MiniGUI API Reference (MiniGUI-Processes)  v5.0.6
A mature and proven cross-platform GUI system for embedded and smart IoT devices
Macros | Typedefs | Functions
Bitmap file load/save operations

Example: More...

Macros

#define MLS_BLENDMODE_NONE   0x00
 
#define LoadBitmap   LoadBitmapFromFile
 An alias of LoadBitmapFromFile. More...
 
#define LoadMyBitmap   LoadMyBitmapFromFile
 Alias of LoadMyBitmapFromFile. More...
 

Typedefs

typedef BOOL(* CB_ALLOC_BITMAP_BUFF) (void *context, BITMAP *bmp)
 The type of callback to allocate pixel buffer for BITMAP object. More...
 
typedef void(* CB_ONE_SCANLINE) (void *context, MYBITMAP *my_bmp, int y)
 The type of scanline loaded callback. More...
 

Functions

const MG_EXPORT char *GUIAPI CheckBitmapType (MG_RWops *fp)
 Check the type of the bitmap in a data source. More...
 
MG_EXPORT BOOL GUIAPI mlsEnableSlaveScreen (HDC dc_mls, BOOL enable)
 Enable or Disable a MLShadow slave screen. More...
 
MG_EXPORT int GUIAPI LoadBitmapEx2 (HDC hdc, PBITMAP pBitmap, MG_RWops *area, const char *ext, CB_ALLOC_BITMAP_BUFF cb_alloc_buff, void *context)
 Load a device-dependent bitmap from a general data source. More...
 
static int LoadBitmapEx (HDC hdc, PBITMAP pBitmap, MG_RWops *area, const char *ext)
 Load a device-dependent bitmap from a general data source. More...
 
MG_EXPORT int GUIAPI LoadBitmapFromFile (HDC hdc, PBITMAP pBitmap, const char *spFileName)
 Load a device-dependent bitmap from a file. More...
 
MG_EXPORT int GUIAPI LoadBitmapFromMem (HDC hdc, PBITMAP pBitmap, const void *mem, size_t size, const char *ext)
 Load a device-dependent bitmap from memory. More...
 
MG_EXPORT void GUIAPI UnloadBitmap (PBITMAP pBitmap)
 Unloads a bitmap. More...
 
MG_EXPORT int GUIAPI SetBitmapKeyColor (HDC hdc, PBITMAP bmp, Uint8 r, Uint8 g, Uint8 b)
 Set the bitmap color key. More...
 
MG_EXPORT void GUIAPI ReplaceBitmapColor (HDC hdc, PBITMAP pBitmap, gal_pixel iOColor, gal_pixel iNColor)
 Replaces a specific pixels in a bitmap with another pixel. More...
 
MG_EXPORT void GUIAPI HFlipBitmap (BITMAP *bmp, unsigned char *inter_buff)
 Horizontal Flip the special Bitmap object. More...
 
MG_EXPORT void GUIAPI VFlipBitmap (BITMAP *bmp, unsigned char *inter_buff)
 Vertical Flip the special Bitmap object. More...
 
MG_EXPORT void *GUIAPI InitMyBitmapSL (MG_RWops *area, const char *ext, MYBITMAP *my_bmp, RGB *pal)
 Initializes scanline loader of the MYBITMAP object from a data source. More...
 
MG_EXPORT int GUIAPI LoadMyBitmapSL (MG_RWops *area, void *load_info, MYBITMAP *my_bmp, CB_ONE_SCANLINE cb, void *context)
 Load MYBITMAP scanlines from a data source one by one. More...
 
MG_EXPORT int GUIAPI CleanupMyBitmapSL (MYBITMAP *my_bmp, void *load_info)
 Cleanups the scanline loader. More...
 
MG_EXPORT int GUIAPI LoadMyBitmapEx (PMYBITMAP my_bmp, RGB *pal, MG_RWops *area, const char *ext)
 Load a MYBITMAP object from a data source. More...
 
MG_EXPORT int GUIAPI LoadMyBitmapFromFile (PMYBITMAP my_bmp, RGB *pal, const char *file_name)
 Load a MYBITMAP object from a file. More...
 
MG_EXPORT int GUIAPI LoadMyBitmapFromMem (PMYBITMAP my_bmp, RGB *pal, const void *mem, size_t size, const char *ext)
 Load a MYBITMAP object from memory. More...
 
MG_EXPORT void GUIAPI UnloadMyBitmap (PMYBITMAP my_bmp)
 Unloads a bitmap. More...
 
MG_EXPORT int GUIAPI SaveMyBitmapToFile (PMYBITMAP my_bmp, RGB *pal, const char *spFileName)
 Saves a MYBITMAP object to a bitmap file. More...
 
MG_EXPORT int GUIAPI SaveBitmapToFile (HDC hdc, PBITMAP pBitmap, const char *spFileName)
 Saves a BITMAP object to a bitmap file. More...
 
MG_EXPORT BOOL GUIAPI InitBitmap (HDC hdc, Uint32 w, Uint32 h, Uint32 pitch, BYTE *bits, PBITMAP bmp)
 Initializes a BITMAP object as a normal bitmap. More...
 
MG_EXPORT HDC GUIAPI InitSlaveScreenEx (const char *name, const char *mode, int dpi)
 Initializes slave screen. More...
 
static HDC InitSlaveScreen (const char *name, const char *mode)
 Initializes slave screen. More...
 
MG_EXPORT void GUIAPI TerminateSlaveScreen (HDC hdc)
 Terminates slave screen. More...
 
