BITMAP.CH

You can share your experience with HMG. Share with some screenshots/project details so that others will also be benefited.

Moderator: Rathinagiri

User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

BITMAP.CH

Post by srvet_claudio »

Hello everyone.
I leave here a set of functions to manipulate BMP images.

I have attached four examples:
1) RUN HORSE: graphic animation (movie)
2) VIEW IMAGE: view BMP image, load, save, rotate, transform, copy / paste clipboard, capture desktop, change the brightness, etc.
3) AIR FIRE: down planes with anti-aircraft battery
4) MOVE DOG: Move a dog

Best Regards,
Claudio Soto.

Code: Select all


****************************************************************************************************************
* PROGRAMA:	BITMAP.CH
* LENGUAJE: HARBOUR-MINIGUI 3.0.34
* FECHA:	12 JUNIO 2010
* AUTOR:	Dr. CLAUDIO SOTO SILVA
* PAIS:		URUGUAY
* E-MAIL:	srvet@adinet.com.uy
****************************************************************************************************************



****************************************************************************************************************
* Functions that manipulate the native control IMAGE of HMG (Image Control HMG = static window)
****************************************************************************************************************
* IMAGE_GET_hWND     (cWinName, cImageName) ====> Return hWnd 
*
* IMAGE_GET_hBITMAP  (cWinName, cImageName) ====> Return hBitmap 
*
* IMAGE_SET_hBITMAP  (cWinName, cImageName, hBitmap, Width, Height) ====> Set and show hBITMAP in IMAGE Control of HMG
* 
* IMAGE_SHOW_hBITMAP (hWND, hBitmap)           ====> Show hBitmap in IMAGE Control of HMG
* 
****************************************************************************************************************



****************************************************************************************************************
* Functions that manipulate BITMAP 
****************************************************************************************************************
* BMP_GET_INFO   (hBitmap, Info) ---> Return BMP_INFO_xxx
*
* BMP_LOAD_FILE  (cFileBMP) ---> Return hBITMAP
* BMP_SAVE_FILE  (hBitmap, cFileBMP) ---> Return Success (TRUE or FALSE)
*
* BMP_CREATE     (Width, Height) ---> Return hBITMAP
* BMP_RELEASE    (hBitmap) ---> Return Success (TRUE or FALSE)
*
* BMP_RESIZE     (hBitmap, New_Width, New_Height, modo_stretch) ---> Return new_hBitmap
* BMP_TRANSFORM  (hBitmap, modo, Angle, Color_Fill) ---> Return New_hBitmap
*
* BMP_SET_PIXEL  (hBitmap, x, y, Color_RGB)
* BMP_GET_PIXEL  (hBitmap, x, y) ---> Return {R,G,B}
*
* BMP_GET_SPRITE          (hBitmap, x, y, Width, Height) ---> Return new_hBITMAP
* BMP_PUT_SPRITE          (hBitmap_D, x1, y1, hBitmap_O, x2, y2, Width2, Height2)
* BMP_ISPOINT_IN_SPRITE   (Px, Py, hBitmap, x, y, Width, Height, Color_Transp, modo)
* BMP_IS_INTERSECT_SPRITE (hBitmap1, x1, y1, Width1, Height1, Color_Transp1, hBitmap2, x2, y2, Width2, Height2, Color_Transp2, modo)
*
* BMP_CLIPBOARD_EMPTY ()      ---> Return TRUE (Empty clipboard: DIB format) or FALSE (Not empty clipboard)
* BMP_GET_CLIPBOARD   ()      ---> Return hBitmap (Success) or 0 (Failure or Clipboard Empty DIB format)
* BMP_PUT_CLIPBOARD (hBitmap) ---> Return Success (TRUE or FALSE)
* 
* BMP_COPY_BITBLT         (hBitmap_D, x1, y1, Width1, Height1, hBitmap_O, x2, y2)
* BMP_COPY_STRETCHBLT     (hBitmap_D, x1, y1, Width1, Height1, hBitmap_O, x2, y2, Width2, Height2, modo_stretch)
* BMP_COPY_TRANSPARENTBLT (hBitmap_D, x1, y1, Width1, Height1, hBitmap_O, x2, y2, Width2, Height2, Color_RGB_Transp, modo_stretch)
* BMP_COPY_ALPHABLEND     (hBitmap_D, x1, y1, Width1, Height1, hBitmap_O, x2, y2, Width2, Height2, Alpha, modo_stretch)
* 
* BMP_SHOW                     (hWnd, x, y, Width, Height, hBitmap, modo_stretch)
* BMP_PUTSCREEN_BITBLT         (hWnd, x1, y1, Width1, Height1, hBitmap, x2, y2)
* BMP_PUTSCREEN_STRETCHBLT     (hWnd, x1, y1, Width1, Height1, hBitmap, x2, y2, Width2, Height2, modo_stretch)
* BMP_PUTSCREEN_TRANSPARENTBLT (hWnd, x1, y1, Width1, Height1, hBitmap, x2, y2, Width2, Height2, color_transp, modo_stretch)
* BMP_PUTSCREEN_ALPHABLEND     (hWnd, x1, y1, Width1, Height1, hBitmap, x2, y2, Width2, Height2, Alpha, modo_stretch)
* 
* BMP_GETSCREEN_BITBLT         (hBitmap, x1, y1, Width1, Height1, hWnd, x2, y2)
* BMP_GETSCREEN_STRETCHBLT     (hBitmap, x1, y1, Width1, Height1, hWnd, x2, y2, Width2, Height2, modo_stretch)
* BMP_GETSCREEN_TRANSPARENTBLT (hBitmap, x1, y1, Width1, Height1, hWnd, x2, y2, Width2, Height2, color_transp, modo_stretch)
* BMP_GETSCREEN_ALPHABLEND     (hBitmap, x1, y1, Width1, Height1, hWnd, x2, y2, Width2, Height2, Alpha, modo_stretch)
* 
* BMP_CLEAN              (hBitmap, x, y, Width, Height, color_RGB)
* BMP_GRAY               (hBitmap, x, y, Width, Height, gray_level)       gray_level = 0 To 100%    
* BMP_LIGHT              (hBitmap, x, y, Width, Height, light_level)       light_level = -255 To +255    
* BMP_CHANGUE_COLOR      (hBitmap, x, y, Width, Height, old_RGB, new_RGB)
* BMP_CHANGUE_COLOR_DIST (hBitmap, x, y, Width, Height, RGB_Color, new_RGB, Dist, Comp)
* 
* BMP_TEXTOUT (hBitmap, x, y, Text, FontName, FontSize, Text_Color, Back_color, Type, Align)
********************************************************************************************************************************



