Isle
Loading...
Searching...
No Matches
MxBitmap Class Reference

[AI] Represents an 8bpp or high color device-independent bitmap (DIB) and provides operations for bitmap loading, manipulation, and palette management. More...

#include <mxbitmap.h>

Inheritance diagram for MxBitmap:
Collaboration diagram for MxBitmap:

Public Member Functions

 MxBitmap ()
 [AI] Constructs an empty MxBitmap instance, initializing all data pointers to NULL. More...
 
 ~MxBitmap () override
 [AI] Frees allocated memory for bitmap info, pixel data, and palette. More...
 
virtual MxResult ImportBitmap (MxBitmap *p_bitmap)
 [AI] Imports the contents of another bitmap into this bitmap, allocating new storage and copying metadata and pixel data. More...
 
virtual MxResult ImportBitmapInfo (MxBITMAPINFO *p_info)
 [AI] Imports bitmap header/palette info (but not pixel data) from the given info block. More...
 
virtual MxResult SetSize (MxS32 p_width, MxS32 p_height, MxPalette *p_palette, MxBool)
 [AI] Allocates the bitmap to a specified width and height, attaches a palette, and configures bit depth. More...
 
virtual MxResult LoadFile (HANDLE p_handle)
 [AI] Loads a bitmap from a file handle, populating header, palette data and pixel data. More...
 
virtual MxLong Read (const char *p_filename)
 [AI] Loads a bitmap from a file given its filename. More...
 
virtual MxS32 VTable0x28 (MxS32)
 [AI] Placeholder or unused virtual; always returns -1. More...
 
virtual void BitBlt (MxBitmap *p_src, MxS32 p_left, MxS32 p_top, MxS32 p_right, MxS32 p_bottom, MxS32 p_width, MxS32 p_height)
 [AI] Copies a rectangular area from a source bitmap into this bitmap (BitBlt). More...
 
virtual void BitBltTransparent (MxBitmap *p_src, MxS32 p_left, MxS32 p_top, MxS32 p_right, MxS32 p_bottom, MxS32 p_width, MxS32 p_height)
 [AI] Copies a rectangular region from a source bitmap to this bitmap, but skips "transparent" (index 0) pixels. More...
 
virtual MxPaletteCreatePalette ()
 [AI] Allocates or clones the current palette for the bitmap. More...
 
virtual void ImportPalette (MxPalette *p_palette)
 [AI] Attaches or clones a palette for the bitmap and updates color data as needed. More...
 
virtual MxResult SetBitDepth (MxBool)
 [AI] Changes the bit depth mode for the bitmap (palettized or high color). More...
 
virtual MxResult StretchBits (HDC p_hdc, MxS32 p_xSrc, MxS32 p_ySrc, MxS32 p_xDest, MxS32 p_yDest, MxS32 p_destWidth, MxS32 p_destHeight)
 [AI] Draws (blits) a scaled region of the bitmap to a Windows device context. More...
 
MxLong AlignToFourByte (MxLong p_value) const
 [AI] Aligns a value up to the nearest multiple of four (stride alignment for DIBs). More...
 
BITMAPINFOHEADER * GetBmiHeader () const
 [AI] Returns a pointer to the underlying BITMAPINFOHEADER. More...
 
MxLong GetBmiWidth () const
 [AI] Fetches the width (in pixels) encoded in this bitmap's header. More...
 
MxLong GetBmiStride () const
 [AI] Computes the stride (bytes per scanline, aligned to 4 bytes). More...
 
MxLong GetBmiHeight () const
 [AI] Fetches the height (could be negative if top-down) of the bitmap. More...
 
MxLong GetBmiHeightAbs () const
 [AI] Returns the absolute value of the bitmap's height. More...
 
MxU8GetImage () const
 [AI] Retrieves the pointer to the image pixel data. More...
 
MxBITMAPINFOGetBitmapInfo () const
 [AI] Retrieves the pointer to the underlying MxBITMAPINFO struct (header and palette). More...
 
MxLong GetDataSize () const
 [AI] Computes the total size in bytes for the bitmap's pixel data buffer. More...
 
MxBool IsTopDown () const
 [AI] Checks if the bitmap is stored in top-down scanline order. More...
 
