Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

Bitmap file load/save operations
[GDI functions]

Defines

Typedefs

Functions


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);
}

Define Documentation

#define LoadBitmap   LoadBitmapFromFile
 

An alias of LoadBitmapFromFile.

See also:
LoadBitmapFromFile

Definition at line 6951 of file gdi.h.

#define LoadMyBitmap   LoadMyBitmapFromFile
 

Alias of LoadMyBitmapFromFile.

See also:
LoadMyBitmapFromFile

Definition at line 7089 of file gdi.h.


Typedef Documentation

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

The type of scanline loaded callback.

Definition at line 6833 of file gdi.h.


Function Documentation

const char *GUIAPI CheckBitmapType MG_RWops fp  ) 
 

Checks 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:
fp The pointer to the data source.
Returns:
The extension of the type of bitmap file. NULL for not recongnized bitmap type.
See also:
RegisterBitmapFileType

int GUIAPI CleanupMyBitmapSL MYBITMAP my_bmp,
void *  load_info
 

Cleanups the scanline loader.

This function cleanups the scanline loader.

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

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

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:
hdc The device context.
bmp The expanded BITMAP object.
my_bmp The MYBITMAP object to be expanded.
pal The palette of the MYBITMAP object.
frame The frame of the MYBITMAP object.
Returns:
0 on success, non-zero on error.

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:
hdc The device context.
w The width of the bitmap.
h The height of the bitmap.
pitch The pitch of the bitmap.
bits The bits of the bitmap.
bmp The 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

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:
hdc The device context.
bmp The BITMAP object to be initialized.
Returns:
TRUE on success, FALSE on error.
See also:
InitBitmap, Bitmap structure

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:
area The data source.
ext The extension of the type of this bitmap.
my_bmp The pointer to the MYBITMAP object.
pal The palette will be returned.
Returns:
The initialized information which should be passed to LoadMyBitmapSL function, and NULL on error.
See also:
LoadMyBitmapEx, LoadMyBitmapSL, CleanupMyBitmapSL

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

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

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

Parameters:
hdc The device context.
pBitmap The pointer to the BITMAP object.
area The data source.
ext The extension of the type of this bitmap.
Returns:
0 on success, less than 0 on error.
Return values:
ERR_BMP_OK Loading successfully
ERR_BMP_IMAGE_TYPE Not a valid bitmap.
ERR_BMP_UNKNOWN_TYPE Not recongnized bitmap type.
ERR_BMP_CANT_READ Read error.
ERR_BMP_CANT_SAVE Save error.
ERR_BMP_NOT_SUPPORTED Not supported bitmap type.
ERR_BMP_MEM Memory allocation error.
ERR_BMP_LOAD Loading error.
ERR_BMP_FILEIO I/O failed.
ERR_BMP_OTHER Other error.
ERR_BMP_ERROR_SOURCE A error data source.
See also:
LoadBitmapFromFile, LoadBitmapFromMem

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

Loads a device-dependent bitmap from a file.

See also:
LoadBitmapEx

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

Loads a device-dependent bitmap from memory.

See also:
LoadBitmapEx

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

Loads a MYBITMAP object from a data source.

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

Parameters:
my_bmp The pointer to the MYBITMAP object.
area The data source.
pal The palette will be returned.
ext The extension of the type of this bitmap.
Returns:
0 on success, less than 0 on error.
See also:
LoadBitmapEx

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

Loads a MYBITMAP object from a file.

See also:
LoadMyBitmapEx

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

Loads a MYBITMAP object from memory.

This function loads a MYBITMAP object from memory.

Parameters:
my_bmp The pointer to the MYBITMAP object.
pal The palette will be retruned through this pointer.
mem The pointer to the memory area.
size The size of the memory area.
ext The extension name used to determine the type of the bitmap.
See also:
LoadMyBitmapEx, MYBITMAP

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

Loads MYBITMAP scanlines from a data source one by one.

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

Parameters:
area The data source.
load_info The initialized information retured by InitMyBitmapSL function.
my_bmp The pointer to the MYBITMAP object.
cb The callback to inform one scanline loaded. It can be NULL.
context The context information passed to the callback.
Returns:
0 on success, less than 0 on error.
See also:
LoadMyBitmapEx, InitMyBitmapSL, CleanupMyBitmapSL

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:
hdc The device context.
x (x,y), the paint position on device.
y (x,y), the paint position on device.
area The data source.
ext The extension of the type of this bitmap.
Returns:
0 on success, less than 0 on error.
Return values:
ERR_BMP_OK Painted successfully
ERR_BMP_IMAGE_TYPE Not a valid image type.
ERR_BMP_UNKNOWN_TYPE Not recongnized bitmap type.
ERR_BMP_CANT_READ Read error.
ERR_BMP_NOT_SUPPORTED Not supported bitmap type.
ERR_BMP_MEM Memory allocation error.
ERR_BMP_LOAD Loading error.
ERR_BMP_FILEIO I/O failed.
ERR_BMP_OTHER Other error.
ERR_BMP_ERROR_SOURCE A error data source.
See also:
PaintImageFromFile, PaintImageFromMem

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