MG_EXPORT BOOL GUIAPI InitBitmapPixelFormat (HDC hdc, PBITMAP bmp)
 Initializes the bitmap pixel format information of a BITMAP object. More...
 
MG_EXPORT void GUIAPI DeleteBitmapAlphaPixel (PBITMAP bmp)
 Deletes the bitmap alpha pixel format information of a BITMAP object. More...
 
MG_EXPORT int GUIAPI ExpandMyBitmap (HDC hdc, PBITMAP bmp, const MYBITMAP *my_bmp, const RGB *pal, int frame)
 Expands a MYBITMAP object to a BITMAP object. More...
 
MG_EXPORT void GUIAPI ExpandMonoBitmap (HDC hdc, BYTE *bits, Uint32 pitch, const BYTE *my_bits, Uint32 my_pitch, Uint32 w, Uint32 h, DWORD flags, Uint32 bg, Uint32 fg)
 Convert a mono color MYBITMAP pixel data to a BITMAP pixel data. More...
 
static void GUIAPI Expand16CBitmap (HDC hdc, BYTE *bits, Uint32 pitch, const BYTE *my_bits, Uint32 my_pitch, Uint32 w, Uint32 h, DWORD flags, const RGB *pal)
 Convert a 16 color MYBITMAP pixel data to a BITMAP pixel data. More...
 
static void GUIAPI Expand256CBitmap (HDC hdc, BYTE *bits, Uint32 pitch, const BYTE *my_bits, Uint32 my_pitch, Uint32 w, Uint32 h, DWORD flags, const RGB *pal, CB_DRAW_PIXEL cb_draw, MYBITMAP_CONTXT *mybmp)
 Convert a 256 color MYBITMAP pixel data to a BITMAP pixel data. More...
 
MG_EXPORT void GUIAPI CompileRGBABitmap (HDC hdc, BYTE *bits, Uint32 pitch, const BYTE *my_bits, Uint32 my_pitch, Uint32 w, Uint32 h, DWORD flags, void *pixel_format, CB_DRAW_PIXEL cb_draw, MYBITMAP_CONTXT *mybmp)
 Convert a MYBITMAP pixel data to a BITMAP pixel data. More...
 
MG_EXPORT void GUIAPI CompileRGBABitmapEx (HDC hdc, BYTE *bits, Uint32 pitch, const BYTE *my_bits, Uint32 my_pitch, Uint32 w, Uint32 h, DWORD flags, void *pixel_format, CB_DRAW_PIXEL cb_draw, MYBITMAP_CONTXT *mybmp, BYTE *alpha_mask)
 Compile a MYBITMAP pixel data to a BITMAP pixel data. More...
 
MG_EXPORT int GUIAPI PaintImageEx (HDC hdc, int x, int y, MG_RWops *area, const char *ext)
 Paints an image from data source on device directly. More...
 
MG_EXPORT int GUIAPI PaintImageFromFile (HDC hdc, int x, int y, const char *spFileName)
 Paints an image from file on device directly. More...
 
MG_EXPORT int GUIAPI PaintImageFromMem (HDC hdc, int x, int y, const void *mem, size_t size, const char *ext)
 Paints an image from memory on device directly. More...
 
MG_EXPORT int GUIAPI StretchPaintImageEx (HDC hdc, int x, int y, int w, int h, MG_RWops *area, const char *ext)
 Paints an image from data source on device directly. More...
 
MG_EXPORT int GUIAPI StretchPaintImageFromFile (HDC hdc, int x, int y, int w, int h, const char *spFileName)
 Paints an image from file on device directly. More...
 
MG_EXPORT int GUIAPI StretchPaintImageFromMem (HDC hdc, int x, int y, int w, int h, const void *mem, size_t size, const char *ext)
 Paints an image from memory on device directly. More...
 
MG_EXPORT void GUIAPI RotateBitmap (HDC hdc, const BITMAP *bmp, int lx, int ty, int angle)
 Rotate a bitmap object. More...
 
MG_EXPORT void GUIAPI RotateBitmapVFlip (HDC hdc, const BITMAP *bmp, int lx, int ty, int angle)
 Flips vertically and rotates a bitmap object. More...
 
MG_EXPORT void GUIAPI RotateBitmapHFlip (HDC hdc, const BITMAP *bmp, int lx, int ty, int angle)
 Flips horizontally and rotates a bitmap object. More...
 
MG_EXPORT void GUIAPI RotateScaledBitmap (HDC hdc, const BITMAP *bmp, int lx, int ty, int angle, int w, int h)
 Stretches or shrinks a bitmap object at the same as rotating it. More...
 
MG_EXPORT void GUIAPI RotateScaledBitmapVFlip (HDC hdc, const BITMAP *bmp, int lx, int ty, int angle, int w, int h)
 Flip vertically, rotates, stretch or shrinks a bitmap object. More...
 
MG_EXPORT void GUIAPI RotateScaledBitmapHFlip (HDC hdc, const BITMAP *bmp, int lx, int ty, int angle, int w, int h)
 Flip horizontaly, rotates, stretch or shrinks a bitmap object. More...
 
MG_EXPORT void GUIAPI PivotBitmap (HDC hdc, const BITMAP *bmp, int lx, int ty, int cx, int cy, int angle)
 Pivot a bitmap object. More...
 
MG_EXPORT void GUIAPI PivotScaledBitmapFlip (HDC hdc, const BITMAP *bmp, fixed x, fixed y, fixed cx, fixed cy, int angle, fixed scale_x, fixed scale_y, BOOL h_flip, BOOL v_flip)
 Rotates, stretches or shrinks, flips a bitmap object. More...
 

