ADTF  v2.14.3
cImage Class Reference

Image and bitmap handling. More...

Inheritance diagram for cImage:

Public Member Functions

 cImage ()
 Default constructor.
 
 cImage (const cImage &oImage)
 Copy constructor.
 
virtual ~cImage ()
 Destructor.
 
tVoid Destroy ()
 Destroy the instance.
 
tResult Create (tInt nWidth, tInt nHeight, tInt nBitsPerPixel, tInt nBytesPerLine=0, const tUInt8 *pBitmap=NULL, tInt nPixelFormat=0)
 Creates a new image. More...
 
tResult Create (const tBitmapFormat *psFormat, const tColor *pPalette=NULL, const tUInt8 *pBitmap=NULL)
 Creates a new image from a bitmap format description. More...
 
tResult Attach (tUInt8 *pBitmap, tInt nWidth, tInt nHeight, tInt nBitsPerPixel, tInt nBytesPerLine=0)
 Attaches an image reference. More...
 
tResult Attach (tUInt8 *pBitmap, const tBitmapFormat *psFormat, const tColor *pPalette=NULL)
 Attaches an image reference. More...
 
tResult Load (const tChar *strFile, tUInt32 nFlags=0)
 Loads an image from a file. More...
 
tResult Save (const tChar *strFile)
 Saves the image to a file. More...
 
tResult Release ()
 Frees all allocated resources. More...
 
tResult SetPixelFormat (tInt nPixelFormat)
 Sets the pixel format used. More...
 
tInt GetPixelFormat () const
 Returns the pixel format. More...
 
tInt GetWidth () const
 Returns the width of the image. More...
 
tInt GetHeight () const
 Returns the height of the image. More...
 
tInt GetBitsPerPixel () const
 Returns the bits per pixel of the image. More...
 
tInt GetBytesPerLine () const
 Returns the bytes per line of the image. More...
 
tInt GetSize () const
 Returns the size of the image in bytes. More...
 
tFloat64 GetRatio () const
 Returns the aspect ratio of the image. More...
 
const tBitmapFormatGetFormat () const
 Returns the current bitmap format of the image. More...
 
tResult SetPalette (tInt nPaletteSize, const tColor *pPalette)
 Sets a color palette. More...
 
tColorGetPalette () const
 Returns the color palette. More...
 
tInt GetPaletteSize () const
 Returns the color palette size. More...
 
tColor GetPaletteEntry (tInt nIdx) const
 Returns a color palette entry. More...
 
tResult SetPaletteEntry (tInt nIdx, const tColor &sColor)
 Sets an entry of the color palette. More...
 
tUInt8GetBitmap () const
 Returns a pointer to the raw data. More...
 
tUInt8GetBitmapLine (tInt y) const
 Returns a pointer to raw data of a line. More...
 
tWin32BitmapInfoGetBitmapInfo ()
 Generates a Win32 image descriptor. More...
 
tInt GetBitmapInfoSize ()
 Returns the size of the Win32 image descriptor. More...
 
 operator IImage * ()
 instance of IImage More...
 
tResult Flip ()
 Flips the image upside down.
 
tResult Mirror ()
 Mirrors the image. More...
 
tResult Resize (tInt nWidth, tInt nHeight)
 Resizes the image to the new height nHeight and width nWidth. More...
 
tResult ChangeDepth (tInt nBitsPerPixel, tInt nBytesPerLine=0, tUInt32 ui32Mask=0x0)
 Changes the color depth. More...
 
tResult Convert (tInt nWidth, tInt nHeight, tInt nBitsPerPixel, tInt nBytesPerLine=0, tUInt32 ui32Mask=0x0)
 Converts the image to new dimensions and color depth. More...
 
tResult Convert (const tBitmapFormat *psFormat, tUInt32 ui32Mask=0x0)
 Converts the image to a new image format. More...
 
tResult ChangePixelFormat (tInt nFormat, tUInt32 ui32Flags=0)
 Changes the pixel format used. More...
 
tResult FlipRGB ()
 Flips RGB to BGR and the other way around. More...
 
tResult FlipAlpha ()
 Flips the alpha part from left to right and back:ARGB <-> RGBA and ABGR <-> BGRA. More...
 
tResult MakeAlphaChannel (const tColor &sColorKey, tBool bClearTransparent=tFalse)
 Creates an alpha channel. More...
 
tResult Blit (const cImage &oDestImage, tInt nFlags=0)
 Copies bitmap data from one image to another. More...
 
tResult SetBits (const tUInt8 *pSrcBitmapData, const tBitmapFormat *psSrcBitmapFormat)
 Sets the image's bitmap data. More...
 
tResult GetBits (tUInt8 *pDestBitmapData, const tBitmapFormat *psDestBitmapFormat, tInt nFlags=0)
 Retrieves the image's bitmap data. More...
 
tBool Compare (const cImage &oImage)
 Compares the bitmaps of two images. More...
 
tInt CountDifferences (const cImage &oImage)
 Compares the bitmaps of two images and counts the amount of different pixels. More...
 
cImageoperator= (const cImage &oImage)
 Set the current image to the image oImage. More...
 

Static Public Member Functions

static tInt FlipRGBFormat (tInt nPixelFormat)
 Returns the format with flipped RGB. More...
 
static tInt FlipToBGRFormat (tInt nPixelFormat)
 Returns the pixel format flipped to BGR. More...
 
static tInt FlipToRGBFormat (tInt nPixelFormat)
 Returns the pixel format flipped to RGB. More...
 
static tResult Blit (const cImage &oSrcImage, const cImage &oDestImage, tInt nFlags=0)
 Copies bitmap data from one image to another. More...
 
static tResult Blit (const tUInt8 *pSrcBitmapData, const tBitmapFormat *psSrcBitmapFormat, tUInt8 *pDestBitmapData, const tBitmapFormat *psDestBitmapFormat, tInt nFlags=0)
 Copies bitmap data from one image to another. More...
 
