fluidvis
Public Member Functions | List of all members
sx::Bitmap Class Reference

#include <SXParser.h>

Public Member Functions

EXPA Bitmap (unsigned int width, unsigned int height)
 
EXPA Bitmap (unsigned int width, unsigned int height, unsigned int bytesPerPixel)
 
EXPA Bitmap (const string filename)
 
EXPA ~Bitmap ()
 
EXPA void save (const string filename)
 
EXPA unsigned int getWidth () const
 
EXPA unsigned int getHeight () const
 
EXPA unsigned int getPixelSize () const
 
EXPA unsigned char * getData ()
 

Detailed Description

A bitmap representing an rgba image.

Constructor & Destructor Documentation

EXPA sx::Bitmap::Bitmap ( unsigned int  width,
unsigned int  height 
)

Constructs an empty image with the given width and height with 4 bytes per pixel.

EXPA sx::Bitmap::Bitmap ( unsigned int  width,
unsigned int  height,
unsigned int  bytesPerPixel 
)

Constructs an empty image with the given width and height and bytesPerPixel bytes per pixel. The value of bytesPerPixel can be 4 or 16.

EXPA sx::Bitmap::Bitmap ( const string  filename)

Constructs an image from a file. Currently bmp, jpg and png files are supported. 8, 16, 24 bit-per-pixel images are supported for bmp, jpg and png files. 32 and 64 bit-per-pixel images are supported for png files. Image files with 8, 16, 24 or 32 bits per pixel are represented with 4 bytes per pixel. After loading such an image, getPixelSize() will return 4. Image files with 64 bis per pixel are represented with 16 bytes per pixel. After loading such an image, getPixelSize() will return 16.

Parameters
filenamepath to the image loaded by the constructor
Exceptions
ifthe image can't be loaded, an exception Exception of type EX_IO is thrown
EXPA sx::Bitmap::~Bitmap ( )

deconstructor

Member Function Documentation

EXPA unsigned char* sx::Bitmap::getData ( )

Returns the data of the image as a char array. If getPixelSize() returns 4, each four arrayelements can interpreted as a pixel's red, green, blue and alpha channel such that the lowest value is 0 and the highest value is 255. If getPixelSize() returns 16, the returned array should be cast to float* Each four arrayelements of the cast float* array can be interpreted as a pixel's red, green, blue and alpha channel such that the lowest value is 0, and the highest value is 1.

EXPA unsigned int sx::Bitmap::getHeight ( ) const

returns the height of the image in pixels

EXPA unsigned int sx::Bitmap::getPixelSize ( ) const

Number of bytes per pixels. Currently only four color channels with one or four bytes are supported.

EXPA unsigned int sx::Bitmap::getWidth ( ) const

returns the width of the image in pixels

EXPA void sx::Bitmap::save ( const string  filename)

Saves the bitmap in its current state to a file. Currently bmp, jpg and png files are supported. If getPixelSize() returns 4, 24 bits per pixels will be used for bmp and jpg files, and 32 bits per pixel will be used for png files. If getPixelSize() returns 16, 24 bits per pixel will be used for bmp and jpg files, and 64 bits per pixel will be used for png files.

Parameters
filenamedestination path of the image
Exceptions
ifthe image can't be saved, an exception Exception of type EX_IO is thrown

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