****************************************************************************************************************
* Functions that implement direct GDI functions
****************************************************************************************************************
* GDI_GET_PIXEL (hWND, x, y) ---> Return {R,G,B}
*
* GDI_SET_PIXEL (hWND, x, y, Color_RGB)
****************************************************************************************************************



****************************************************************************************************************
* Miscellaneous functions
****************************************************************************************************************
* WIN_GETCURSOR_POS (hWnd) ---> Return {x,y}
*
* WIN_SETCURSOR_POS (hWnd, x, y)
*
* WIN_GET_CLIENT_RECT (hWnd) ---> Return {Width, Height}
*
* WIN_GET_hWND (cWinName)  ---> Return hWnd
*
* BMP_DESKTOP_hWND          ---> Constant 0
****************************************************************************************************************



****************************************************************************************************************
* Functions that DELAY execution of the program
****************************************************************************************************************
* SYS_DELAY (nTicks)                --->  1000 Ticks/seg ---> 1 Ticks = 1 MiliSeg (define in time.h)
*
* SYS_DELAY_WITH_DOEVENTS (nTicks)  --->  1000 Ticks/seg ---> 1 Ticks = 1 MiliSeg (define in time.h)
*
* SYS_CLOCK ()                      ---> Return nTicks
****************************************************************************************************************


**********************************************************************************
* BMP constant definition   
**********************************************************************************

// BMP_Get_Info()
#define BMP_INFO_WIDTH     0
#define BMP_INFO_HEIGHT    1
#define BMP_INFO_BITSPIXEL 2