static tResult StretchBlit (const cImage &oSrcImage, const cImage &oDestImage, tInt nFlags=0)
 Copies bitmap data from one image (with height H1 and width W1) to another image, stretching the scr image to the width and height of the dest image (with height H2 and width W2). More...
 
static tResult StretchBlit (const tUInt8 *pSrcBitmapData, const tBitmapFormat *psSrcBitmapFormat, tUInt8 *pDestBitmapData, const tBitmapFormat *psDestBitmapFormat, tInt nFlags=0)
 Copies bitmap data from one image (with height H1 and width W1) to another image, stretching the scr image to the width and height of the dest image (with height H2 and width W2). More...
 
static tResult Convert (const tUInt8 *pSrcBitmapData, const tBitmapFormat *psSrcBitmapFormat, tUInt8 *pDestBitmapData, const tBitmapFormat *psDestBitmapFormat, tInt nFlags, tUInt32 ui32Mask)
 Converts an image to another format. More...
 
static tResult AlphaBlend (cImage *pSourceImage, cImage *pDestImage, cImage *pMaskImage)
 Alpha blends an image to a destination image. More...
 
static tResult BilinearStretchBlit (cImage &oSrc, cImage &oDest)
 Copies an image to another using the bilinear algorithm. More...
 
static tUInt8 RedValue (tUInt32 nColor)
 Returns the red component of a color. More...
 
static tUInt8 GreenValue (tUInt32 nColor)
 Returns the green component of a color. More...
 
static tUInt8 BlueValue (tUInt32 nColor)
 Returns the blue component of a color. More...
 
static tFloat64 Brightness (tFloat64 fRed, tFloat64 fGreen, tFloat64 fBlue)
 Calculates the bringhtness value of a color. More...
 
static tInt BrightnessValue (tInt nRed, tInt nGreen, tInt nBlue)
 Calculates the bringhtness value of a color without scaling it down. More...
 
static tUInt8 Brightness (tInt nRed, tInt nGreen, tInt nBlue)
 Calculates the bringhtness value of a color. More...
 
static tUInt8 Brightness (tColor nColor)
 Calculates the bringhtness value of a color. More...
 
static tUInt8 Brightness (tUInt32 nColor)
 Calculates the bringhtness value of a color. More...
 
static tInt CalcAlignedMemSize (tInt nBytes, tInt nAlignment)
 Calculate the size of a given number of bytes to match a given alignment. More...
 
static tInt GuessPixelFormat (const tBitmapFormat *pFormat)
 Tries to guess the PixelFormat based on the other parameters of a bitmap format. More...
 
static tInt GetBitsPerPixelFromFormat (tInt nFormat)
 Retrieve image resolution from image format. More...
 
static tInt GetDefaultFormatFromBpp (tInt nBpp)
 Retrieve image format based on image resolution. More...
 
static tChar const *const GetPixelFormatIdentifier (tInt const nImage)
 Returns the image format as string (enum to string) More...
 

Static Public Attributes

static tInt m_nDefaultMemoryAlignment
 the default memory alignment used, currently 16
 
static tInt m_nDefaultLineAlignment
 the default line alignment, currently power of 2
 

Protected Member Functions

tResult Initialize ()
 Initialize the image. More...
 
tResult Alloc (const tBitmapFormat *psFormat)
 Allocates the image's bitmap buffer. More...
 
tResult Free ()
 Frees the image's bitmap buffer. More...
 
tResult AllocImpl (tInt nSize, tHandle *hMemory, tVoid **pBuffer)
 Internal implementation of the allocation function. More...
 
tResult FreeImpl (tHandle hMemory)
 Internal implementation of the free function. More...
 
tResult AllocPalette (tInt nPaletteSize)
 Allocate space for a palette. More...
 
tResult FreePalette ()
 Frees space from palette. More...
 
tResult AllocBitmapInfo ()
 Allocate space for bitmap info. More...
 
tResult FreeBitmapInfo ()
 Free space from bitmap info. More...
 

Static Protected Member Functions

static tResult Blit_impl (const tUInt8 *pSrcBitmapData, const tBitmapFormat *psSrcBitmapFormat, tUInt8 *pDestBitmapData, const tBitmapFormat *psDestBitmapFormat, tInt nFlags)
 Internal blitting operation. More...
 
static tResult StretchBlit_impl (const tUInt8 *pSrcBitmapData, const tBitmapFormat *psSrcBitmapFormat, tUInt8 *pDestBitmapData, const tBitmapFormat *psDestBitmapFormat, tInt nFlags, tUInt32 ui32Mask=0x0)
 Internal blitting operation. More...
 
static tResult Convert_impl (const tUInt8 *pSrcBitmapData, const tBitmapFormat *psSrcBitmapFormat, tUInt8 *pDestBitmapData, const tBitmapFormat *psDestBitmapFormat, tInt nFlags, tUInt32 ui32Mask)
 will convert the bitmap from one format to another one. More...
 

Protected Attributes

tBool m_bReference
 flag indicating the m_pBitmap pointer is used as a reference
 
tBitmapFormat m_sFormat
 current format of bitmap
 
tWin32BitmapInfom_psBitmapInfo
 current bitmap info, windows style
 
tInt m_nBitmapInfoSize
 size of windows bitmap info
 
tColorm_pPalette
 array of colors making up the palette
 
tUInt8m_pBitmap
 actual pixel data, may be reference to data of other pic
 
tHandle m_hBitmapMemory
 Handle for bitmap memory.
 
tInt m_nGreyPaletteSize
 size of palette
 

Additional Inherited Members

- Public Types inherited from IImage
enum  tPixelFormat {
  PF_UNKNOWN = 0, PF_8BIT = 10, PF_GREYSCALE_8 = 11, PF_RGB_8 = 12,
  PF_16BIT = 20, PF_GREYSCALE_10 = 21, PF_GREYSCALE_12 = 22, PF_GREYSCALE_14 = 23,
  PF_GREYSCALE_16 = 24, PF_RGB_444 = 25, PF_RGB_555 = 26, PF_RGB_565 = 27,
  PF_RGBA_4444 = 28, PF_ABGR_4444 = 29, PF_RIII_10 = 30, PF_RIII_12 = 31,
  PF_RIII_14 = 32, PF_RIII_16 = 33, PF_BGR_555 = 34, PF_BGR_565 = 35,
  PF_24BIT = 40, PF_GREYSCALE_18 = 41, PF_GREYSCALE_20 = 42, PF_GREYSCALE_22 = 43,
  PF_GREYSCALE_24 = 44, PF_RGB_888 = 45, PF_BGR_888 = 46, PF_32BIT = 50,
  PF_ARGB_8888 = 51, PF_ABGR_8888 = 52, PF_RGBA_8888 = 53, PF_BGRA_8888 = 54,
  PF_GREYSCALE_32 = 55, PF_GREYSCALE_FLOAT32 = 56, PF_YUV420P_888 = 60, PF_CUSTOM = 1000
}
 The enum ePixelFormat specifies some common pixel formats, that is, descriptions of a byte to color mapping. More...
 
enum  tLoadFlags { LF_SWAP_RGB = 0x0001, LF_FLIP_VERTICAL = 0x0002 }
 The enum tLoadFlags specifies options available for image transformation. More...
 
enum  tBlitFlags { BLIT_VerticalFlip = 0x01, BLIT_DontStretch = 0x02 }
 This enumeration is used for the Blit function. More...
 

Detailed Description

Image and bitmap handling.

The cImage class encapsulates basic image handling methods.

Definition at line 25 of file image.h.

Member Function Documentation

tResult Alloc ( const tBitmapFormat psFormat)
protected

Allocates the image's bitmap buffer.

Parameters
psFormat[in] Specifies the image format.
Returns
Standard result code.
tResult AllocBitmapInfo ( )
protected

Allocate space for bitmap info.

Returns
Standard result code.
tResult AllocImpl ( tInt  nSize,
tHandle hMemory,
tVoid **  pBuffer 
)
protected

Internal implementation of the allocation function.

Parameters
nSize[in] Size of allocation.
hMemory[in] Memory handle.
pBuffer[in] Destination buffer.
Returns
Standard result code.
tResult AllocPalette ( tInt  nPaletteSize)
protected

Allocate space for a palette.

Parameters
nPaletteSize[in] Size of palette.
Returns
Standard result code.
static tResult AlphaBlend ( cImage pSourceImage,
cImage pDestImage,
cImage pMaskImage 
)
static

Alpha blends an image to a destination image.

Parameters
pSourceImage[in] The source image.
pDestImage[in] The destination image.
pMaskImage[in] The image that contains the alpha mask to use.
Return values
ERR_NOT_SUPPORTEDif pSourceImage or pDestImage are not PF_RGB_888, PF_BGR_888, PF_RGBA or PF_BGRA
ERR_NOERRORif all went well
This method is real-time safe.
See The ADTF Real-Time Extension.
tResult Attach ( tUInt8 pBitmap,
tInt  nWidth,
tInt  nHeight,
tInt  nBitsPerPixel,
tInt  nBytesPerLine = 0 
)

Attaches an image reference.

The Attach method initializes the image format block, but doesn't allocate actual bitmap data.

Parameters
pBitmap[in] The external bitmap.
nWidth[in] The width of the bitmap.
nHeight[in] The height of the bitmap.
nBitsPerPixel[in] The pits per pixel of the bitmap.
nBytesPerLine[in] The bytes per line (to account for padding bytes). Calculated for aligned memory if 0.
Return values
ERR_POINTERif pBitmap is NULL.
ERR_NOERRORif all went well
tResult Attach ( tUInt8 pBitmap,
const tBitmapFormat psFormat,
const tColor pPalette = NULL 
)

Attaches an image reference.

The Attach method initializes the image format block, but doesn't allocate actual bitmap data. Instead, it references the bitmap data it was passed. It does, However, copy the bitmap format.

Parameters
pBitmap[in] The external bitmap.
psFormat[in] The format description of the bitmap.
pPalette[in] An optional color palette array.
Return values
ERR_NOERROif all went well
ERR_FAILEDif a palette is provided, but bits per pixel is not 8
ERR_MEMORYif memory allocation for the palette failed
ERR_NOERRORif all went well
static tResult BilinearStretchBlit ( cImage oSrc,
cImage oDest 
)
static

Copies an image to another using the bilinear algorithm.

Parameters
oSrc[in] The source image.
oDest[in] The destination image.
Return values
ERR_POINTERif either source or destination have no bitmap data or format data
ERR_NOERRORif all went well
ERR_ERR_NOT_SUPPORTEDif the pixelformat is not either PF_RGB_888 or PF_RGBA_8888
ERR_NOT_IMPLif source and destination have a different format
tResult Blit ( const cImage oDestImage,
tInt  nFlags = 0 
)

Copies bitmap data from one image to another.

The Blit method copies bitmap data from one image to another.

Parameters
oDestImage[in] Specifies the destination image.
nFlags[in] Flags, see tBlitFlags
Return values
ERR_NO_ERRORif all went well.
ERR_NOT_SUPPORTEDif the blit needed a nont supported conversion
ERR_POINTERif any of the input pointer was NULL
This method is real-time safe only when the following conditions are met:
The image formats (color format) have to match. See The ADTF Real-Time Extension.
static tResult Blit ( const cImage oSrcImage,
const cImage oDestImage,
tInt  nFlags = 0 
)
static

Copies bitmap data from one image to another.

The Blit method copies bitmap data from one image to another.

