BT_BitmapSaveFile

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
srvet_claudio
Posts: 1919
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 25 times
Been thanked: 95 times
Contact:

Re: BT_BitmapSaveFile

Post by srvet_claudio » Sun Nov 03, 2013 2:14 am

Andrés, espero que éste ejemplo te sirva de ayuda:

Code: Select all

#include "hmg.ch"
#include "hfcl.ch"


FUNCTION MAIN
PRIVATE cFileName := "BosTaurus_logo.JPG"

   DEFINE WINDOW Win1;
      AT 0,0 ;
      WIDTH 600 ;
      HEIGHT 650 ;
      MAIN;
      TITLE "Click on the picture";
      ON INIT    Proc_ON_INIT ();
      ON RELEASE Proc_ON_RELEASE()
      
      @ 5, 50 IMAGE Image1 PICTURE "" ACTION Proc_ON_CLICK()

   END WINDOW
   CENTER WINDOW Win1
   ACTIVATE WINDOW Win1
RETURN NIL


PROCEDURE Proc_ON_INIT
LOCAL hBitmap := 0
  hBitmap := BT_BitmapLoadFile (cFileName)
  BT_HMGSetImage ("Win1", "Image1", hBitmap)
RETURN


PROCEDURE Proc_ON_CLICK
LOCAL hDC, BTstruct
LOCAL hBitmap
LOCAL nRow := 0
LOCAL nCol := 0

#define OFFSET 40

   GetCursorPos (@nCol, @nRow)
   ScreenToClient (Win1.Image1.HANDLE, @nCol, @nRow)

   hBitmap := BT_HMGGetImage ("Win1", "Image1")

   hDC := BT_CreateDC (hBitmap, BT_HDC_BITMAP, @BTstruct)
       BT_DrawEllipse (hDC, nRow-OFFSET/2, nCol-OFFSET/2, OFFSET, OFFSET, RED, 3)   // Draw in image
   //  BT_Draw... ()                                      // Others draw functions
   BT_DeleteDC (BTstruct)
   
   BT_ClientAreaInvalidateAll (Win1.Image1.HANDLE)
RETURN


PROCEDURE Proc_ON_RELEASE
LOCAL hBitmap
   hBitmap := BT_HMGGetImage ("Win1", "Image1")
   BT_BitmapSaveFile (hBitmap, "Image_33.png", BT_FILEFORMAT_PNG)
   BT_BitmapRelease (hBitmap)
RETURN
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

User avatar
andyglezl
Posts: 826
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 7 times
Been thanked: 18 times
Contact:

Post by andyglezl » Mon Nov 04, 2013 6:06 pm

Gracias Dr. Soto, me sirvio perfecto !.
A mi hija de 8 años le dejaron aprenderse los Estados de la Republica Mexicana,
y le hice este programita para que se los aprendiera además de su ubicación.
-------------------------------------------------------------------------------
Thank you Dr. Soto, served me perfect!.
My 8 year old daughter left him learn the States of the Mexican Republic,
and I made this little program to have them learn besides location.
-------------------------------------------------------------------------------

Code: Select all

*----------------------------------------------------------------------------------------------
#include "hmg.ch"
#include "hfcl.ch"


