Simple image data structure for storing RAW image data and for easy conversion to/from a few compression formats. More...
#include <image.h>
Public Types | |
enum | Format { Unused = 0, Invalid = 0, MPEG2, MPEG4, MJPEG, NTSC, PAL, TIFF, JPEG, GIF, H263, H264, PNG, BMP, RAW, PPM, PGM, PNM } |
Enumeration of possible image formats supported by this library. However, not all are supported. More... | |
Public Member Functions | |
Image () | |
Constructor. | |
Image (const Image &img) | |
Copy Constructor. | |
~Image () | |
Destructor. Destroys the Image object and closes the temporary file produced by the mVirtual file. | |
int | Create (const unsigned short width, const unsigned short height, const unsigned char channels, const unsigned char *rawImage=NULL, const bool verticalFlip=false) |
This initializes the Image. | |
int | Create (const unsigned short width, const unsigned short height, const unsigned char channels, const unsigned char *rawImage, const double scale, const bool verticalFlip=false) |
This initializes the Image. | |
int | Create (const unsigned short width, const unsigned short height, const unsigned char channels, const unsigned char *rawImage, const unsigned short maxWidth, const unsigned short maxHeight, const bool verticalFlip) |
This initializes the Image. | |
int | Destroy () |
Destroys the Image object data. | |
int | Decompress (const unsigned char *compressed, const unsigned int len, const Format format) |
Takes a compressed image in the buffer, and uses one of the supported image decompression algorithms to convert to RAW image data. | |
int | Compress (unsigned char **buffer, unsigned int *len, unsigned int *clen, const Format format, void *args=NULL) const |
The method compresses the image to buffer. | |
void | ApplyTile (const Image &tile) |
Applies a tile repeatedly accross an image. | |
int | Load (const std::string &file) |
The function loads image to internal structure. The image will be decompressed based on the extension of the file. | |
int | Save (const std::string &file) const |
The function saves a frame to file. The format will be compressed based on the extension of the file. | |
void | FlipChannels () |
Image & | operator= (const Image &img) |
Copies contents of image. | |
Static Public Member Functions | |
static int | Compress (unsigned char *image, unsigned int width, unsigned int height, unsigned char channels, unsigned char **buffer, unsigned int *len, unsigned int *clen, const Format format, void *args=NULL) |
The method compresses the image to buffer. | |
static int | SaveCompressedImage (const std::string &name, const unsigned char *data, const unsigned int size, const Format format) |
The funtion saves data to disk. | |
static Format | GetFormat (const std::string &file) |
The function returns the format based on the extension of the file. | |
static void | FlipColorChannels (unsigned char *colorImage, unsigned int width, unsigned int height) |
Public Attributes | |
unsigned char | mChannels |
Number of color channels 1, or 3. | |
unsigned short | mWidth |
Horizontal resolution of image in pixels. | |
unsigned short | mHeight |
Vertical resolution of image in pixels. | |
unsigned int | mDataSize |
Size of RAW data in bytes. | |
unsigned char * | mpImage |
Raw uncompressed image data. |
Simple image data structure for storing RAW image data and for easy conversion to/from a few compression formats.
The format for image data in this library must be BGR, not RGB, otherwise your images will look weird! BGR is used because this is the format that most used format from cameras and other capture devices.
Image compression and decompression software and image data storage. formats supported: + JPG - A modified version of libjpeg is used to convert channel order to BGR from RGB. + PNG - libpng is used
Definition at line 68 of file image.h.
Image::~Image | ( | ) |
void Image::ApplyTile | ( | const Image & | tile ) |
int Image::Compress | ( | unsigned char ** | buffer, |
unsigned int * | len, | ||
unsigned int * | clen, | ||
const Format | format, | ||
void * | args = NULL |
||
) | const |
The method compresses the image to buffer.
If necessary, this method will re-size the buffer to fit the compressed image.
[out] | buffer | The pointer to the output buffer |
[in] | len | Specify the lenght of the buffer |
[out] | clen | Is the length of the compressed image in the output buffer. |
[in] | format | The image format type to compress to. See jimageformats.h. |
[in] | args | Pointer to additional compression arguments (like quality) which is converted the appropriate format for the compression routine based on data format. (by default is NULL and does nothing). |
int Image::Compress | ( | unsigned char * | image, |
unsigned int | width, | ||
unsigned int | height, | ||
unsigned char | channels, | ||
unsigned char ** | buffer, | ||
unsigned int * | len, | ||
unsigned int * | clen, | ||
const Format | format, | ||
void * | args = NULL |
||
) | [static] |
The method compresses the image to buffer.
If necessary, this method will re-size the buffer to fit the compressed image.
[in] | image | Image data to compress. |
[in] | width | Image width in pixels. |
[in] | height | Image height in pixels. |
[in] | channels | Number of color channels in image. |
[out] | buffer | The pointer to the output buffer |
[in] | len | Specify the lenght of the buffer |
[out] | clen | Is the length of the compressed image in the output buffer. |
[in] | format | The image format type to compress to. See jimageformats.h. |
[in] | args | Pointer to additional compression arguments (like quality) which is converted the appropriate format for the compression routine based on data format. (by default is NULL and does nothing). |
int Image::Create | ( | const unsigned short | width, |
const unsigned short | height, | ||
const unsigned char | channels, | ||
const unsigned char * | rawImage, | ||
const double | scale, | ||
const bool | verticalFlip = false |
||
) |
This initializes the Image.
[in] | width | The width of the image |
[in] | height | The height of the image |
[in] | channels | Number of channels used (1, 3, or 4) |
[in] | rawImage | The image data to be copied to the image, if the pointer is NULL (default), only memory allocation takes place an no copying. |
[in] | scale | How much to scale the image data. |
[in] | verticalFlip | If true, image is flipped vertically when copied. |
int Image::Create | ( | const unsigned short | width, |
const unsigned short | height, | ||
const unsigned char | channels, | ||
const unsigned char * | rawImage, | ||
const unsigned short | maxWidth, | ||
const unsigned short | maxHeight, | ||
const bool | verticalFlip | ||
) |
This initializes the Image.
[in] | width | The width of the image |
[in] | height | The height of the image |
[in] | channels | Number of channels used (1, 3, or 4) |
[in] | rawImage | The image data to be copied to the image, if the pointer is NULL (default), only memory allocation takes place an no copying. |
[in] | maxWidth | Maximum width to store image as (will force scaling). |
[in] | maxHeight | Maximum height to store image as (will force scaling). |
[in] | verticalFlip | If true, image is flipped vertically when copied. |
int Image::Create | ( | const unsigned short | width, |
const unsigned short | height, | ||
const unsigned char | channels, | ||
const unsigned char * | rawImage = NULL , |
||
const bool | verticalFlip = false |
||
) |
This initializes the Image.
[in] | width | The width of the image |
[in] | height | The height of the image |
[in] | channels | Number of channels used (1, 3, or 4) |
[in] | rawImage | The image data to be copied to the image, if the pointer is NULL (default), only memory allocation takes place an no copying. |
[in] | verticalFlip | If true, image is flipped vertically when copied. |
int Image::Decompress | ( | const unsigned char * | compressed, |
const unsigned int | len, | ||
const Format | format | ||
) |
Takes a compressed image in the buffer, and uses one of the supported image decompression algorithms to convert to RAW image data.
[in] | compressed | The buffer with data |
[in] | len | The size of the buffer |
[in] | format | The format of the data in the compressed buffer |
int Image::Destroy | ( | ) |
static void CxUtils::Image::FlipColorChannels | ( | unsigned char * | colorImage, |
unsigned int | width, | ||
unsigned int | height | ||
) | [inline, static] |
Image::Format Image::GetFormat | ( | const std::string & | file ) | [static] |
int Image::Load | ( | const std::string & | file ) |
int Image::Save | ( | const std::string & | file ) | const |
int Image::SaveCompressedImage | ( | const std::string & | name, |
const unsigned char * | data, | ||
const unsigned int | size, | ||
const Format | format | ||
) | [static] |
unsigned char CxUtils::Image::mChannels |
unsigned int CxUtils::Image::mDataSize |
unsigned short CxUtils::Image::mHeight |
unsigned char* CxUtils::Image::mpImage |
unsigned short CxUtils::Image::mWidth |