MxU8GetStart (MxS32 p_left, MxS32 p_top) const
 [AI] Returns a pointer to the starting address of the pixel data at the specified coordinates. More...
 
- Public Member Functions inherited from MxCore
 MxCore ()
 [AI] Constructs a new MxCore object and assigns it a unique id. More...
 
virtual ~MxCore ()
 [AI] Virtual destructor. Required for correct polymorphic cleanup in derived classes. More...
 
virtual MxLong Notify (MxParam &p_param)
 [AI] Virtual callback notification mechanism. More...
 
virtual MxResult Tickle ()
 [AI] Called by tickle managers to allow the object to update itself. More...
 
virtual const char * ClassName () const
 [AI] Returns the runtime class name of this object. More...
 
virtual MxBool IsA (const char *p_name) const
 [AI] Checks whether this object's class type or parents match the given name. More...
 
MxU32 GetId ()
 [AI] Gets the unique (per-process) id assigned to this object instance. More...
 

Static Public Member Functions

static MxLong HeightAbs (MxLong p_value)
 [AI] Returns the absolute value of the input height (for DIBs). More...
 

Detailed Description

[AI] Represents an 8bpp or high color device-independent bitmap (DIB) and provides operations for bitmap loading, manipulation, and palette management.

[AI] This class manages both the metadata (header and palette) and raw pixel data for a bitmap, supporting direct blitting, transparency, and palette operations for the LEGO Island engine.

The bitmap can be managed in either palettized or "high color" (truecolor) modes. It is primarily used for image resource management and 2D rendering, such as GUI assets or video frames.

Definition at line 55 of file mxbitmap.h.

Constructor & Destructor Documentation

◆ MxBitmap()

MxBitmap::MxBitmap ( )

[AI] Constructs an empty MxBitmap instance, initializing all data pointers to NULL.

Definition at line 16 of file mxbitmap.cpp.

◆ ~MxBitmap()

MxBitmap::~MxBitmap ( )
override

[AI] Frees allocated memory for bitmap info, pixel data, and palette.

Definition at line 28 of file mxbitmap.cpp.

Member Function Documentation

◆ AlignToFourByte()

MxLong MxBitmap::AlignToFourByte ( MxLong  p_value) const
inline

[AI] Aligns a value up to the nearest multiple of four (stride alignment for DIBs).

Parameters
p_value[AI] The input value to align (pixels/bytes).
Returns
[AI] The aligned value (next multiple of 4, at minimum p_value).

[AI] Used for scanline stride calculations in Win32 DIB format.

Definition at line 204 of file mxbitmap.h.

◆ BitBlt()

void MxBitmap::BitBlt ( MxBitmap p_src,
MxS32  p_left,
MxS32  p_top,
MxS32  p_right,
MxS32  p_bottom,
MxS32  p_width,
MxS32  p_height 
)
virtual

[AI] Copies a rectangular area from a source bitmap into this bitmap (BitBlt).

Parameters
p_src[AI] Source bitmap.
p_left[AI] Source left pixel X position.
p_top[AI] Source top pixel Y position.
p_right[AI] Destination left pixel X position.
p_bottom[AI] Destination top pixel Y position.
p_width[AI] Width of rectangle to copy.
p_height[AI] Height of rectangle to copy.

[AI] Performs a memory copy for each scanline, including proper stride handling and clipping.

Definition at line 267 of file mxbitmap.cpp.

◆ BitBltTransparent()

void MxBitmap::BitBltTransparent ( MxBitmap p_src,
MxS32  p_left,
MxS32  p_top,
MxS32  p_right,
MxS32  p_bottom,
MxS32  p_width,
MxS32  p_height 
)
virtual

[AI] Copies a rectangular region from a source bitmap to this bitmap, but skips "transparent" (index 0) pixels.

Parameters
p_src[AI] Source bitmap.
p_left[AI] Source left pixel X position.
p_top[AI] Source top pixel Y position.
p_right[AI] Destination left pixel X position.
p_bottom[AI] Destination top pixel Y position.
p_width[AI] Width of rectangle to copy.
p_height[AI] Height of rectangle to copy.

[AI] Used for drawing sprites/images with transparency by ignoring palette index 0.