Detailed Description

Example:

/*
* The following code loads a BITMAP object from a file and then
* fills a box in a DC.
*
* You should note that the code assigns 'bmType' field of the BITMAP object directly.
*/
{
int tox = 800, toy = 800;
int count;
BITMAP bitmap;
unsigned int start_tick, end_tick;
/* Load the bitmap from the file. */
if (LoadBitmap (hdc, &bitmap, "res/icon.bmp"))
return;
bitmap.bmType = BMP_TYPE_ALPHACHANNEL;
/* Fill a box with the bitmap with alpha channel. */
start_tick = GetTickCount ();
count = 1000;
while (count--) {
tox = rand() % 800;
toy = rand() % 800;
/* Set a random alpha channel. */
bitmap.bmAlpha = rand() % 256;
/* Fill the box. */
FillBoxWithBitmap (hdc, tox, toy, 0, 0, &bitmap);
}
end_tick = GetTickCount ();
TellSpeed (hwnd, start_tick, end_tick, "Alpha Blended Bitmap", 1000);
bitmap.bmType = BMP_TYPE_ALPHACHANNEL | BMP_TYPE_COLORKEY;
/* Set the color key (the transparent pixel) of the bitmap. */
bitmap.bmColorKey = GetPixelInBitmap (&bitmap, 0, 0);
/* Fill a box with the bitmap with alpha channel and color key. */
start_tick = GetTickCount ();
count = 1000;
while (count--) {
tox = rand() % 800;
toy = rand() % 800;
/* Set a random alpha channel. */
bitmap.bmAlpha = rand() % 256;
/* Fill the box. */
FillBoxWithBitmap (hdc, tox, toy, 0, 0, &bitmap);
}
end_tick = GetTickCount ();
TellSpeed (hwnd, start_tick, end_tick, "Alpha Blended Transparent Bitmap", 1000);
UnloadBitmap (&bitmap);
}

Macro Definition Documentation

◆ LoadBitmap

#define LoadBitmap   LoadBitmapFromFile

An alias of LoadBitmapFromFile.

See also
LoadBitmapFromFile

Definition at line 11407 of file gdi.h.

◆ LoadMyBitmap

#define LoadMyBitmap   LoadMyBitmapFromFile

Alias of LoadMyBitmapFromFile.

See also
LoadMyBitmapFromFile

Definition at line 11583 of file gdi.h.

◆ MLS_BLENDMODE_NONE

#define MLS_BLENDMODE_NONE   0x00

This function is used to set attributes of MLShadow slave screen. After creating a slave screen by InitSlaveScreen successfully, you should call this function to set its attributes. When blend_flags is MLS_INFOMASK_ALL, it will set all attributes of slave screen.

Parameters
dc_mlsThe handle to the slave screen.
maskThe attributes mask, can be or'ed values of the following mask:
  • MLS_INFOMASK_OFFSET
    Set x and y offset value of slave screen.
  • MLS_INFOMASK_BLEND
    Set blend mode of slave screen.
  • MLS_INFOMASK_ZORDER
    Set z_order value of slave screen.
  • MLS_INFOMASK_ALL
    Set all attribute value of slave screen.
Parameters
offset_xThe x offset value of slave screen relative to masterscreen.
offset_yThe y offset value of slave screen relative to masterscreen.
blend_flagsThe blend flags, can be one of the following values:
  • MLS_BLENDMODE_COLORKEY
    Set color_key value of slave screen.
  • MLS_BLENDMODE_ALPHA
    Set alpha value of slave screen.
  • MLS_BLENDMODE_NONE
    The value of alpha and color_key is invalid.
Parameters
color_keyThe colorkey value of MLShadow slave screen.
alphaThe alpha value of MLShadow slave screen.
z_orderThe zorder of MLShadow slave screen.
Returns
TRUE on success, FALSE on error.

Definition at line 11279 of file gdi.h.

Typedef Documentation

◆ CB_ALLOC_BITMAP_BUFF

typedef void(* CB_ALLOC_BITMAP_BUFF)(void *context, BITMAP *bmp)

The type of callback to allocate pixel buffer for BITMAP object.

Return TRUE for success, otherwise FALSE.

Definition at line 11171 of file gdi.h.

◆ CB_ONE_SCANLINE

typedef void(* CB_ONE_SCANLINE)(void *context, MYBITMAP *my_bmp, int y)

The type of scanline loaded callback.

Definition at line 11177 of file gdi.h.

Function Documentation

◆ CheckBitmapType()

const char *GUIAPI CheckBitmapType ( MG_RWops fp)

Check the type of the bitmap in a data source.

This function checks the type of the bitmap in the data source fp, and returns the extension of this type of bitmap file.

Parameters
fpThe pointer to the data source.
Returns
The extension of the type of bitmap file. NULL for not recongnized bitmap type.
See also
RegisterBitmapFileType

◆ CleanupMyBitmapSL()

int GUIAPI CleanupMyBitmapSL ( MYBITMAP my_bmp,
void *  load_info 
)

Cleanups the scanline loader.

This function cleanups the scanline loader.

Parameters
my_bmpThe pointer to the MYBITMAP object.
load_infoThe initialized information retured by InitMyBitmapSL function.
Returns
0 on success, less than 0 on error.
See also
LoadMyBitmapEx, InitMyBitmapSL, LoadMyBitmapSL

◆ CompileRGBABitmap()

void GUIAPI CompileRGBABitmap ( HDC  hdc,
BYTE bits,
Uint32  pitch,
const BYTE my_bits,
Uint32  my_pitch,
Uint32  w,
Uint32  h,
DWORD  flags,
void *  pixel_format,
CB_DRAW_PIXEL  cb_draw,
MYBITMAP_CONTXT *  mybmp 
)

