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