Definition at line 306 of file mxbitmap.cpp.

◆ CreatePalette()

MxPalette * MxBitmap::CreatePalette ( )
virtual

[AI] Allocates or clones the current palette for the bitmap.

Returns
[AI] Newly allocated or cloned MxPalette instance (if success), NULL if allocation failed.

[AI] Returns a palette copy depending on current color depth mode.

Definition at line 352 of file mxbitmap.cpp.

◆ GetBitmapInfo()

MxBITMAPINFO * MxBitmap::GetBitmapInfo ( ) const
inline

[AI] Retrieves the pointer to the underlying MxBITMAPINFO struct (header and palette).

Returns
[AI] Pointer to bitmap info struct.

Definition at line 254 of file mxbitmap.h.

◆ GetBmiHeader()

BITMAPINFOHEADER * MxBitmap::GetBmiHeader ( ) const
inline

[AI] Returns a pointer to the underlying BITMAPINFOHEADER.

Returns
[AI] Pointer to BITMAPINFOHEADER struct.

Definition at line 218 of file mxbitmap.h.

◆ GetBmiHeight()

MxLong MxBitmap::GetBmiHeight ( ) const
inline

[AI] Fetches the height (could be negative if top-down) of the bitmap.

Returns
[AI] DIB height as encoded (could be negative for top-down).

Definition at line 236 of file mxbitmap.h.

◆ GetBmiHeightAbs()

MxLong MxBitmap::GetBmiHeightAbs ( ) const
inline

[AI] Returns the absolute value of the bitmap's height.

Returns
[AI] Height in pixels (always positive).

Definition at line 242 of file mxbitmap.h.

◆ GetBmiStride()

MxLong MxBitmap::GetBmiStride ( ) const
inline

[AI] Computes the stride (bytes per scanline, aligned to 4 bytes).

Returns
[AI] Number of bytes per scanline with stride padding.

Definition at line 230 of file mxbitmap.h.

◆ GetBmiWidth()

MxLong MxBitmap::GetBmiWidth ( ) const
inline

[AI] Fetches the width (in pixels) encoded in this bitmap's header.

Returns
[AI] Bitmap width in pixels.

Definition at line 224 of file mxbitmap.h.

◆ GetDataSize()

MxLong MxBitmap::GetDataSize ( ) const
inline

[AI] Computes the total size in bytes for the bitmap's pixel data buffer.

Returns
[AI] Data size (width aligned to four bytes * abs(height)).

Definition at line 260 of file mxbitmap.h.

◆ GetImage()

MxU8 * MxBitmap::GetImage ( ) const
inline

[AI] Retrieves the pointer to the image pixel data.

Returns
[AI] Pointer to start of pixel array.

Definition at line 248 of file mxbitmap.h.

◆ GetStart()

MxU8 * MxBitmap::GetStart ( MxS32  p_left,
MxS32  p_top 
) const
inline

[AI] Returns a pointer to the starting address of the pixel data at the specified coordinates.

Parameters
p_left[AI] X coordinate (column).
p_top[AI] Y coordinate (row).
Returns
[AI] Pointer to start of requested pixel.

[AI] Takes into account DIB storage format (top-down or bottom-up).

Definition at line 288 of file mxbitmap.h.

◆ HeightAbs()

static MxLong MxBitmap::HeightAbs ( MxLong  p_value)
inlinestatic

[AI] Returns the absolute value of the input height (for DIBs).

Parameters
p_value[AI] The value (may be negative or positive).
Returns
[AI] Always positive height.

[AI] Used for supporting negative heights (top-down flag) in DIBs.

Definition at line 212 of file mxbitmap.h.

◆ ImportBitmap()

MxResult MxBitmap::ImportBitmap ( MxBitmap p_bitmap)
virtual

[AI] Imports the contents of another bitmap into this bitmap, allocating new storage and copying metadata and pixel data.

Parameters
p_bitmap[AI] Source bitmap to copy from.
Returns
[AI] SUCCESS if the operation completed, FAILURE otherwise.

Definition at line 136 of file mxbitmap.cpp.

◆ ImportBitmapInfo()

MxResult MxBitmap::ImportBitmapInfo ( MxBITMAPINFO p_info)
virtual