Convert a MYBITMAP pixel data to a BITMAP pixel data.

This function Convert a MYBITMAP pixel data to a BITMAP pixel data.

Parameters
hdcThe device context.
bitsThe BITMAP pixel data(RGBA etc.).
pitchThe pitch of the BITMAP object.
my_bitsThe MYBITMAP pixel data to be compile.
my_pitchThe pitch of the MYBITMAP object.
wThe width of the MYBITMAP object.
hThe height of the MYBITMAP object.
flagsThe flags of the MYBITMAP object.
pixel_formatThe pixel format of the MYBITMAP object.
cb_drawThe draw callback function.
mybmpThe context of cb_draw.
See also
CompileRGBABitmapEx

◆ CompileRGBABitmapEx()

void GUIAPI CompileRGBABitmapEx ( HDC  hdc,
BYTE bits,
Uint32  pitch,
const BYTE my_bits,
Uint32  my_pitch,
Uint32  w,
Uint32  h,
DWORD  flags,
void *  pixel_format,
CB_DRAW_PIXEL  cb_draw,
MYBITMAP_CONTXT *  mybmp,
BYTE alpha_mask 
)

Compile a MYBITMAP pixel data to a BITMAP pixel data.

This function compile a MYBITMAP pixel data to a BITMAP pixel data.

See also
CompileRGBABitmap

◆ DeleteBitmapAlphaPixel()

void GUIAPI DeleteBitmapAlphaPixel ( PBITMAP  bmp)

Deletes the bitmap alpha pixel format information of a BITMAP object.

This function deletes the bitmap alpha pixel format information of the BITMAP object bmp.

See also
InitBitmapPixelFormat

◆ Expand16CBitmap()

void GUIAPI Expand16CBitmap ( HDC  hdc,
BYTE bits,
Uint32  pitch,
const BYTE my_bits,
Uint32  my_pitch,
Uint32  w,
Uint32  h,
DWORD  flags,
const RGB pal 
)
inlinestatic

Convert a 16 color MYBITMAP pixel data to a BITMAP pixel data.

This function compile a 16 color MYBITMAP pixel data to a BITMAP pixel data.

Parameters
hdcThe device context.
bitsThe BITMAP pixel data(RGBA etc.).
pitchThe pitch of the BITMAP object.
my_bitsThe MYBITMAP pixel data to be compile.
my_pitchThe pitch of the MYBITMAP object.
wThe width of the MYBITMAP object.
hThe height of the MYBITMAP object.
flagsThe flags of the MYBITMAP object.
palThe Palette of the MYBITMAP object.
See also
ExpandMonoBitmap, Expand256CBitmap

Definition at line 11858 of file gdi.h.

◆ Expand256CBitmap()

void GUIAPI Expand256CBitmap ( HDC  hdc,
BYTE bits,
Uint32  pitch,
const BYTE my_bits,
Uint32  my_pitch,
Uint32  w,
Uint32  h,
DWORD  flags,
const RGB pal,
CB_DRAW_PIXEL  cb_draw,
MYBITMAP_CONTXT *  mybmp 
)
inlinestatic

Convert a 256 color MYBITMAP pixel data to a BITMAP pixel data.

This function compile a 256 color MYBITMAP pixel data to a BITMAP pixel data.

Parameters
hdcThe device context.
bitsThe BITMAP pixel data(RGBA etc.).
pitchThe pitch of the BITMAP object.
my_bitsThe MYBITMAP pixel data to be compile.
my_pitchThe pitch of the MYBITMAP object.
wThe width of the MYBITMAP object.
hThe height of the MYBITMAP object.
flagsThe flags of the MYBITMAP object.
palThe Palette of the MYBITMAP object.
cb_drawThe draw callback function.
mybmpThe context of cb_draw.
See also
ExpandMonoBitmap, Expand16CBitmap

Definition at line 11895 of file gdi.h.

◆ ExpandMonoBitmap()

void GUIAPI ExpandMonoBitmap ( HDC  hdc,
BYTE bits,
Uint32  pitch,
const BYTE my_bits,
Uint32  my_pitch,
Uint32  w,
Uint32  h,
DWORD  flags,
Uint32  bg,
Uint32  fg 
)

Convert a mono color MYBITMAP pixel data to a BITMAP pixel data.

This function compile a MYBITMAP pixel data to a BITMAP pixel data.

Parameters
hdcThe device context.
bitsThe BITMAP pixel data(RGBA etc.).
pitchThe pitch of the BITMAP object.
my_bitsThe MYBITMAP pixel data to be compile.
my_pitchThe pitch of the MYBITMAP object.
wThe width of the MYBITMAP object.
hThe height of the MYBITMAP object.
flagsThe flags of the MYBITMAP object.
bgThe foreground color of the BITMAP object.
fgThe foreground color of the BITMAP object.
See also
Expand16CBitmap, Expand256CBitmap

◆ ExpandMyBitmap()

int GUIAPI ExpandMyBitmap ( HDC  hdc,
PBITMAP  bmp,
const MYBITMAP my_bmp,
const RGB pal,
int  frame 
)

Expands a MYBITMAP object to a BITMAP object.

This function expands the MYBITMAP object pointed to by my_bmp to a BITMAP object (bmp).

Parameters
hdcThe device context.
bmpThe expanded BITMAP object.
my_bmpThe MYBITMAP object to be expanded.
palThe palette of the MYBITMAP object.
frameThe frame of the MYBITMAP object.
Returns
0 on success, non-zero on error.