FUNCTION MAIN
	LOCAL BTstruct
	PRIVATE cFileName := "MapaEdos.Rep.Mex.jpg"		//   <== Pon tu imagen
	PRIVATE hBitmap:=0, hBitmap2:=0, ImgWidth:=0 , ImgHeight:=0, hDC, lFill:=.F., nRow:=0, nCol:=0

	aEstados:={ "Aguascalientes", "Baja California", "Baja California Sur", "Campeche", "Coahuila de Zaragoza", "Colima", ;	
				"Chiapas", "Chihuahua", "Distrito Federal", "Durango", "Guanajuato", "Guerrero", "Hidalgo", "Jalisco", "México", ;	
				"Michoacán", "Morelos", "Nayarit", "Nuevo León", "Oaxaca", "Puebla", "Querétaro", "Quintana Roo", "San Luis Potosí", ;
				"Sinaloa", "Sonora", "Tabasco", "Tamaulipas", "Tlaxcala", "Veracruz", "Yucatán", "Zacatecas" }				

	
	DEFINE WINDOW Win1 AT 0,0 WIDTH 600 HEIGHT 650 MAIN	TITLE "DEMO -   Click on Window to Draw..."	BACKCOLOR {200,216,237}  ;
			ON INIT      Proc_ON_INIT ()       		 				;
			ON RELEASE   Proc_ON_RELEASE() 
     
		@   5 , 310 LABEL LB_Titulo VALUE "Da click en el mapa de acuerdo el nombre. --->" WIDTH 500 HEIGHT 16 FONT 'Verdana' SIZE 10 ;  // BOLD 
					FONTCOLOR BLACK TRANSPARENT RIGHTALIGN
		@   0 , 815 COMBOBOX CB_Estados WIDTH 160 HEIGHT 200 FONT "Arial" SIZE 9 ITEMS aEstados VALUE 1 TOOLTIP "Seleccione un Estado"
		@  25 , 0   IMAGE Image1 PICTURE "" ACTION Proc_ON_CLICK()
		
		DEFINE CONTEXT MENU OF Win1

			MENUITEM "Reload"   ACTION { ||  hBitmap := BT_BitmapLoadFile( cFileName ),   ;		       // NAME <MenuItemName>]  IMAGE <cImageName> ]  CHECKED
													BT_HMGSetImage( "Win1", "Image1", hBitmap ), ;
													BT_ClientAreaInvalidateAll( "Win1" ) }
			SEPARATOR
			MENUITEM "Save"  ACTION { || SaveImg( ) }			
		END MENU

	END WINDOW
	CENTER WINDOW Win1
	ACTIVATE WINDOW Win1
RETURN NIL
FUNCTION UpdYX( )
	Win1.Title:= "DEMO -   Click on Window to Draw...       "+PADC( nRow,5)+" / "+PADC( nCol,5)
RETURN
PROCEDURE Proc_ON_INIT
	hBitmap     := BT_BitmapLoadFile( cFileName )
	Win1.Width  := ImgWidth    := BT_BitmapWidth( hBitmap )
	Win1.Height := ImgHeight   := BT_BitmapHeight( hBitmap )+60
	Win1.Center
	BT_HMGSetImage("Win1", "Image1", hBitmap)
RETURN

PROCEDURE Proc_ON_CLICK
	LOCAL BTstruct  //  hDC, 
	LOCAL hBitmap
	
	*------------------------------------------------
	*#define OFFSET 40										
	GetCursorPos (@nCol, @nRow)							// Para saber las coordenadas dentro del control IMAGE
	ScreenToClient (Win1.Image1.HANDLE, @nCol, @nRow)
	*------------------------------------------------
	UpdYX()
	
	hBitmap := BT_HMGGetImage( "Win1", "Image1" ) 
	hDC := BT_CreateDC( hBitmap, BT_HDC_BITMAP, @BTstruct )
	BT_DrawText( hDC, nRow, nCol, Win1.CB_Estados.DisplayValue, "Lucida", 8, WHITE, BLUE, BT_TEXT_OPAQUE, BT_TEXT_LEFT, BT_TEXT_NORMAL_ORIENTATION )
	BT_DeleteDC(BTstruct)
	BT_ClientAreaInvalidateAll("Win1")						// Repinta toda el area
	Win1.CB_Estados.Value:=Random( LEN( aEstados ) )		// Seleccion aleatoria de un estado
	
RETURN
PROCEDURE SaveImg
	LOCAL hBitmap
	hBitmap := BT_HMGGetImage( "Win1", "Image1" )
	BT_BitmapSaveFile( hBitmap, "Image_33.png", BT_FILEFORMAT_PNG )
	MsgInfo( "Saved Image..." )
RETURN
PROCEDURE Proc_ON_RELEASE
	BT_BitmapRelease( hBitmap )
RETURN
*----------------------------------------------------------------------
Estoy viendo un sin fin de posibilidades para el desarrollo de aplicaciones. Gracias de nuevo !
I'm seeing a lot of possibilities for application development. Thank you again!


