CGVIS Utils
Loading...
Searching...
No Matches
BMP Namespace Reference

Classes

class  BMPException
 Exception type thrown by BMP I/O helpers. More...

Functions

bool save (const std::string &filename, const Image &source, bool ignoreSize=false)
 Save an Image to a BMP file.
bool save (const std::string &filename, uint32_t w, uint32_t h, const std::vector< float > &data, uint8_t iComponentCount=3, bool ignoreSize=false)
 Save raw floating-point component data to a BMP file.
bool save (const std::string &filename, uint32_t w, uint32_t h, const std::vector< uint8_t > &data, uint8_t iComponentCount=3, bool ignoreSize=false)
 Save raw 8-bit component data to a BMP file.
Image load (const std::string &filename)
 Load a BMP file into an Image.
void blit (const Image &source, const Vec2ui &sourceStart, const Vec2ui &sourceEnd, Image &target, const Vec2ui &targetStart, bool skipChecks=false)
 Copy a rectangular region from source to target (blit).

Function Documentation

◆ blit()

void BMP::blit ( const Image & source,
const Vec2ui & sourceStart,
const Vec2ui & sourceEnd,
Image & target,
const Vec2ui & targetStart,
bool skipChecks = false )

Copy a rectangular region from source to target (blit).

Copies pixels in the half-open region [sourceStart, sourceEnd) from source into target with its top-left corner placed at targetStart. When skipChecks is false, component count compatibility and bounds are validated. If the destination would overflow, target is grown to fit and the original contents are preserved.

Parameters
sourceSource image.
sourceStartMin corner (inclusive) of the source region.
sourceEndMax corner (exclusive) of the source region.
targetDestination image to write into (may be resized).
targetStartDestination top-left position where the region is placed.
skipChecksIf true, skip validation and resizing logic (caller is responsible for safety).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load()

Image BMP::load ( const std::string & filename)

Load a BMP file into an Image.

Parameters
filenameSource file path.
Returns
Loaded image (RGB/RGBA). For 8/16/24/32 bpp BMPs, the data is converted from BGR(A) to RGB(A). If the BMP is stored top-down (negative height), the image is flipped to a top-left origin.
Exceptions
BMPExceptionOn I/O errors, unsupported bit depth, or invalid file.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ save() [1/3]

bool BMP::save ( const std::string & filename,
const Image & source,
bool ignoreSize = false )

Save an Image to a BMP file.

Parameters
filenameDestination file path.
sourceSource image (RGB or RGBA expected).
ignoreSizeIf false, validate that total size fits into 32-bit BMP header fields; if too large, throw BMPException. If true, skip the size check (use with care).
Returns
true on success; false if the file could not be opened.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ save() [2/3]

bool BMP::save ( const std::string & filename,
uint32_t w,
uint32_t h,
const std::vector< float > & data,
uint8_t iComponentCount = 3,
bool ignoreSize = false )

Save raw floating-point component data to a BMP file.

Parameters
filenameDestination file path.
wImage width in pixels.
hImage height in pixels.
dataInterleaved pixel data of size w*h*iComponentCount in RGB(A) order per pixel. Each channel should be in [0,1].
iComponentCountNumber of components per pixel (3 for RGB, 4 for RGBA).
ignoreSizeIf false, validate that total size fits 32-bit BMP fields and throw on overflow; if true, skip this validation.
Returns
true on success; false if the file could not be opened.
Note
Values are converted to bytes by multiplying by 255 and casting.
Here is the call graph for this function:

◆ save() [3/3]

bool BMP::save ( const std::string & filename,
uint32_t w,
uint32_t h,
const std::vector< uint8_t > & data,
uint8_t iComponentCount = 3,
bool ignoreSize = false )

Save raw 8-bit component data to a BMP file.

Parameters
filenameDestination file path.
wImage width in pixels.
hImage height in pixels.
dataInterleaved pixel data of size w*h*iComponentCount in RGB(A) order per pixel.
iComponentCountNumber of components per pixel (3 for RGB, 4 for RGBA).
ignoreSizeIf false, validate that total size fits 32-bit BMP fields and throw on overflow; if true, skip this validation.
Returns
true on success; false if the file could not be opened.
Note
Rows are padded to 4-byte boundaries; components are written BGR(A) as required by BMP.