◆ HFlipBitmap()

void void GUIAPI HFlipBitmap ( BITMAP bmp,
unsigned char *  inter_buff 
)

Horizontal Flip the special Bitmap object.

Parameters
bmpThe BITMAP object.
inter_buffThe one scan line pre-alloc buffer of bitmap.

◆ InitBitmap()

BOOL GUIAPI InitBitmap ( HDC  hdc,
Uint32  w,
Uint32  h,
Uint32  pitch,
BYTE bits,
PBITMAP  bmp 
)

Initializes a BITMAP object as a normal bitmap.

This function initializes the bitmap pointed to by bmp as a normal bitmap. It sets the bitmap structure fields, and allocates the bits if bits is NULL.

Parameters
hdcThe device context.
wThe width of the bitmap.
hThe height of the bitmap.
pitchThe pitch of the bitmap.
bitsThe bits of the bitmap.
bmpThe BITMAP object to be initialized.
Returns
TRUE on success, FALSE on error.
Note
LoadBitmapEx will initialize the BITMAP object itself.
See also
InitBitmapPixelFormat, UnloadBitmap, Bitmap structure

◆ InitBitmapPixelFormat()

BOOL GUIAPI InitBitmapPixelFormat ( HDC  hdc,
PBITMAP  bmp 
)

Initializes the bitmap pixel format information of a BITMAP object.

This function initializes the bitmap pixel format information of the BITMAP object pointed to by bmp. This includes bmBitsPerPixel and bmBytesPerPixel fields, and the private pixel format if the bitmap is a bitmap with alpha.

Parameters
hdcThe device context.
bmpThe BITMAP object to be initialized.
Returns
TRUE on success, FALSE on error.
See also
InitBitmap, Bitmap structure

◆ InitMyBitmapSL()

void *GUIAPI InitMyBitmapSL ( MG_RWops area,
const char *  ext,
MYBITMAP my_bmp,
RGB pal 
)

Initializes scanline loader of the MYBITMAP object from a data source.

This function initializes scanline loader of the MYBITMAP object from a data source.

Parameters
areaThe data source.
extThe extension of the type of this bitmap.
my_bmpThe pointer to the MYBITMAP object.
palThe palette will be returned.
Returns
The initialized information which should be passed to LoadMyBitmapSL function, and NULL on error.
See also
LoadMyBitmapEx, LoadMyBitmapSL, CleanupMyBitmapSL

◆ InitSlaveScreen()

HDC GUIAPI InitSlaveScreen ( const char *  name,
const char *  mode 
)
inlinestatic

Initializes slave screen.

Parameters
nameThe gal engine name.
modeThe display mode. For example : 640x480-16bpp.
Returns
Valid handle on success, HDC_INVALID on failure.

Definition at line 11703 of file gdi.h.

References InitSlaveScreenEx().

◆ InitSlaveScreenEx()

HDC GUIAPI InitSlaveScreenEx ( const char *  name,
const char *  mode,
int  dpi 
)

Initializes slave screen.

Parameters
nameThe gal engine name.
modeThe display mode. For example : 640x480-16bpp.
dpiThe resolution of screen, should be a value larger than GDCAP_DPI_MINIMAL (36).
Returns
Valid handle on success, HDC_INVALID on failure.

Referenced by InitSlaveScreen().

◆ LoadBitmapEx()

int GUIAPI LoadBitmapEx ( HDC  hdc,
PBITMAP  pBitmap,
MG_RWops area,
const char *  ext 
)
inlinestatic

Load a device-dependent bitmap from a general data source.

This function loads a device-dependent bitmap from the data source area.

Parameters
hdcThe device context.
pBitmapThe pointer to the BITMAP object.
areaThe data source.
extThe extension of the type of this bitmap.
Returns
0 on success, less than 0 on error.
Return values
ERR_BMP_OKLoading successfully
ERR_BMP_IMAGE_TYPENot a valid bitmap.
ERR_BMP_UNKNOWN_TYPENot recongnized bitmap type.
ERR_BMP_CANT_READRead error.
ERR_BMP_CANT_SAVESave error.
ERR_BMP_NOT_SUPPORTEDNot supported bitmap type.
ERR_BMP_MEMMemory allocation error.
ERR_BMP_LOADLoading error.
ERR_BMP_FILEIOI/O failed.
ERR_BMP_OTHEROther error.
ERR_BMP_ERROR_SOURCEA error data source.
See also
LoadBitmapFromFile, LoadBitmapFromMem

Definition at line 11386 of file gdi.h.

References LoadBitmapEx2(), and NULL.

◆ LoadBitmapEx2()

int GUIAPI LoadBitmapEx2 ( HDC  hdc,
PBITMAP  pBitmap,
MG_RWops area,
const char *  ext,
CB_ALLOC_BITMAP_BUFF  cb_alloc_buff,
void *  context 
)

Load a device-dependent bitmap from a general data source.

This function loads a device-dependent bitmap from the data source area. This function gives a chance to the caller to allocate the pixel buffer of the BITMAP object in a different way.