Parameters
oSrcImage[in] Specifies the source image.
oDestImage[in] Specifies the destination image.
nFlags[in] Flags, see tBlitFlags
Return values
ERR_NO_ERRORif all went well.
ERR_NOT_SUPPORTEDif the blit needed a nont supported conversion
ERR_POINTERif any of the input pointer was NULL
This method is real-time safe only when the following conditions are met:
The image formats (color format) have to match. See The ADTF Real-Time Extension.
static tResult Blit ( const tUInt8 pSrcBitmapData,
const tBitmapFormat psSrcBitmapFormat,
tUInt8 pDestBitmapData,
const tBitmapFormat psDestBitmapFormat,
tInt  nFlags = 0 
)
static

Copies bitmap data from one image to another.

The Blit method copies bitmap data from one image to another.

Parameters
pSrcBitmapData[in] Specifies the source bitmap data.
psSrcBitmapFormat[in] Specifies the source bitmap format.
pDestBitmapData[in] Specifies the destination bitmap buffer.
psDestBitmapFormat[in] Specifies the destination bitmap format.
nFlags[in] Flags, see tBlitFlags
Return values
ERR_NO_ERRORif all went well.
ERR_NOT_SUPPORTEDif the blit needed a nont supported conversion
ERR_POINTERif any of the input pointer was NULL
This method is real-time safe only when the following conditions are met:
The image formats (color format) have to match. See The ADTF Real-Time Extension.
static tResult Blit_impl ( const tUInt8 pSrcBitmapData,
const tBitmapFormat psSrcBitmapFormat,
tUInt8 pDestBitmapData,
const tBitmapFormat psDestBitmapFormat,
tInt  nFlags 
)
staticprotected

Internal blitting operation.

Parameters
pSrcBitmapData[in] Source bitmap data.
psSrcBitmapFormat[in] Source bitmap format.
pDestBitmapData[in] Destination bitmap data.
psDestBitmapFormat[in] Destination bitmap format.
nFlags[in] Blitting flags.
Returns
Standard result code.
This method is real-time safe only when the following conditions are met:
The image formats (color format) have to match. See The ADTF Real-Time Extension.
static tUInt8 BlueValue ( tUInt32  nColor)
inlinestatic

Returns the blue component of a color.

Parameters
nColor[in] The color.
Returns
The blue component of a color.
This method is real-time safe.
See The ADTF Real-Time Extension.

Definition at line 749 of file image.h.

static tFloat64 Brightness ( tFloat64  fRed,
tFloat64  fGreen,
tFloat64  fBlue 
)
inlinestatic

Calculates the bringhtness value of a color.

Parameters
fRed[in] The red component (0.0-1.0).
fGreen[in] The green component (0.0-1.0).
fBlue[in] The blue component (0.0-1.0).
Returns
The brightness.
This method is real-time safe.
See The ADTF Real-Time Extension.

Definition at line 764 of file image.h.

static tUInt8 Brightness ( tInt  nRed,
tInt  nGreen,
tInt  nBlue 
)
inlinestatic

Calculates the bringhtness value of a color.

Parameters
nRed[in] The red component.
nGreen[in] The green component.
nBlue[in] The blue component.
Returns
The brightness.
This method is real-time safe.
See The ADTF Real-Time Extension.

Definition at line 794 of file image.h.

static tUInt8 Brightness ( tColor  nColor)
inlinestatic

Calculates the bringhtness value of a color.

Parameters
nColor[in] The color.
Returns
The brightness.
This method is real-time safe.
See The ADTF Real-Time Extension.

Definition at line 807 of file image.h.

References tColor::nBlue, tColor::nGreen, and tColor::nRed.

static tUInt8 Brightness ( tUInt32  nColor)
inlinestatic

Calculates the bringhtness value of a color.

Parameters
nColor[in] The color as RGBA.
Returns
The brightness.
This method is real-time safe.
See The ADTF Real-Time Extension.

Definition at line 820 of file image.h.

static tInt BrightnessValue ( tInt  nRed,
tInt  nGreen,
tInt  nBlue 
)
inlinestatic

Calculates the bringhtness value of a color without scaling it down.

Parameters
nRed[in] The red component.
nGreen[in] The green component.
nBlue[in] The blue component.
Returns
The brightness.
This method is real-time safe.
See The ADTF Real-Time Extension.

Definition at line 779 of file image.h.

static tInt CalcAlignedMemSize ( tInt  nBytes,
tInt  nAlignment 
)
static

Calculate the size of a given number of bytes to match a given alignment.

Parameters
nBytesnumber of bytes to align
nAlignmentbytes to align with.
Returns
size of required buffer with stuffing bytes or nBytes if nBytes was less than 1 or 0 if nBytes was less than 1; nBytes take precedence to nAlignment
This method is real-time safe.
See The ADTF Real-Time Extension.
tResult ChangeDepth ( tInt  nBitsPerPixel,
tInt  nBytesPerLine = 0,
tUInt32  ui32Mask = 0x0 
)

Changes the color depth.

Note
the pixelformat of the result is the default one for the selected bitdepth. 8 bit : PF_GREYSCALE_8 16 bit : PF_RGB_555 24 bit : PF_RGB_888 32 bit : PF_RGBA_8888
Parameters
nBitsPerPixel[in] The bits per pixel.
nBytesPerLine[in] The bytes per line.
ui32Mask[in] Only bits of color values in this bitmask will be considered.
Return values
ERR_NOERRORif all went well
ERR_MEMORYif memory reallocation failed
ERR_POINTERif no image has been created, attached or loaded yet
tResult ChangePixelFormat ( tInt  nFormat,
tUInt32  ui32Flags = 0 
)

Changes the pixel format used.

This is a shortcut for convert, changing only the pixel format Can also convert between PF_RGB_888 <-> PF_YUV420P_888 PF_RGBA_8888 <-> PF_ARGB_8888 and PF_BGRA_8888 <-> PF_ABGR_8888. Supports also all conversions of the staic cImage::convert method