[AI] Imports bitmap header/palette info (but not pixel data) from the given info block.

Parameters
p_info[AI] Source MxBITMAPINFO structure to import.
Returns
[AI] SUCCESS if the operation completed, FAILURE otherwise.

Definition at line 98 of file mxbitmap.cpp.

◆ ImportPalette()

void MxBitmap::ImportPalette ( MxPalette p_palette)
virtual

[AI] Attaches or clones a palette for the bitmap and updates color data as needed.

Parameters
p_palette[AI] Palette to import (will clone if high color).

[AI] Behavior depends on current color depth mode (palettized or high color).

Definition at line 387 of file mxbitmap.cpp.

◆ IsTopDown()

MxBool MxBitmap::IsTopDown ( ) const
inline

[AI] Checks if the bitmap is stored in top-down scanline order.

Returns
[AI] TRUE if top-down, FALSE otherwise.

[AI] Uses the custom BI_RGB_TOPDOWN or negative height.

Definition at line 267 of file mxbitmap.h.

◆ LoadFile()

MxResult MxBitmap::LoadFile ( HANDLE  p_handle)
virtual

[AI] Loads a bitmap from a file handle, populating header, palette data and pixel data.

Parameters
p_handle[AI] File handle (must be positioned at the start of a valid BMP file).
Returns
[AI] SUCCESS if bitmap loaded, FAILURE otherwise.

Definition at line 202 of file mxbitmap.cpp.

◆ Read()

MxLong MxBitmap::Read ( const char *  p_filename)
virtual

[AI] Loads a bitmap from a file given its filename.

Parameters
p_filename[AI] Path to the bitmap file.
Returns
[AI] 0 on failure or if not found, nonzero on success.

Definition at line 175 of file mxbitmap.cpp.

◆ SetBitDepth()

MxResult MxBitmap::SetBitDepth ( MxBool  p_isHighColor)
virtual

[AI] Changes the bit depth mode for the bitmap (palettized or high color).

Parameters
[AI]TRUE for high color, FALSE for palette mode.
Returns
[AI] SUCCESS if mode switched or same as before, FAILURE on allocation/conversion error.

[AI] May allocate/reallocate a new palette if switching to high color.

Definition at line 404 of file mxbitmap.cpp.

◆ SetSize()

MxResult MxBitmap::SetSize ( MxS32  p_width,
MxS32  p_height,
MxPalette p_palette,
MxBool  p_isHighColor 
)
virtual

[AI] Allocates the bitmap to a specified width and height, attaches a palette, and configures bit depth.

Parameters
p_width[AI] Image width in pixels.
p_height[AI] Image height in pixels.
p_palette[AI] Palette to assign to this bitmap, or NULL for a default.
[AI]p_isHighColor Whether to use high color/truecolor (TRUE) or palettized (FALSE) format.
Returns
[AI] SUCCESS if allocated and initialized correctly, FAILURE otherwise.

Definition at line 43 of file mxbitmap.cpp.

◆ StretchBits()

MxResult MxBitmap::StretchBits ( HDC  p_hdc,
MxS32  p_xSrc,
MxS32  p_ySrc,
MxS32  p_xDest,
MxS32  p_yDest,
MxS32  p_destWidth,
MxS32  p_destHeight 
)
virtual

[AI] Draws (blits) a scaled region of the bitmap to a Windows device context.

Parameters
p_hdc[AI] Target device context handle.
p_xSrc[AI] Source X origin.
p_ySrc[AI] Source Y origin.
p_xDest[AI] Destination X origin.
p_yDest[AI] Destination Y origin.
p_destWidth[AI] Destination width (in pixels).
p_destHeight[AI] Destination height (in pixels).
Returns
[AI] The result code from Windows StretchDIBits.

[AI] Handles flipping for bottom-up DIBs.

Definition at line 454 of file mxbitmap.cpp.

◆ VTable0x28()

virtual MxS32 MxBitmap::VTable0x28 ( MxS32  )
inlinevirtual

[AI] Placeholder or unused virtual; always returns -1.

Parameters
[AI]Unknown / unused argument.
Returns
[AI] -1 always.

Definition at line 110 of file mxbitmap.h.


The documentation for this class was generated from the following files: