TinyGPU
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
BMPParser< RGB_T > Class Template Reference

Incremental BMP decoder for TinyGPU framebuffers. More...

#include <BMPParser.h>

Collaboration diagram for BMPParser< RGB_T >:
Collaboration graph
[legend]

Classes

struct  HeaderInfo
 Stores parsed BMP metadata. More...
 

Public Types

enum class  Status { Collecting , Complete , Error }
 Represents the parser status. More...
 

Public Member Functions

 BMPParser (ISurface< RGB_T > &target)
 Creates a parser that decodes into the provided framebuffer target.
 
void reset ()
 Resets the parser to decode a new BMP image.
 
size_t write (const uint8_t *data, size_t length)
 Writes BMP data incrementally to the parser.
 
size_t write (uint8_t *data, size_t length)
 Writes BMP data incrementally to the parser.
 
bool isComplete () const
 Returns true when the full image has been decoded.
 
bool hasError () const
 Returns true when parsing failed.
 
Status status () const
 Returns the current parser status.
 
size_t width () const
 Returns the decoded image width in pixels.
 
size_t height () const
 Returns the decoded image height in pixels.
 
const char * errorMessage () const
 Returns the latest error message, if any.
 

Protected Member Functions

void tryDecode ()
 
bool parseHeader (HeaderInfo &header)
 
bool parseBitMasks (HeaderInfo &header)
 
bool parsePalette (const HeaderInfo &header)
 
uint32_t requiredDataSize (const HeaderInfo &header) const
 
bool decode (const HeaderInfo &header)
 
bool decodeRow (const HeaderInfo &header, size_t rowOffset, size_t targetY)
 
bool decode8BitRow (size_t rowOffset, size_t targetY)
 
bool decode16BitRow (const HeaderInfo &header, size_t rowOffset, size_t targetY)
 
bool decode24BitRow (size_t rowOffset, size_t targetY)
 
bool decode32BitRow (const HeaderInfo &header, size_t rowOffset, size_t targetY)
 
RGB565 decodeMaskedPixel (uint32_t pixelValue, const HeaderInfo &header) const
 
uint16_t readU16 (size_t offset) const
 
uint32_t readU32 (size_t offset) const
 
int32_t readS32 (size_t offset) const
 
void setError (const char *message)
 

Static Protected Member Functions

static uint8_t extractChannel (uint32_t pixelValue, uint32_t mask)
 
static uint32_t bmpRowStride (uint16_t bitsPerPixel, size_t width)
 

Protected Attributes

ISurface< RGB_T > & target_
 
Vector< uint8_t > buffer_
 
Vector< RGB_T > palette_
 
Status status_ = Status::Collecting
 
const char * errorMessage_ = nullptr
 
size_t imageWidth_ = 0
 
size_t imageHeight_ = 0
 
bool topDown_ = false
 

Static Protected Attributes

static constexpr uint32_t kCompressionRgb = 0
 
static constexpr uint32_t kCompressionBitfields = 3
 

Detailed Description

template<typename RGB_T = RGB565>
class tinygpu::BMPParser< RGB_T >

Incremental BMP decoder for TinyGPU framebuffers.

The parser accepts BMP file bytes through write(), buffers them until enough data is available, then decodes supported uncompressed BMP formats directly into the provided ISurface target using RGB565 pixels.

Member Enumeration Documentation

◆ Status

enum class Status
strong

Represents the parser status.

Enumerator
Collecting 
Complete 
Error 

Constructor & Destructor Documentation

◆ BMPParser()

BMPParser ( ISurface< RGB_T > &  target)
inline

Creates a parser that decodes into the provided framebuffer target.

Member Function Documentation

◆ bmpRowStride()

static uint32_t bmpRowStride ( uint16_t  bitsPerPixel,
size_t  width 
)
inlinestaticprotected

◆ decode()

bool decode ( const HeaderInfo header)
inlineprotected

◆ decode16BitRow()

bool decode16BitRow ( const HeaderInfo header,
size_t  rowOffset,
size_t  targetY 
)
inlineprotected

◆ decode24BitRow()

bool decode24BitRow ( size_t  rowOffset,
size_t  targetY 
)
inlineprotected

◆ decode32BitRow()

bool decode32BitRow ( const HeaderInfo header,
size_t  rowOffset,
size_t  targetY 
)
inlineprotected

◆ decode8BitRow()

bool decode8BitRow ( size_t  rowOffset,
size_t  targetY 
)
inlineprotected

◆ decodeMaskedPixel()

RGB565 decodeMaskedPixel ( uint32_t  pixelValue,
const HeaderInfo header 
) const
inlineprotected

◆ decodeRow()

bool decodeRow ( const HeaderInfo header,
size_t  rowOffset,
size_t  targetY 
)
inlineprotected

◆ errorMessage()

const char * errorMessage ( ) const
inline

Returns the latest error message, if any.

◆ extractChannel()

static uint8_t extractChannel ( uint32_t  pixelValue,
uint32_t  mask 
)
inlinestaticprotected

◆ hasError()

bool hasError ( ) const
inline

Returns true when parsing failed.

◆ height()

size_t height ( ) const
inline

Returns the decoded image height in pixels.

◆ isComplete()

bool isComplete ( ) const
inline

Returns true when the full image has been decoded.

◆ parseBitMasks()

bool parseBitMasks ( HeaderInfo header)
inlineprotected

◆ parseHeader()

bool parseHeader ( HeaderInfo header)
inlineprotected

◆ parsePalette()

bool parsePalette ( const HeaderInfo header)
inlineprotected

◆ readS32()

int32_t readS32 ( size_t  offset) const
inlineprotected

◆ readU16()

uint16_t readU16 ( size_t  offset) const
inlineprotected

◆ readU32()

uint32_t readU32 ( size_t  offset) const
inlineprotected

◆ requiredDataSize()

uint32_t requiredDataSize ( const HeaderInfo header) const
inlineprotected

◆ reset()

void reset ( )
inline

Resets the parser to decode a new BMP image.

◆ setError()

void setError ( const char *  message)
inlineprotected

◆ status()

Status status ( ) const
inline

Returns the current parser status.

◆ tryDecode()

void tryDecode ( )
inlineprotected

◆ width()

size_t width ( ) const
inline

Returns the decoded image width in pixels.

◆ write() [1/2]

size_t write ( const uint8_t *  data,
size_t  length 
)
inline

Writes BMP data incrementally to the parser.

◆ write() [2/2]

size_t write ( uint8_t *  data,
size_t  length 
)
inline

Writes BMP data incrementally to the parser.

Member Data Documentation

◆ buffer_

Vector<uint8_t> buffer_
protected

◆ errorMessage_

const char* errorMessage_ = nullptr
protected

◆ imageHeight_

size_t imageHeight_ = 0
protected

◆ imageWidth_

size_t imageWidth_ = 0
protected

◆ kCompressionBitfields

constexpr uint32_t kCompressionBitfields = 3
staticconstexprprotected

◆ kCompressionRgb

constexpr uint32_t kCompressionRgb = 0
staticconstexprprotected

◆ palette_

Vector<RGB_T> palette_
protected

◆ status_

Status status_ = Status::Collecting
protected

◆ target_

ISurface<RGB_T>& target_
protected

◆ topDown_

bool topDown_ = false
protected

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