Parameters
nFormat[in] The new pixel format tPixelFormat.
ui32Flagsunused
Return values
ERR_NOT_SUPPORTEDif conversion is not supported.
ERR_NOERRORif all went well
tBool Compare ( const cImage oImage)

Compares the bitmaps of two images.

The format of both images must be the same.

Parameters
oImageThe image for comparison
Returns
tTrue if both images are equal tFalse if images are different
tResult Convert ( tInt  nWidth,
tInt  nHeight,
tInt  nBitsPerPixel,
tInt  nBytesPerLine = 0,
tUInt32  ui32Mask = 0x0 
)

Converts the image to new dimensions and color depth.

Parameters
nWidth[in] The new width.
nHeight[in] The new height.
nBitsPerPixel[in] The new color depth.
nBytesPerLine[in] The new bytes per line value.
ui32Mask[in] Only bits of color values in this bitmask will be considered.
Return values
ERR_INVAILD_ARGUMENTif nWidth or nHeight <= 0
ERR_MEMORYif memory reallocation failed
ERR_POINTERif no image has been created, attached or loaded yet
ERR_NOERRORif all went well
tResult Convert ( const tBitmapFormat psFormat,
tUInt32  ui32Mask = 0x0 
)

Converts the image to a new image format.

Parameters
psFormat[in] The new format.
See also
cImage::convert_impl
Parameters
ui32Mask[in] Only bits of color values in this bitmask will be considered. This is used for 8bpp<->16bpp conversion of not listed pixel formats ONLY
Return values
ERR_POINTERif psFormat is NULL
ERR_INVAILD_ARGUMENTif nWidth or nHeight <= 0
ERR_MEMORYif memory reallocation failed
ERR_POINTERif no image has been created, attached or loaded yet
ERR_NOERRORif all went well
static tResult Convert ( const tUInt8 pSrcBitmapData,
const tBitmapFormat psSrcBitmapFormat,
tUInt8 pDestBitmapData,
const tBitmapFormat psDestBitmapFormat,
tInt  nFlags,
tUInt32  ui32Mask 
)
static

Converts an image to another format.

List of possible conversions: PF_GREYSCALE_8 -> PF_RGB_888, PF_BGR_888 PF_RGBA_8888, PF_BGRA_8888 PF_RGB_555, PF_RGB_565

PF_RGB_555/PF_RGB_565 -> PF_GREYSCALE_8 PF_BGR_888, PF_RGB_888 PF_RGBA_8888, PF_BGRA_888 PF_ARGB_8888, PF_ABGR_888

PF_RGB_888/PF_BGR -> PF_GREYSCALE_8 PF_RGB_555, PF_RGB_565 PF_BGR_888/PF_RGB_888 PF_ARGB_8888,PF_RGBA_8888,PF_BGRA_8888,PF_ABGR_8888

PF_RGBA_8888,PF_BGRA_8888 -> GREYSCALE_8

PF_ARGB_8888,PF_RGBA_8888,PF_BGRA_8888,PF_ABGR_8888 -> PF_RGB_555, PF_RGB_565 PF_ARGB_8888 / PF_ABGR_888 -> PF_RGB_888 / PF_BGR_888

Parameters
pSrcBitmapData[in] Specifies the source bitmap data.
psSrcBitmapFormat[in] Specifies the source bitmap format.
pDestBitmapData[in] Specifies the destination bitmap buffer.
psDestBitmapFormat[in] Specifies the destination bitmap format.
ui32Mask[in] Only bits of color values in this bitmask will be considered.
nFlags[in] Flags, see tBlitFlags
Return values
ERR_NOERRORif all went well.
ERR_NOT_SUPPORTEDif conversio is not supported.
static tResult Convert_impl ( const tUInt8 pSrcBitmapData,
const tBitmapFormat psSrcBitmapFormat,
tUInt8 pDestBitmapData,
const tBitmapFormat psDestBitmapFormat,
tInt  nFlags,
tUInt32  ui32Mask 
)
staticprotected

will convert the bitmap from one format to another one.

Parameters
[in]nFlagsadditional flags, allowed values
  • BLIT_VerticalFlip
  • 0
[in]pSrcBitmapDatapointer to the source bitmap Data
[in]psSrcBitmapFormatpointer to the bitmap format description
[in]pDestBitmapDatapointer to the destination bitmap
[in]psDestBitmapFormatpointer to the destination bitmap format description
[in]ui32Maskmask for bit conversions
See also
cImage::Convert()
Returns
Standard result code.
tInt CountDifferences ( const cImage oImage)

Compares the bitmaps of two images and counts the amount of different pixels.

The format of both images must be the same.

Parameters
oImageThe image for comparison
Returns
The number of different pixels
tResult Create ( tInt  nWidth,
tInt  nHeight,
tInt  nBitsPerPixel,
tInt  nBytesPerLine = 0,
const tUInt8 pBitmap = NULL,
tInt  nPixelFormat = 0 
)

Creates a new image.

Parameters
nWidth[in] The width of the image in pixels.
nHeight[in] The height of the image in pixels.
nBitsPerPixel[in] The bits per pixel
nBytesPerLine[in] The bytes per line (optional). leave this to zero for automatic calculation[recommended!] If a value is passed for this parameter it will be used as is, no padding bytes will be added.
pBitmap[in] A bitmap that the image data should be initialized with.
nPixelFormat[in] The pixelformat to use, see tPixelFormat
Return values
ERR_MEMORYif memory allocation for the data buffer failed, else ERR_NOERROR
ERR_NOERRORif all went well
tResult Create ( const tBitmapFormat psFormat,
const tColor pPalette = NULL,
const tUInt8 pBitmap = NULL 
)

Creates a new image from a bitmap format description.