Parameters
hdcThe device context.
pBitmapThe pointer to the BITMAP object.
areaThe data source.
extThe extension of the type of this bitmap.
cb_alloc_buffThe callback to allocate the buffer for the pixels. If it is NULL, the function will allocate the buffer by calling malloc.
contextThe context will be passed to the cb_alloc_buff.
Returns
0 on success, less than 0 on error.
Return values
ERR_BMP_OKLoading successfully
ERR_BMP_IMAGE_TYPENot a valid bitmap.
ERR_BMP_UNKNOWN_TYPENot recongnized bitmap type.
ERR_BMP_CANT_READRead error.
ERR_BMP_CANT_SAVESave error.
ERR_BMP_NOT_SUPPORTEDNot supported bitmap type.
ERR_BMP_MEMMemory allocation error.
ERR_BMP_LOADLoading error.
ERR_BMP_FILEIOI/O failed.
ERR_BMP_OTHEROther error.
ERR_BMP_ERROR_SOURCEA error data source.
See also
LoadBitmapFromFile, LoadBitmapFromMem, CB_ALLOC_BITMAP_BUFF

Referenced by LoadBitmapEx().

◆ LoadBitmapFromFile()

int GUIAPI LoadBitmapFromFile ( HDC  hdc,
PBITMAP  pBitmap,
const char *  spFileName 
)

Load a device-dependent bitmap from a file.

See also
LoadBitmapEx

◆ LoadBitmapFromMem()

int GUIAPI LoadBitmapFromMem ( HDC  hdc,
PBITMAP  pBitmap,
const void *  mem,
size_t  size,
const char *  ext 
)

Load a device-dependent bitmap from memory.

See also
LoadBitmapEx

◆ LoadMyBitmapEx()

int GUIAPI LoadMyBitmapEx ( PMYBITMAP  my_bmp,
RGB pal,
MG_RWops area,
const char *  ext 
)

Load a MYBITMAP object from a data source.

This function loads a MYBITMAP object from the data source area.

Parameters
my_bmpThe pointer to the MYBITMAP object.
areaThe data source.
palThe palette will be returned.
extThe extension of the type of this bitmap.
Returns
0 on success, less than 0 on error.
See also
LoadBitmapEx

◆ LoadMyBitmapFromFile()

int GUIAPI LoadMyBitmapFromFile ( PMYBITMAP  my_bmp,
RGB pal,
const char *  file_name 
)

Load a MYBITMAP object from a file.

See also
LoadMyBitmapEx

◆ LoadMyBitmapFromMem()

int GUIAPI LoadMyBitmapFromMem ( PMYBITMAP  my_bmp,
RGB pal,
const void *  mem,
size_t  size,
const char *  ext 
)

Load a MYBITMAP object from memory.

This function loads a MYBITMAP object from memory.

Parameters
my_bmpThe pointer to the MYBITMAP object.
palThe palette will be retruned through this pointer.
memThe pointer to the memory area.
sizeThe size of the memory area.
extThe extension name used to determine the type of the bitmap.
See also
LoadMyBitmapEx, MYBITMAP

◆ LoadMyBitmapSL()

int GUIAPI LoadMyBitmapSL ( MG_RWops area,
void *  load_info,
MYBITMAP my_bmp,
CB_ONE_SCANLINE  cb,
void *  context 
)

Load MYBITMAP scanlines from a data source one by one.

This function loads MYBITMAP scanlines from the data source area one by one.

Parameters
areaThe data source.
load_infoThe initialized information retured by InitMyBitmapSL function.
my_bmpThe pointer to the MYBITMAP object.
cbThe callback to inform one scanline loaded. It can be NULL.
contextThe context information passed to the callback.
Returns
0 on success, less than 0 on error.
See also
LoadMyBitmapEx, InitMyBitmapSL, CleanupMyBitmapSL

◆ mlsEnableSlaveScreen()

BOOL GUIAPI mlsEnableSlaveScreen ( HDC  dc_mls,
BOOL  enable 
)

Enable or Disable a MLShadow slave screen.

This function is used to enable or diable a MLShadow slave screen. After creating a slave screen by InitSlaveScreen successfully, its default status is disabled.

Parameters
dc_mlsThe handle of MLShadow slave screen.
enableWhether to enable the MLShadow slave screen.
Returns
TRUE on success, FALSE on error.

◆ PaintImageEx()

int GUIAPI PaintImageEx ( HDC  hdc,
int  x,
int  y,
MG_RWops area,
const char *  ext 
)

Paints an image from data source on device directly.

This function paints an image from data source onto device directly.

Parameters
hdcThe device context.
x(x,y), the paint position on device.
y(x,y), the paint position on device.
areaThe data source.
extThe extension of the type of this bitmap.
Returns
0 on success, less than 0 on error.
Return values
ERR_BMP_OKPainted successfully
ERR_BMP_IMAGE_TYPENot a valid image type.
ERR_BMP_UNKNOWN_TYPENot recongnized bitmap type.
ERR_BMP_CANT_READRead error.
ERR_BMP_NOT_SUPPORTEDNot supported bitmap type.
ERR_BMP_MEMMemory allocation error.
ERR_BMP_LOADLoading error.
ERR_BMP_FILEIOI/O failed.
ERR_BMP_OTHEROther error.
ERR_BMP_ERROR_SOURCEA error data source.
See also
PaintImageFromFile, PaintImageFromMem

◆ PaintImageFromFile()

int GUIAPI PaintImageFromFile ( HDC  hdc,
int  x,
int  y,
const char *  spFileName 
)

Paints an image from file on device directly.

Parameters
hdcThe device context.
x(x,y), the paint position on device.
y(x,y), the paint position on device.
spFileNameThe file name of the image file.
Returns
0 on success, less than 0 on error.
See also
PaintImageEx

◆ PaintImageFromMem()

int GUIAPI PaintImageFromMem ( HDC  hdc,
int  x,
int  y,
const void *  mem,
size_t  size,
const char *  ext 
)

Paints an image from memory on device directly.