Lo siento por la mezcla Español-Ingles.
Sorry for the Spanish-English mixture.
Attachments
RepMex.jpg
RepMex.jpg (74.34 KiB) Viewed 702 times
Andrés González López
Desde Guadalajara, Jalisco. México.

User avatar
andyglezl
Posts: 826
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 7 times
Been thanked: 18 times
Contact:

Post by andyglezl » Tue Nov 12, 2013 10:30 pm

Hola Dr. Soto
Tendrá disponibles estas funciones en la BosTaurus ? ó se pudieran incluir ?
En realidad yo no se que implique hacerlo o si es sencillo o dificil, yo solo pregunto.
Intento rellenar una cierta area de otro color.
------------------------------------------------------------------------
Hello Dr. Soto
You will have these functions available in BosTaurus? or could be included?
Actually I was not implying it or if it is simple or difficult, I just wonder.
I try to fill a certain area of another color.
------------------------------------------------------------------------

RELLENADO DE FIGURAS

floodfill(int x, int y, int border); RELLENAR FIGURA
setfillstyle(int pattern, int color); TIPO DE RELLENO Y COLOR A USAR

TIPOS DE RELLENADO(FILL PATTERNS)

0 EMPTY_FILL
1 SOLID_FILL
2 LINE_FILL
3 LTSLASH_FILL
4 SLASH_FILL
5 BKSLASH_FILL
6 LTBKSLASH_FILL
7 HATCH_FILL
8 XHATCH_FILL
9 INTERLEAVE_FILL
10 WIDE_DOT_FILL
11 CLOSE_DOT_FILL
12 USER_FILL
Andrés González López
Desde Guadalajara, Jalisco. México.

User avatar
srvet_claudio
Posts: 1919
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 25 times
Been thanked: 95 times
Contact:

Post by srvet_claudio » Wed Nov 13, 2013 2:51 am

andyglezl wrote:Hola Dr. Soto
Tendrá disponibles estas funciones en la BosTaurus ? ó se pudieran incluir ?
En realidad yo no se que implique hacerlo o si es sencillo o dificil, yo solo pregunto.
Intento rellenar una cierta area de otro color.
------------------------------------------------------------------------
Hello Dr. Soto
You will have these functions available in BosTaurus? or could be included?
Actually I was not implying it or if it is simple or difficult, I just wonder.
I try to fill a certain area of another color.
------------------------------------------------------------------------

RELLENADO DE FIGURAS

floodfill(int x, int y, int border); RELLENAR FIGURA
setfillstyle(int pattern, int color); TIPO DE RELLENO Y COLOR A USAR

TIPOS DE RELLENADO(FILL PATTERNS)

0 EMPTY_FILL
1 SOLID_FILL
2 LINE_FILL
3 LTSLASH_FILL
4 SLASH_FILL
5 BKSLASH_FILL
6 LTBKSLASH_FILL
7 HATCH_FILL
8 XHATCH_FILL
9 INTERLEAVE_FILL
10 WIDE_DOT_FILL
11 CLOSE_DOT_FILL
12 USER_FILL
Lo incluiré en la próxima versión.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

User avatar
andyglezl
Posts: 826
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 7 times
Been thanked: 18 times
Contact:

Post by andyglezl » Wed Nov 13, 2013 3:11 am

Muy agradecido Dr. Soto.
Andrés González López
Desde Guadalajara, Jalisco. México.

User avatar
srvet_claudio
Posts: 1919
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 25 times
Been thanked: 95 times
Contact:

Post by srvet_claudio » Sun May 25, 2014 1:13 am

Andres en HMG.3.3.0 existe:

Code: Select all

BT_DrawFillFlood (hDC, Row, Col, aColorRGBFill) 
Fill an area in all directions defined by the color of the point of the specified 
coordinates. 
hDC: is a handle to the device context. 
Row, Col: specifies the coordinates in pixels of the point where begin filling. 
aColorRGBFill: array that contains the RGB colors that set of the fill color. 
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 4 guests