Please note that ALL fields of the format Description have to be correctly filled since none but the pixel format will be automatically calculated for you. This is especially important for the size of the bitmap. Even if width, height and bytes per line have been filled in, you still need to fill in the size or no buffer will be allocated.

Parameters
psFormat[in] The format description.
pPalette[in] An optional color palette array.
pBitmap[in] A bitmap that the image data should be initialized with.
Return values
ERR_POINTERif psFormat is NULL
ERR_MEMORYif memory allocation for the data buffer failed
ERR_NOERRORif all went well
tResult FlipAlpha ( )

Flips the alpha part from left to right and back:ARGB <-> RGBA and ABGR <-> BGRA.

Return values
ERR_UNEXPECTEDif the BitsPerLine are zero
ERR_NOT_SUPPORTEDif Format is not PF_ABGR_8888, PF_BGRA_8888, PF_ARGB_8888 or PF_ARGB_8888
This method is real-time safe.
See The ADTF Real-Time Extension.
tResult FlipRGB ( )

Flips RGB to BGR and the other way around.

Return values
ERR_NOT_SUPPORTEDif the format is not one of the following PF_RGB_444 <-> PF_BGR_444 PF_RGB_555 <-> PF_BGR_555 PF_RGB_565 <-> PF_BGR_565 PF_RGB_888 <-> PF_BGR_888 PF_RGBA_8888 <-> PF_BGRA_8888 PF_ARGB_8888 <-> PF_ABGR_8888
ERR_NOERRORif all went well
This method is real-time safe.
See The ADTF Real-Time Extension.
static tInt FlipRGBFormat ( tInt  nPixelFormat)
static

Returns the format with flipped RGB.

Example: PF_RGB_888 gets flipped to PF_BGR_888

Parameters
nPixelFormat[in] The new pixel format, see cImage::tPixelFormat.
Returns
the opposite RGB format, see tPixelFormat.
static tInt FlipToBGRFormat ( tInt  nPixelFormat)
static

Returns the pixel format flipped to BGR.

Example 1: PF_RGB_555 gets flipped to PF_BGR_888 Example 2: PF_RGBA_8888 gets flipped to PF_BGRA_8888

Parameters
nPixelFormat[in] The new pixel format, see cImage::tPixelFormat.
Returns
the associated BGR format, see tPixelFormat.
static tInt FlipToRGBFormat ( tInt  nPixelFormat)
static

Returns the pixel format flipped to RGB.

Example 1: PF_BGR_555 gets flipped to PF_RGB_555 Example 2: PF_BGRA_8888 gets flipped to PF_RGBA_8888

Parameters
nPixelFormat[in] The new pixel format, see cImage::tPixelFormat.
Returns
the associated RGB format, see tPixelFormat.
tResult Free ( )
protected

Frees the image's bitmap buffer.

Returns
Standard result code.
tResult FreeBitmapInfo ( )
protected

Free space from bitmap info.

Returns
Standard result code.
tResult FreeImpl ( tHandle  hMemory)
protected

Internal implementation of the free function.

Parameters
hMemory[in] Memory handle.
Returns
Standard result code.
tResult FreePalette ( )
protected

Frees space from palette.

Returns
Standard result code.
tUInt8* GetBitmap ( ) const
virtual

Returns a pointer to the raw data.

Returns
a pointer to the raw data. NULL if image is not initialised.
This method is real-time safe.
See The ADTF Real-Time Extension.

Implements IImage.

tWin32BitmapInfo* GetBitmapInfo ( )
virtual

Generates a Win32 image descriptor.

The GetBitmapInfo method generates a Win32 image descriptor structure.

Returns
Returns a pointer to the Win32 image descriptor structure.

Implements IImage.

tInt GetBitmapInfoSize ( )

Returns the size of the Win32 image descriptor.

Returns
The size of the Win32 image descriptor.
tUInt8* GetBitmapLine ( tInt  y) const
virtual

Returns a pointer to raw data of a line.

Get the specified line of the bitmap. Use this function rather than calculating the line yourself, since the actual linewidth might vary due to stuffing bytes!

Parameters
y[in] The line number, starting at 0.
Returns
A pointer to raw data of a line or NULL if index is out of bounds
This method is real-time safe.
See The ADTF Real-Time Extension.

Implements IImage.

tResult GetBits ( tUInt8 pDestBitmapData,
const tBitmapFormat psDestBitmapFormat,
tInt  nFlags = 0 
)
virtual

Retrieves the image's bitmap data.

The GetBits method retrieves the image's bitmap data.

Parameters
pDestBitmapData[in] Specifies the destination bitmap data.
psDestBitmapFormat[in] Specifies the destination bitmap format.
nFlags[in] Flags, see tBlitFlags
Return values
ERR_NOERRORif all went well.
ERR_POINTERif oSrcBitmapData or pSrcBitmapFormat is NULL
This method is real-time safe only when the following conditions are met:
The image formats (color format) have to match. See The ADTF Real-Time Extension.

Implements IImage.

tInt GetBitsPerPixel ( ) const
virtual

Returns the bits per pixel of the image.

Returns
The bits per pixel of the image.
This method is real-time safe.
See The ADTF Real-Time Extension.

Implements IImage.

static tInt GetBitsPerPixelFromFormat ( tInt  nFormat)
static

Retrieve image resolution from image format.

Parameters
nFormat[in] Image format.
Returns
Image resolution.
This method is real-time safe.
See The ADTF Real-Time Extension.
tInt GetBytesPerLine ( ) const
virtual

Returns the bytes per line of the image.

Since the actual linewidth may be bigger than the with of the image * bytesperpixel, use this function to retrieve the actual line width including stuffing bytes

Returns
The bytes per line of the image.
This method is real-time safe.
See The ADTF Real-Time Extension.

Implements IImage.

static tInt GetDefaultFormatFromBpp ( tInt  nBpp)
static

Retrieve image format based on image resolution.

