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

[AI] Class representing an 8-bit palettized image with up to 256 palette entries and indexed pixel data. More...

#include <legoimage.h>

Collaboration diagram for LegoImage:

Public Member Functions

 LegoImage ()
 [AI] Constructs an empty image object. Palette is not initialized; bits is nullptr. More...
 
 LegoImage (LegoU32 p_width, LegoU32 p_height)
 [AI] Constructs an image object with a given width and height. More...
 
 ~LegoImage ()
 [AI] Destructor; releases any allocated pixel buffer memory. More...
 
LegoU32 GetWidth ()
 [AI] Returns the current image width in pixels. More...
 
void SetWidth (LegoU32 p_width)
 [AI] Sets the image width in pixels. More...
 
LegoU32 GetHeight ()
 [AI] Returns the current image height in pixels. More...
 
void SetHeight (LegoU32 p_height)
 [AI] Sets the image height in pixels. More...
 
LegoU32 GetCount ()
 [AI] Returns the number of palette entries in use for this image. More...
 
void SetCount (LegoU32 p_count)
 [AI] Sets the palette color count (number of valid entries in m_palette). More...
 
LegoPaletteEntryGetPalette ()
 [AI] Returns the pointer to the start of the palette array (256 entries). More...
 
LegoPaletteEntryGetPaletteEntry (LegoU32 p_i)
 [AI] Returns a reference to the palette entry at index p_i. More...
 
void SetPaletteEntry (LegoU32 p_i, LegoPaletteEntry &p_paletteEntry)
 [AI] Sets the palette entry at index p_i to the given value. More...
 
LegoU8GetBits ()
 [AI] Returns pointer to the buffer containing indexed pixel data. More...
 
void SetBits (LegoU8 *p_bits)
 [AI] Sets the pixel data buffer pointer. More...
 
LegoResult Read (LegoStorage *p_storage, LegoU32 p_square)
 [AI] Reads the full image from the storage source, including width, height, count, palette, and pixel indices. More...
 
LegoResult Write (LegoStorage *p_storage)
 [AI] Writes the full image to the given storage: width, height, count, palette, pixel indices. More...
 

Protected Attributes

LegoU32 m_width
 [AI] Image width, in pixels. More...
 
LegoU32 m_height
 [AI] Image height, in pixels. More...
 
LegoU32 m_count
 [AI] Number of palette entries in use (<= 256). More...
 
LegoPaletteEntry m_palette [256]
 [AI] Full palette array (256 possible 8-bit RGB entries). More...
 
LegoU8m_bits
 [AI] Pointer to the image bits. Each byte is a palette index; size = width*height. More...
 

Detailed Description

[AI] Class representing an 8-bit palettized image with up to 256 palette entries and indexed pixel data.

[AI] Each image consists of a width, height, a count of palette colors (typically 256 or less), a palette array, and a bitmap of indices referencing the palette. Pixel data is 8-bit indices into the palette. Provides serialization/deserialization and functions to manipulate palette and raw image bits. If square padding is requested upon read, non-square images are padded to squares by duplicating scanlines or columns as needed. Used for textures, UI elements, or sprite data in LEGO Island.

Definition at line 68 of file legoimage.h.

Constructor & Destructor Documentation

◆ LegoImage() [1/2]

LegoImage::LegoImage ( )

[AI] Constructs an empty image object. Palette is not initialized; bits is nullptr.

Definition at line 51 of file legoimage.cpp.

◆ LegoImage() [2/2]

LegoImage::LegoImage ( LegoU32  p_width,
LegoU32  p_height 
)

[AI] Constructs an image object with a given width and height.

Allocates the bits buffer accordingly.

Parameters
p_width[AI] Width in pixels.
p_height[AI] Height in pixels.

Definition at line 60 of file legoimage.cpp.

◆ ~LegoImage()

LegoImage::~LegoImage ( )

[AI] Destructor; releases any allocated pixel buffer memory.

Definition at line 69 of file legoimage.cpp.

Member Function Documentation

◆ GetBits()

LegoU8 * LegoImage::GetBits ( )
inline

[AI] Returns pointer to the buffer containing indexed pixel data.

[AI_SUGGESTED_CORRECTED_NAME: GetPixelIndices]

[AI] Each byte is a palette index for the corresponding pixel, row-major order. Buffer size is width*height bytes.

Definition at line 116 of file legoimage.h.

◆ GetCount()

