22 m_isHighColor =
FALSE;
53 m_data =
new MxU8[size];
60 memset(m_bmiHeader, 0,
sizeof(m_info->
m_bmiHeader));
62 m_bmiHeader->biSize =
sizeof(*m_bmiHeader);
63 m_bmiHeader->biWidth = p_width;
64 m_bmiHeader->biHeight = p_height;
65 m_bmiHeader->biPlanes = 1;
66 m_bmiHeader->biBitCount = 8;
67 m_bmiHeader->biCompression = 0;
68 m_bmiHeader->biSizeImage = size;
70 if (ImportColorsToPalette(m_paletteData, p_palette)) {
108 m_data =
new MxU8[size];
113 memcpy(m_info, p_info, MxBitmapInfoSize());
150 memcpy(m_info, p_bitmap->
GetBitmapInfo(), p_bitmap->MxBitmapInfoSize());
180 handle = CreateFileA(p_filename, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
NULL);
182 if (handle == INVALID_HANDLE_VALUE) {
209 BITMAPFILEHEADER hdr;
210 if (!ReadFile(p_handle, &hdr,
sizeof(hdr), &bytesRead,
NULL)) {
223 if (!ReadFile(p_handle, m_info, MxBitmapInfoSize(), &bytesRead,
NULL)) {
231 size = hdr.bfSize -
sizeof(BITMAPFILEHEADER) - MxBitmapInfoSize();
232 m_data =
new MxU8[size];
237 if (!ReadFile(p_handle, m_data, size, &bytesRead,
NULL)) {
298 memcpy(dstStart, srcStart, p_width);
299 dstStart += dstStride;
300 srcStart += srcStride;
336 for (
MxS32 h = 0; h < p_height; h++) {
337 for (
MxS32 w = 0; w < p_width; w++) {
339 *dstStart = *srcStart;
345 srcStart += srcStride;
346 dstStart += dstStride;
357 switch (m_isHighColor) {
359 if (!(palette =
new MxPalette(m_paletteData))) {
365 if (!(palette = m_palette->
Clone())) {
377 if (!success && palette) {
390 switch (m_isHighColor) {
392 ImportColorsToPalette(m_paletteData, p_palette);
397 m_palette = p_palette->
Clone();
409 if (m_isHighColor == p_isHighColor) {
415 switch (p_isHighColor) {
417 ImportColorsToPalette(m_paletteData, m_palette);
422 if (!(pal =
new MxPalette(m_paletteData))) {
430 for (
MxU16 i = 0; i < 256; i++) {
439 m_isHighColor = p_isHighColor;
469 return StretchDIBits(
480 (BITMAPINFO*) m_info,
488MxResult MxBitmap::ImportColorsToPalette(RGBQUAD* p_rgbquad,
MxPalette* p_palette)
491 PALETTEENTRY entries[256];
506 for (i = 0; i < 256; i++) {
507 p_rgbquad[i].rgbRed = entries[i].peRed;
508 p_rgbquad[i].rgbGreen = entries[i].peGreen;
509 p_rgbquad[i].rgbBlue = entries[i].peBlue;
510 p_rgbquad[i].rgbReserved = 0;
[AI] Represents an 8bpp or high color device-independent bitmap (DIB) and provides operations for bit...
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.
MxBITMAPINFO * GetBitmapInfo() const
[AI] Retrieves the pointer to the underlying MxBITMAPINFO struct (header and palette).
virtual MxResult SetBitDepth(MxBool)
[AI] Changes the bit depth mode for the bitmap (palettized or high color).
virtual MxPalette * CreatePalette()
[AI] Allocates or clones the current palette for the bitmap.
MxLong AlignToFourByte(MxLong p_value) const
[AI] Aligns a value up to the nearest multiple of four (stride alignment for DIBs).
MxBitmap()
[AI] Constructs an empty MxBitmap instance, initializing all data pointers to NULL.
virtual MxResult ImportBitmap(MxBitmap *p_bitmap)
[AI] Imports the contents of another bitmap into this bitmap, allocating new storage and copying meta...
MxLong GetBmiHeightAbs() const
[AI] Returns the absolute value of the bitmap's height.
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 ...
~MxBitmap() override
[AI] Frees allocated memory for bitmap info, pixel data, and palette.
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 dep...
virtual MxLong Read(const char *p_filename)
[AI] Loads a bitmap from a file given its filename.
virtual MxResult LoadFile(HANDLE p_handle)
[AI] Loads a bitmap from a file handle, populating header, palette data and pixel data.
MxU8 * GetStart(MxS32 p_left, MxS32 p_top) const
[AI] Returns a pointer to the starting address of the pixel data at the specified coordinates.
virtual void ImportPalette(MxPalette *p_palette)
[AI] Attaches or clones a palette for the bitmap and updates color data as needed.
MxLong GetDataSize() const
[AI] Computes the total size in bytes for the bitmap's pixel data buffer.
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).
MxLong GetBmiWidth() const
[AI] Fetches the width (in pixels) encoded in this bitmap's header.
virtual MxResult ImportBitmapInfo(MxBITMAPINFO *p_info)
[AI] Imports bitmap header/palette info (but not pixel data) from the given info block.
MxU8 * GetImage() const
[AI] Retrieves the pointer to the image pixel data.
[AI] Encapsulates a DirectDraw 8-bit (256 color) palette for use with DirectX rendering.
MxPalette * Clone()
[AI] Creates a duplicate of this palette object with the same palette data and override flag.
MxResult GetEntries(LPPALETTEENTRY p_entries)
[AI] Copies all palette entries to external buffer.
typedef DWORD(FAR PASCAL *LPCLIPPERCALLBACK)(LPDIRECTDRAWCLIPPER lpDDClipper
#define DECOMP_SIZE_ASSERT(T, S)
#define NULL
[AI] Null pointer value (C/C++ semantics).
#define FAILURE
[AI] Used to indicate a failed operation in result codes.
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
#define GetAdjustedStride(p_bitmap)
#define TWOCC(a, b)
[AI] Macro to compose a 16-bit code from two 8-bit characters (e.g., for type IDs).
MxBool GetRectIntersection(MxS32 p_rect1Width, MxS32 p_rect1Height, MxS32 p_rect2Width, MxS32 p_rect2Height, MxS32 *p_rect1Left, MxS32 *p_rect1Top, MxS32 *p_rect2Left, MxS32 *p_rect2Top, MxS32 *p_width, MxS32 *p_height)
Computes intersection of two rectangles and modifies their positions and dimensions to the intersecti...
[AI] Represents a bitmap information header plus a 256-color palette, matching the layout for 8-bit D...
RGBQUAD m_bmiColors[256]
[AI] 256-entry color palette for 8bpp images.
BITMAPINFOHEADER m_bmiHeader
[AI] Standard DIB bitmap header (size 0x28 bytes).