Parameters
nBpp[in] Image resolution.
Returns
Image format.
This method is real-time safe.
See The ADTF Real-Time Extension.
const tBitmapFormat* GetFormat ( ) const
virtual

Returns the current bitmap format of the image.

See also
tBitmapFormat
Returns
Pointer to the current bitmap format of the image.
This method is real-time safe.
See The ADTF Real-Time Extension.

Implements IImage.

tInt GetHeight ( ) const
virtual

Returns the height of the image.

Returns
The height of the image.
This method is real-time safe.
See The ADTF Real-Time Extension.

Implements IImage.

tColor* GetPalette ( ) const
virtual

Returns the color palette.

Returns
The color palette.
This method is real-time safe.
See The ADTF Real-Time Extension.

Implements IImage.

tColor GetPaletteEntry ( tInt  nIdx) const
virtual

Returns a color palette entry.

  • Parameters
    nIdx[in] The index of the entry, starting at 0.
    Returns
    The color palette entry.
    This method is real-time safe.
    See The ADTF Real-Time Extension.

Implements IImage.

tInt GetPaletteSize ( ) const
virtual

Returns the color palette size.

Returns
The color palette size.
This method is real-time safe.
See The ADTF Real-Time Extension.

Implements IImage.

tInt GetPixelFormat ( ) const
virtual

Returns the pixel format.

Returns
The pixel format, see tPixelFormat.
This method is real-time safe.
See The ADTF Real-Time Extension.

Implements IImage.

static tChar const* const GetPixelFormatIdentifier ( tInt const  nImage)
static

Returns the image format as string (enum to string)

Parameters
nImage[in] Image format.
Returns
pixel identifier as string.
This method is real-time safe.
See The ADTF Real-Time Extension.
tFloat64 GetRatio ( ) const
virtual

Returns the aspect ratio of the image.

Returns
The aspect ratio of the image.
This method is real-time safe.
See The ADTF Real-Time Extension.

Implements IImage.

tInt GetSize ( ) const
virtual

Returns the size of the image in bytes.

Returns
The size of the image in bytes. My be bigger than w*h*(bpp/8) due to stuffing bytes
This method is real-time safe.
See The ADTF Real-Time Extension.

Implements IImage.

tInt GetWidth ( ) const
virtual

Returns the width of the image.

Returns
The width of the image.
This method is real-time safe.
See The ADTF Real-Time Extension.

Implements IImage.

static tUInt8 GreenValue ( tUInt32  nColor)
inlinestatic

Returns the green component of a color.

Parameters
nColor[in] The color.
Returns
The green component of a color.
This method is real-time safe.
See The ADTF Real-Time Extension.

Definition at line 736 of file image.h.

static tInt GuessPixelFormat ( const tBitmapFormat pFormat)
static

Tries to guess the PixelFormat based on the other parameters of a bitmap format.

Parameters
[in]pFormatThe input format to base the guess on. If the nPixelFormat member is set to something other than PF_UNKNOWN, this value is returned.
Returns
The guessed PixelFormat tPixelFormat.
This method is real-time safe.
See The ADTF Real-Time Extension.
tResult Initialize ( )
protected

Initialize the image.

Returns
Standard result code.
tResult Load ( const tChar strFile,
tUInt32  nFlags = 0 
)

Loads an image from a file.

This loads an image from a fileassuming the following pixelformats: 24 bit: PF_RGB_888 32 bit: PF_RGBA_8888 You may overwrite the pixelformat with cImage::SetPixelFormat

Currently only the BMP Format is supported.

Parameters
strFile[in] The filename.
nFlags[in] Special Flags, see tLoadFlags.
Return values
ERR_NOERRORif all went well
ERR_POINTERif strFile is NULL
ERR_NOERRORif all went well.
ERR_OPEN_FAILEDif the file could not be opened ( e.g. does not exist )
ERR_INVALID_FILEif file could be opened but is no compatible bitmap
ERR_NOT_SUPPORTEDif the file's bits per pixel is less than 8
ERR_MEMORYif memory allocation for the buffer failed
tResult MakeAlphaChannel ( const tColor sColorKey,
tBool  bClearTransparent = tFalse 
)

Creates an alpha channel.

Remarks
if the input is not a bpp of 32, a conversion to 32 bpp is executed!
this function works on RGBA internally. If input is not RGBA , it is converted to RGBA! During conversion the (e.g. from 24Bit values), the alpha values are set to 0x00 per default.
Parameters
sColorKey[in] The alpha value of pixels with this color will be set to 0, all others will get 0xFF. A given alpha channel will be ignored
bClearTransparent[in] If tTrue then pixels matching sColorKey will be set to black.
Return values
ERR_NOERRORif all went well.
ERR_NOT_SUPPORTEDif no conversion could be found to convert to PF_RGBA_888
ERR_POINTERif no image has been loaded, attached or created yet
tResult Mirror ( )

Mirrors the image.

Return values
ERR_NOERRORif all went well
ERR_NOT_SUPPORTEDif executed on unsupported pixel format
ERR_UNEXPECTEDif no bitmap data is associated
operator IImage * ( )
inline

instance of IImage

Returns
object

Definition at line 370 of file image.h.

cImage& operator= ( const cImage oImage)

Set the current image to the image oImage.

Parameters
oImage[in] Given Image.
Returns
Returns a reference to the given image.
static tUInt8 RedValue ( tUInt32  nColor)
inlinestatic

Returns the red component of a color.

Parameters
nColor[in] The color.
Returns
The red component of a color.
This method is real-time safe.
See The ADTF Real-Time Extension.

Definition at line 723 of file image.h.

tResult Release ( )

Frees all allocated resources.

Returns
always returns ERR_NOERROR
tResult Resize ( tInt  nWidth,
tInt  nHeight 
)

Resizes the image to the new height nHeight and width nWidth.