LegoU32 LegoImage::GetCount ( )
inline

[AI] Returns the number of palette entries in use for this image.

Definition at line 96 of file legoimage.h.

◆ GetHeight()

LegoU32 LegoImage::GetHeight ( )
inline

[AI] Returns the current image height in pixels.

Definition at line 89 of file legoimage.h.

◆ GetPalette()

LegoPaletteEntry * LegoImage::GetPalette ( )
inline

[AI] Returns the pointer to the start of the palette array (256 entries).

Definition at line 103 of file legoimage.h.

◆ GetPaletteEntry()

LegoPaletteEntry & LegoImage::GetPaletteEntry ( LegoU32  p_i)
inline

[AI] Returns a reference to the palette entry at index p_i.

No bounds checking.

Parameters
p_i[AI] Index (palette entry number, 0-255).

Definition at line 107 of file legoimage.h.

◆ GetWidth()

LegoU32 LegoImage::GetWidth ( )
inline

[AI] Returns the current image width in pixels.

Definition at line 82 of file legoimage.h.

◆ Read()

LegoResult LegoImage::Read ( LegoStorage p_storage,
LegoU32  p_square 
)

[AI] Reads the full image from the storage source, including width, height, count, palette, and pixel indices.

Parameters
p_storage[AI] Storage interface to read from (file/memory/etc).
p_square[AI] If nonzero, enforces padding of the image to square dimensions by duplicating scanlines or columns.

[AI] Allocates m_bits with new[] (deletes the previous on success). Applies square-padding if requested and width != height.

Definition at line 77 of file legoimage.cpp.

◆ SetBits()

void LegoImage::SetBits ( LegoU8 p_bits)
inline

[AI] Sets the pixel data buffer pointer.

Does NOT take ownership of the memory.

Parameters
p_bits[AI] Pointer to new bits data. Must be width * height bytes.

Definition at line 120 of file legoimage.h.

◆ SetCount()

void LegoImage::SetCount ( LegoU32  p_count)
inline

[AI] Sets the palette color count (number of valid entries in m_palette).

Parameters
p_count[AI] Number of palette colors used (<= 256).

Definition at line 100 of file legoimage.h.

◆ SetHeight()

void LegoImage::SetHeight ( LegoU32  p_height)
inline

[AI] Sets the image height in pixels.

[AI_SUGGESTED_CORRECTED_NAME: SetImageHeight]

Parameters
p_height[AI] New height value to store.

Definition at line 93 of file legoimage.h.

◆ SetPaletteEntry()

void LegoImage::SetPaletteEntry ( LegoU32  p_i,
LegoPaletteEntry p_paletteEntry 
)
inline

[AI] Sets the palette entry at index p_i to the given value.

No bounds checking.

Parameters
p_i[AI] Index (palette entry number, 0-255).
p_paletteEntry[AI] Palette object containing the desired RGB value for this entry.

Definition at line 112 of file legoimage.h.

◆ SetWidth()

void LegoImage::SetWidth ( LegoU32  p_width)
inline

[AI] Sets the image width in pixels.

[AI_SUGGESTED_CORRECTED_NAME: SetImageWidth]

Parameters
p_width[AI] New width value to store.

Definition at line 86 of file legoimage.h.

◆ Write()

LegoResult LegoImage::Write ( LegoStorage p_storage)

[AI] Writes the full image to the given storage: width, height, count, palette, pixel indices.

Parameters
p_storage[AI] Storage output to receive the formatted palette data and image bits.

Definition at line 153 of file legoimage.cpp.

Member Data Documentation

◆ m_bits

LegoU8* LegoImage::m_bits
protected

[AI] Pointer to the image bits. Each byte is a palette index; size = width*height.

Definition at line 137 of file legoimage.h.

◆ m_count

LegoU32 LegoImage::m_count
protected

[AI] Number of palette entries in use (<= 256).

Definition at line 135 of file legoimage.h.

◆ m_height

LegoU32 LegoImage::m_height
protected

[AI] Image height, in pixels.

Definition at line 134 of file legoimage.h.

◆ m_palette

LegoPaletteEntry LegoImage::m_palette[256]
protected

[AI] Full palette array (256 possible 8-bit RGB entries).

Definition at line 136 of file legoimage.h.

◆ m_width

LegoU32 LegoImage::m_width
protected

[AI] Image width, in pixels.

Definition at line 133 of file legoimage.h.


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