Parameters
hdcThe device context.
x(x,y), the paint position on device.
y(x,y), the paint position on device.
memThe pointer to memory containing image data.
sizeThe size of the image data.
extThe name of the image which indicates the type of the image.
Returns
0 on success, less than 0 on error.
See also
PaintImageEx

◆ PivotBitmap()

void GUIAPI PivotBitmap ( HDC  hdc,
const BITMAP bmp,
int  x,
int  y,
int  cx,
int  cy,
int  angle 
)

Pivot a bitmap object.

This function aligns the point in the bitmap given by (cx, cy) to (x, y) in device context, then rotates around this point.

See also
PivotScaledBitmapFlip

◆ PivotScaledBitmapFlip()

void GUIAPI PivotScaledBitmapFlip ( HDC  hdc,
const BITMAP bmp,
fixed  x,
fixed  y,
fixed  cx,
fixed  cy,
int  angle,
fixed  scale_x,
fixed  scale_y,
BOOL  h_flip,
BOOL  v_flip 
)

Rotates, stretches or shrinks, flips a bitmap object.

This function flips the bitmap vertically if v_flip is TRUE, flips the bitmap horizontally if h_flip is TRUE first. Then stretches or shrinks the bitmap according to scale and aligns the point in the bitmap given by (cx, cy) to (x, y) in device context, Finally rotates specified angle pointed to angle in 1/64ths of a degree around this point (cx, cy).

Parameters
hdcThe device context.
bmpThe pointer of BITMAP object.
x(x,y) The x coordinate of a point in fixed point on dc.
y(x,y) The y coordinate of a point in fixed point on dc.
cx(cx,cy) The x coordinate of a point in fixed point on the bitmap.
cy(cx,cy) The y coordinate of a point in fixed point on the bitmap.
angleThe specified rotated angle around its center.
scale_xThe ratio of width of stretching or shrinking the bitmap in fixed point.
scale_yThe ratio of height of stretching or shrinking the bitmap in fixed point.
h_flipThe flags of fliping horizontally.
v_flipThe flags of fliping vertically.

◆ ReplaceBitmapColor()

void GUIAPI ReplaceBitmapColor ( HDC  hdc,
PBITMAP  pBitmap,
gal_pixel  iOColor,
gal_pixel  iNColor 
)

Replaces a specific pixels in a bitmap with another pixel.

This function replaces the specific pixels with value iOColor with the other pixel value iNcolor in the bitmap pBitmap.

Parameters
hdcThe device context.
pBitmapThe BITMAP object.
iOColorThe pixel value of the color will be replaced.
iNColorThe pixel value of the new color.

◆ RotateBitmap()

void GUIAPI RotateBitmap ( HDC  hdc,
const BITMAP bmp,
int  lx,
int  ty,
int  angle 
)

Rotate a bitmap object.

Parameters
hdcThe device context.
bmpThe pointer of Bitmap object.
lx(lx,ty), the x coordinate of top left corner.
ty(lx,ty), the y coordinate of top left corner.
angleThe specified rotated angle around its center. It must be in 1/64ths of a degree.
See also
PivotScaledBitmapFlip

◆ RotateBitmapHFlip()

void GUIAPI RotateBitmapHFlip ( HDC  hdc,
const BITMAP bmp,
int  lx,
int  ty,
int  angle 
)

Flips horizontally and rotates a bitmap object.

See also
RotateBitmap

◆ RotateBitmapVFlip()

void GUIAPI RotateBitmapVFlip ( HDC  hdc,
const BITMAP bmp,
int  lx,
int  ty,
int  angle 
)

Flips vertically and rotates a bitmap object.

This function flips vertically before rotating the bitmap pointed to bmp.

See also
RotateBitmap

◆ RotateScaledBitmap()

void GUIAPI RotateScaledBitmap ( HDC  hdc,
const BITMAP bmp,
int  lx,
int  ty,
int  angle,
int  w,
int  h 
)

Stretches or shrinks a bitmap object at the same as rotating it.

See also
RotateBitmap

◆ RotateScaledBitmapHFlip()

void GUIAPI RotateScaledBitmapHFlip ( HDC  hdc,
const BITMAP bmp,
int  lx,
int  ty,
int  angle,
int  w,
int  h 
)

Flip horizontaly, rotates, stretch or shrinks a bitmap object.

This function is similar to RotateScaledBitmap() expect that it flips the bitmap horizontally first.

See also
RotateScaledBitmap()

◆ RotateScaledBitmapVFlip()

void GUIAPI RotateScaledBitmapVFlip ( HDC  hdc,
const BITMAP bmp,
int  lx,
int  ty,
int  angle,
int  w,
int  h 
)

Flip vertically, rotates, stretch or shrinks a bitmap object.

This function is similar to RotateScaledBitmap() expect that it flips the bitmap vertically first.

See also
RotateScaledBitmap()

◆ SaveBitmapToFile()

int GUIAPI SaveBitmapToFile ( HDC  hdc,
PBITMAP  pBitmap,
const char *  spFileName 
)

Saves a BITMAP object to a bitmap file.

This function saves the BITMAP object pBitmap to the bitmap file named spFileName.

Parameters
hdcThe device context.
pBitmapThe BITMAP object.
spFileNameThe file name.
Returns
0 on success, less than 0 on error.
See also
SaveMyBitmapToFile

◆ SaveMyBitmapToFile()

int GUIAPI SaveMyBitmapToFile ( PMYBITMAP  my_bmp,
RGB pal,
const char *  spFileName 
)

Saves a MYBITMAP object to a bitmap file.

