Mali OpenCL SDK v1.1.0
 All Classes Files Functions Variables Macros Pages
image.h File Reference

Functions for working with bitmap images. More...

#include <CL/cl.h>
#include <string>

Go to the source code of this file.

Classes

struct  bitmapMagic
 Bitmap magic file header numbers. More...
 
struct  bitmapHeader
 Bitmap header. More...
 
struct  bitmapInformationHeader
 Bitmap information header. More...
 

Functions

bool saveToBitmap (std::string filename, int width, int height, const unsigned char *imageData)
 Save data as a bitmap image.
 
bool loadFromBitmap (std::string filename, int *width, int *height, unsigned char **imageData)
 Load data from a bitmap image.
 
bool luminanceToRGB (const unsigned char *luminanceData, unsigned char *rgbData, int width, int height)
 Convert 8-bits per pixel luminance data to 24-bits per pixel RGB data.
 
bool RGBToLuminance (const unsigned char *rgbData, unsigned char *luminanceData, int width, int height)
 Convert 24-bits per pixel RGB data to 8-bits per pixel luminance data.
 
bool RGBToRGBA (const unsigned char *rgbData, unsigned char *rgbaData, int width, int height)
 Convert 24-bits per pixel RGB data to 32-bits per pixel RGBA data.
 
bool RGBAToRGB (const unsigned char *rgbaData, unsigned char *rgbData, int width, int height)
 Convert 32-bits per pixel RGBA data to 24-bits per pixel RGB data.
 

Detailed Description

Functions for working with bitmap images.

Definition in file image.h.

Function Documentation

bool loadFromBitmap ( std::string  filename,
int *  width,
int *  height,
unsigned char **  imageData 
)

Load data from a bitmap image.

Load a block of 24-bits per pixel RGB image data from a bitmap image. Only supports uncompressed bitmaps.

Parameters
[in]filenameThe filename of the bitmap to load.
[out]widthPointer to where the width of the image (in pixels) will be stored.
[out]heightPointer to where the height of the image (in pixels) will be stored.
[out]imageDataPointer to the data block loaded. Data is loaded as 8-bits per component RGB and in row-major format. The size of the data block is 3 * width * height bytes. Data must be deleted by the calling application.
Returns
False if an error occurred, true otherwise.
bool luminanceToRGB ( const unsigned char *  luminanceData,
unsigned char *  rgbData,
int  width,
int  height 
)

Convert 8-bits per pixel luminance data to 24-bits per pixel RGB data.

Each RGB pixel is created using the luminance value for each component. For example, a pixel with luminance of 125 will convert into an RGB pixel with values R = 125, G = 125, and B = 125.

Parameters
[in]luminanceDataPointer to a block of 8-bits per pixel luminance data. Must be width * height bytes in size.
[out]rgbDataPointer to a data block containing the 24-bits per pixel RGB data. The data block must be initialised with a size of 3 * width * height bytes.
[in]widthThe width of the image.
[in]heightThe height of the image.
Returns
False if an error occurred, true otherwise.

Definition at line 243 of file image.cpp.

bool RGBAToRGB ( const unsigned char *  rgbaData,
unsigned char *  rgbData,
int  width,
int  height 
)

Convert 32-bits per pixel RGBA data to 24-bits per pixel RGB data.

The alpha values are discarded.

Parameters
[in]rgbaDataPointer to a block of 32-bits per pixel RGBA data. Must be 4 * width * height bytes in size.
[out]rgbDataPointer to a data block containing the 24-bits per pixel RGB data. The data block must be initialised with a size of 3 * width * height bytes.
[in]widthThe width of the image.
[in]heightThe height of the image.
Returns
False if an error occurred, true otherwise.

Definition at line 318 of file image.cpp.

bool RGBToLuminance ( const unsigned char *  rgbData,
unsigned char *  luminanceData,
int  width,
int  height 
)

Convert 24-bits per pixel RGB data to 8-bits per pixel luminance data.

Each luminance pixel is created using a weighted sum of the RGB values. The weightings are 0.2126R, 0.7152G, and 0.0722B.

Parameters
[in]rgbDataPointer to a block of 24-bits per pixel RGB data. Must be 3 * width * height bytes in size.
[out]luminanceDataPointer to a data block containing the 8-bits per pixel luminanceData data. The data block must be initialised with a size of width * height bytes.
[in]widthThe width of the image.
[in]heightThe height of the image.
Returns
False if an error occurred, true otherwise.

Definition at line 267 of file image.cpp.

bool RGBToRGBA ( const unsigned char *  rgbData,
unsigned char *  rgbaData,
int  width,
int  height 
)

Convert 24-bits per pixel RGB data to 32-bits per pixel RGBA data.

The alpha values are all set to 255.

Parameters
[in]rgbDataPointer to a block of 24-bits per pixel RGB data. Must be 3 * width * height bytes in size.
[out]rgbaDataPointer to a data block containing the 32-bits per pixel RGBA data. The data block must be initialised with a size of 4 * width * height bytes.
[in]widthThe width of the image.
[in]heightThe height of the image.
Returns
False if an error occurred, true otherwise.

Definition at line 291 of file image.cpp.

bool saveToBitmap ( std::string  filename,
int  width,
int  height,
const unsigned char *  imageData 
)

Save data as a bitmap image.

Save a block of 24-bits per pixel RGB image data out as a bitmap image. Output bitmap is uncompressed.

Parameters
[in]filenameThe filename to use for the bitmap (should typically have the extension .bmp).
[in]widthThe width of the image to save (in pixels).
[in]heightThe height of the image to save (in pixels).
[in]imageDataPointer to the data block to save. Data must be 8-bits per component RGB and be in row-major format. The size of the data block must be 3 * width * height bytes.
Returns
False if an error occurred, true otherwise.