Paints an image from file on device directly.

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

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

Paints an image from memory on device directly.

Parameters:
hdc The device context.
x (x,y), the paint position on device.
y (x,y), the paint position on device.
mem The pointer to memory containing image data.
size The size of the image data.
ext The name of the image which indicates the type of the image.
Returns:
0 on success, less than 0 on error.
See also:
PaintImageEx

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

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:
hdc The device context.
bmp The 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.
angle The specified rotated angle around its center.
scale_x The ratio of width of stretching or shrinking the bitmap in fixed point.
scale_y The ratio of height of stretching or shrinking the bitmap in fixed point.
h_flip The flags of fliping horizontally.
v_flip The flags of fliping vertically.

BOOL GUIAPI RegisterBitmapFileType const char *  ext,
void *(*)(MG_RWops *fp, MYBITMAP *my_bmp, RGB *pal)  init,
int(*)(MG_RWops *fp, void *init_info, MYBITMAP *my_bmp, CB_ONE_SCANLINE cb, void *context)  load,
void(*)(void *init_info)  cleanup,
int(*)(MG_RWops *fp, MYBITMAP *my_bmp, RGB *pal)  save,
BOOL(*)(MG_RWops *fp)  check
 

Registers a bitmap file loader, saver, and checker.

This function registers a new bitmap file loader, saver, and checker. You should pass the extension of the bitmap files, the functions to init, load, and cleanup this type of bitmap file, the function to save, and the function to check the type.

Parameters:
ext The extension name of the type of bitmap file, like "jpg" or "gif".
init The routine to init the MYBITMAP object (bmp). This routine fills the MYBITMAP structure and get the pallete if needed. It will return the init_info for the following load routine.
load The routine to load the scanlines of the bitmap file. This routine will load the initialized MYBITMAP object (bmp) from the data source (fp). It will call the scanline loaded callback (cb) by passing through the context (context), the MYBITMAP object (bmp), and the index of the scanline.
cleanup The cleanup routine.
save The saver of the bitmap file, can be NULL.
check The checker of the bitmap file.
Returns:
TRUE on success, FALSE on error.
See also:
CheckBitmapType, InitMyBitmapSL, LoadMyBitmapSL, CleanupMyBitmapSL, General read/write operations

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:
hdc The device context.
pBitmap The BITMAP object.
iOColor The pixel value of the color will be replaced.
iNColor The pixel value of the new color.

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

Rotate a bitmap object.

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

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

Flips horizontally and rotates a bitmap object.

See also:
RotateBitmap

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

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

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()

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()

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:
hdc The device context.
pBitmap The BITMAP object.
spFileName The file name.
Returns:
0 on success, less than 0 on error.
See also:
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_bmp The MYBITMAP object.
pal The palette.
spFileName The file name.
Returns:
0 on success, less than 0 on error.
See also:
SaveBitmapToFile

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:
hdc The device context.
x (x,y), the paint position on device.
y (x,y), the paint position on device.
w the width of the stretched bitmap.
h the height of the stretched bitmap.
area The data source.
ext The extension of the type of this bitmap.
Returns:
0 on success, less than 0 on error.
Return values:
ERR_BMP_OK Painted successfully
ERR_BMP_IMAGE_TYPE Not a valid image type.
ERR_BMP_UNKNOWN_TYPE Not recongnized bitmap type.
ERR_BMP_CANT_READ Read error.
ERR_BMP_NOT_SUPPORTED Not supported bitmap type.
ERR_BMP_MEM Memory allocation error.
ERR_BMP_LOAD Loading error.
ERR_BMP_FILEIO I/O failed.
ERR_BMP_OTHER Other error.
ERR_BMP_ERROR_SOURCE A error data source.
See also:
PaintImageFromFile, PaintImageFromMem

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:
hdc The device context.
x (x,y), the paint position on device.
y (x,y), the paint position on device.
w The width of the stretched bitmap.
h The height of the stretched bitmap.
spFileName the file name of the image file.
Returns:
0 on success, less than 0 on error.
See also:
StretchPaintImageEx

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

Paints an image from memory on device directly.

Parameters:
hdc The device context.
x (x,y) the paint position on device.
y (x,y) the paint position on device.
w The width of the stretched bitmap.
h The height of the stretched bitmap.
mem The pointer to memory containing image data.
size The size of the image data.
ext The name of the image which indicates the type of the image.
Returns:
0 on success, less than 0 on error.
See also:
StretchPaintImageEx

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:
pBitmap The BITMAP object.
See also:
LoadBitmapEx

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_bmp The pointer to the MYBITMAP object.
See also:
LoadMyBitmapEx


Generated on Mon Jun 26 13:54:31 2006 for MiniGUI V1.6.9 API Reference by  doxygen 1.4.2