This function saves the MYBITMAP object my_bmp to the bitmap file named spFileName.

Parameters
my_bmpThe MYBITMAP object.
palThe palette.
spFileNameThe file name.
Returns
0 on success, less than 0 on error.
See also
SaveBitmapToFile

◆ SetBitmapKeyColor()

int GUIAPI SetBitmapKeyColor ( HDC  hdc,
PBITMAP  bmp,
Uint8  r,
Uint8  g,
Uint8  b 
)

Set the bitmap color key.

This function set the bitmap member bmColorKey with the param r,g,b and set the BMP_TYPE_COLORKEY flag.

Parameters
hdcThe device context.
bmpPoint of the bitmap which to set color key.
rThe red componets of RGB color.
gThe green componets of RGB color.
bThe blue componets of RGB color.
Returns
ERR_BMP_OK for success, ERR_BMP_UNKNOWN_TYPE for error.

/sa SetMemDCColorKey

◆ StretchPaintImageEx()

int GUIAPI StretchPaintImageEx ( HDC  hdc,
int  x,
int  y,
int  w,
int  h,
MG_RWops area,
const char *  ext 
)

Paints an image from data source on device directly.

This function paints an image from data source onto device directly with stretch.

Parameters
hdcThe device context.
x(x,y), the paint position on device.
y(x,y), the paint position on device.
wthe width of the stretched bitmap.
hthe height of the stretched bitmap.
areaThe data source.
extThe extension of the type of this bitmap.
Returns
0 on success, less than 0 on error.
Return values
ERR_BMP_OKPainted successfully
ERR_BMP_IMAGE_TYPENot a valid image type.
ERR_BMP_UNKNOWN_TYPENot recongnized bitmap type.
ERR_BMP_CANT_READRead error.
ERR_BMP_NOT_SUPPORTEDNot supported bitmap type.
ERR_BMP_MEMMemory allocation error.
ERR_BMP_LOADLoading error.
ERR_BMP_FILEIOI/O failed.
ERR_BMP_OTHEROther error.
ERR_BMP_ERROR_SOURCEA error data source.
See also
PaintImageFromFile, PaintImageFromMem

◆ StretchPaintImageFromFile()

int GUIAPI StretchPaintImageFromFile ( HDC  hdc,
int  x,
int  y,
int  w,
int  h,
const char *  spFileName 
)

Paints an image from file on device directly.

Parameters
hdcThe device context.
x(x,y), the paint position on device.
y(x,y), the paint position on device.
wThe width of the stretched bitmap.
hThe height of the stretched bitmap.
spFileNamethe file name of the image file.
Returns
0 on success, less than 0 on error.
See also
StretchPaintImageEx

◆ StretchPaintImageFromMem()

int GUIAPI StretchPaintImageFromMem ( HDC  hdc,
int  x,
int  y,
int  w,
int  h,
const void *  mem,
size_t  size,
const char *  ext 
)

Paints an image from memory on device directly.

Parameters
hdcThe device context.
x(x,y) the paint position on device.
y(x,y) the paint position on device.
wThe width of the stretched bitmap.
hThe height of the stretched bitmap.
memThe pointer to memory containing image data.
sizeThe size of the image data.
extThe name of the image which indicates the type of the image.
Returns
0 on success, less than 0 on error.
See also
StretchPaintImageEx

◆ TerminateSlaveScreen()

void TerminateSlaveScreen ( HDC  hdc)

Terminates slave screen.

Parameters
hdcThe slave device context.

◆ UnloadBitmap()

void GUIAPI UnloadBitmap ( PBITMAP  pBitmap)

Unloads a bitmap.

This function unloads the specified bitmap pBitmap. It will free the private pixel format and the bits of the bitmap.

Parameters
pBitmapThe BITMAP object.
See also
LoadBitmapEx

◆ UnloadMyBitmap()

void GUIAPI UnloadMyBitmap ( PMYBITMAP  my_bmp)

Unloads a bitmap.

This function unloads the specified MYBITMAP object my_bmp. It will free the bits of the bitmap.

Parameters
my_bmpThe pointer to the MYBITMAP object.
See also
LoadMyBitmapEx

◆ VFlipBitmap()

void GUIAPI VFlipBitmap ( BITMAP bmp,
unsigned char *  inter_buff 
)

Vertical Flip the special Bitmap object.

Parameters
bmpThe BITMAP object.
inter_buffThe one scan line pre-alloc buffer of bitmap.
FillBoxWithBitmap
MG_EXPORT BOOL GUIAPI FillBoxWithBitmap(HDC hdc, int x, int y, int w, int h, const BITMAP *bmp)
Fills a box with a BITMAP object.
GetPixelInBitmap
static gal_pixel GUIAPI GetPixelInBitmap(const BITMAP *bmp, int x, int y)
Returns the pixel value in a BITMAP object.
Definition: gdi.h:5567
GetTickCount
MG_EXPORT DWORD GUIAPI GetTickCount(void)
Retrieve the tick counts that have elapsed since MiniGUI was started.
LoadBitmap
#define LoadBitmap
An alias of LoadBitmapFromFile.
Definition: gdi.h:11407
_BITMAP::bmType
Uint8 bmType
Definition: gdi.h:11122
_BITMAP::bmColorKey
Uint32 bmColorKey
Definition: gdi.h:11130
_BITMAP::bmAlpha
Uint8 bmAlpha
Definition: gdi.h:11128
_BITMAP
Definition: gdi.h:11088
UnloadBitmap
MG_EXPORT void GUIAPI UnloadBitmap(PBITMAP pBitmap)
Unloads a bitmap.