//  BMP_Transform ()
//           MODO                         ANGLE                       COLOR_FILL                
#define BMP_REFLECT_HORIZONTAL 1   //     Not use                     Not use
#define BMP_REFLECT_VERTICAL   2   //     Not use                     Not use
#define BMP_ROTATE             4   //     Angle (0 to 360 degree)     Color fill blank space



//  BMP_IsPoint_In_Sprite ()  
//  BMP_Is_Intersect_Sprite ()
#define BMP_OPAQUE       0 
#define BMP_TRANSPARENT  1



//                                                       _x_ ---> _Copy_, _PutScreen_, _GetScreen_ 
#define BMP_SCALE   0   // BMP_SHOW(),  BMP_Resize(), BMP_x_StretchBlt(), BMP_x_TransparentBlt(), BMP_x_AlphaBlend()
#define BMP_STRETCH 1   // BMP_SHOW(),  BMP_Resize(), BMP_x_StretchBlt(), BMP_x_TransparentBlt(), BMP_x_AlphaBlend()
#define BMP_COPY    3   // BMP_SHOW() 



//BMP_Gray ()       gray_level = 0 To 100%    
#define BMP_GRAY_NONE 0
#define BMP_GRAY_FULL 100



// BMP_Light ()    light_level = -255 To +255
#define BMP_LIGHT_BLACK -255
#define BMP_LIGHT_NONE  0
#define BMP_LIGHT_WHITE 255



// BMP_Changue_Color_Dist()
#define BMP_CHANGUE_COLOR_DIST_EQ 0    // DIST() == Dist  ---> (equal)
#define BMP_CHANGUE_COLOR_DIST_LE 1    // DIST() <= Dist  ---> (less or equal)
#define BMP_CHANGUE_COLOR_DIST_GE 2    // DIST() >= Dist  ---> (great or equal)



// BMP_TextOut()
#define BMP_TEXTOUT_OPAQUE      0
#define BMP_TEXTOUT_TRANSPARENT 1

#define BMP_TEXTOUT_BOLD        2
#define BMP_TEXTOUT_ITALIC      4
#define BMP_TEXTOUT_UNDERLINE   8
#define BMP_TEXTOUT_STRIKEOUT   16

#define BMP_TEXTOUT_LEFT        0
#define BMP_TEXTOUT_CENTER      1
#define BMP_TEXTOUT_RIGHT       2
Attachments
BITMAP.CH.rar
(3.98 MiB) Downloaded 818 times
Last edited by srvet_claudio on Mon Jun 28, 2010 1:44 am, edited 2 times in total.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: BITMAP.CH

Post by Roberto Lopez »

srvet_claudio wrote:Hello everyone.
I leave here a set of functions to manipulate BMP images.
<...>
Nice!!!

Thanks!!!!!!
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: BITMAP.CH

Post by srvet_claudio »

Roberto Lopez wrote:Nice!!!

Thanks!!!!!!
Thanks Roberto.


Hello everyone:

Attention:
In the previous post,
I changed (Mon June 28, 2010 1:45 a.m.) the original file by the current BITMAP.CH.rar (due to a small bug in the original).
Sorry for the inconvenience.
Best Regards,
Claudio Soto

PD:If your downloaded the original file, please download again and change original file for the new file.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: BITMAP.CH

Post by Rathinagiri »

Thanks a lot Claudio. Really helpful.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
dhaine_adp
Posts: 457
Joined: Wed Aug 06, 2008 12:22 pm
Location: Manila, Philippines

Re: BITMAP.CH

Post by dhaine_adp »

Hi Doctor,

Thank you very much for your contribution. It's cool!

Regards,

Danny
Regards,

Danny
Manila, Philippines
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: BITMAP.CH

Post by Rathinagiri »

Fantastic work! So, we can expect a fun game soon in HMG! :) Whoo!

But, the first sample (run horse) crashes for me. Mine is Win XP.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: BITMAP.CH

Post by esgici »

Thanks Dr. :)

Good work, best performence :D

Regards

--

Esgici
Viva INTERNATIONAL HMG :D
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: BITMAP.CH

Post by mustafa »

Amigo Claudio
Fenomenal !!!!
Gracias por compartir
Un abrazo
Mustafa ;)
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: BITMAP.CH

Post by srvet_claudio »

Thanks Rathinagiri, Danny, Marek, Esgici and Mustafa.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
Post Reply