This function is calling the Convert() function, in which the parameters nBytesPerLine and ui32Mask are not specified and nBitsPerPixel stays unchanged. In this special case, the Convert() function calls the function StretchBlit(), in which the image is resized by a "Nearest Neighbour" algorithm. For further information about the implemented Nearest Neighbour algorithm, please have a look at StretchBlit().

Parameters
nWidth[in] The new width.
nHeight[in] The new height.
Return values
ERR_NOERRORif all went well.
ERR_INVAILD_ARGUMENTif nWidth or nHeight <= 0
ERR_MEMORYif memory reallocation failed
ERR_POINTERif no image has been created, attached or loaded yet
tResult Save ( const tChar strFile)

Saves the image to a file.

This saves the raw image as is allowing you to save your data in what ever format it currenntly is. Since the format information, except the bpp, is not stored along in the resulting file, you have to use this with care.

Parameters
strFile[in] The filename.
Return values
ERR_NOERRORif all went well
ERR_POINTERif strFile is NULL
ERR_OPEN_FAILEDif the file could not be created
ERR_DEVICE_IOif there was an error while writing
tResult SetBits ( const tUInt8 pSrcBitmapData,
const tBitmapFormat psSrcBitmapFormat 
)

Sets the image's bitmap data.

The SetBits method sets the image's bitmap data, and will release the current buffer if format differs. When format not differs it will only overwrite the current buffer.

Parameters
pSrcBitmapData[in] Specifies the source bitmap data.
psSrcBitmapFormat[in] Specifies the source bitmap format.
Return values
ERR_NO_ERRORif all went well
ERR_POINTERif pSrcBitmapData or psSrcBitmapFormat
ERR_MEMORYif a problem occured during creation of new image buffer
ERR_NOERRORif all went well
This method is real-time safe only when the following conditions are met:
The image formats (color format) have to match. See The ADTF Real-Time Extension.
tResult SetPalette ( tInt  nPaletteSize,
const tColor pPalette 
)

Sets a color palette.

Parameters
nPaletteSize[in] The size of the pPalette array
pPalette[in] The color palette array. If this is NULL, initialises palette as greyscale
Return values
ERR_NOERRORif all went well.
ERR_NOT_SUPPORTEDif bits per pixel are not 8
ERR_MEMORYif memory allocation for the palette failed
tResult SetPaletteEntry ( tInt  nIdx,
const tColor sColor 
)

Sets an entry of the color palette.

Parameters
nIdx[in] The index of the entry, starting at 0.
sColor[in] The new color value.
Return values
ERR_INVALID_ARGif nIdx is not part of the palette
ERR_NOERRORif all went well
This method is real-time safe.
See The ADTF Real-Time Extension.
tResult SetPixelFormat ( tInt  nPixelFormat)

Sets the pixel format used.

Does NOT perform a conversion.

Parameters
nPixelFormat[in] The new pixel format, see cImage::tPixelFormat.
Returns
Always returns ERR_NOERROR.
This method is real-time safe.
See The ADTF Real-Time Extension.
static tResult StretchBlit ( const cImage oSrcImage,
const cImage oDestImage,
tInt  nFlags = 0 
)
static

Copies bitmap data from one image (with height H1 and width W1) to another image, stretching the scr image to the width and height of the dest image (with height H2 and width W2).

The stretching is done via a Nearest Neighbour algorithm. The value for the pixel (x_n,y_m) in the dest image is given by the value of the pixel: (x,y)= ( |_ (x_n*W1)/W2 _| , |_ (y_m*H1)/H2 _| ) of the src image. |_x_| stands for the mathematical floor function (e.g. |_1.34_| = 1).

Parameters
oSrcImage[in] Specifies the source image.
oDestImage[in] Specifies the destination image.
nFlags[in] Flags, see tBlitFlags
Return values
ERR_NOERRORif all went well.
ERR_NO_SUPPORTEDif a pixelformat conversion was needed but was not supported
static tResult StretchBlit ( const tUInt8 pSrcBitmapData,
const tBitmapFormat psSrcBitmapFormat,
tUInt8 pDestBitmapData,
const tBitmapFormat psDestBitmapFormat,
tInt  nFlags = 0 
)
static

Copies bitmap data from one image (with height H1 and width W1) to another image, stretching the scr image to the width and height of the dest image (with height H2 and width W2).

The stretching is done via a Nearest Neighbour algorithm. The value for the pixel (x_n,y_m) in the dest image is given by the value of the pixel: (x,y)= ( |_ (x_n*W1)/W2 _| , |_ (y_m*H1)/H2 _| ) of the src image. |_x_| stands for the mathematical floor function (e.g. |_1.34_| = 1).

Parameters
pSrcBitmapData[in] Specifies the source bitmap data.
psSrcBitmapFormat[in] Specifies the source bitmap format.
pDestBitmapData[in] Specifies the destination bitmap buffer.
psDestBitmapFormat[in] Specifies the destination bitmap format.
nFlags[in] Flags, see tBlitFlags
Return values
ERR_NOERRORif all went well.
ERR_NO_SUPPORTEDif a pixelformat conversion was needed but was not supported
static tResult StretchBlit_impl ( const tUInt8 pSrcBitmapData,
const tBitmapFormat psSrcBitmapFormat,
tUInt8 pDestBitmapData,
const tBitmapFormat psDestBitmapFormat,
tInt  nFlags,
tUInt32  ui32Mask = 0x0 
)
staticprotected

Internal blitting operation.

Parameters
pSrcBitmapData[in] Source bitmap data.
psSrcBitmapFormat[in] Source bitmap format.
pDestBitmapData[in] Destination bitmap data.
psDestBitmapFormat[in] Destination bitmap format.
nFlags[in] Blitting flags.
ui32Mask[in] Blitting mask.
Returns
Standard result code.

Copyright © Audi Electronics Venture GmbH. All rights reserved. (Generated on Fri Mar 22 2019 by doxygen 1.8.10)