ADTF Display Toolbox
Loading...
Searching...
No Matches
cImage

Image and bitmap handling. More...

#include <image.h>

Inheritance diagram for cImage:
[legend]

Public Member Functions

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

Static Public Member Functions

static tInt FlipRGBFormat (tInt nPixelFormat)
 Returns the format with flipped RGB.
 
static tInt FlipToBGRFormat (tInt nPixelFormat)
 Returns the pixel format flipped to BGR.
 
static tInt FlipToRGBFormat (tInt nPixelFormat)
 Returns the pixel format flipped to RGB.
 
static tResult Convert (const tUInt8 *pSrcBitmapData, const tBitmapFormat *psSrcBitmapFormat, tUInt8 *pDestBitmapData, const tBitmapFormat *psDestBitmapFormat, tInt nFlags, tUInt32 ui32Mask)
 Converts an image to another format.
 
static tResult Blit (const disptb::graphicslib::dengar::cImage &oSrcImage, const disptb::graphicslib::dengar::cImage &oDestImage, tInt nFlags=0)
 Copies bitmap data from one image to another.
 
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.
 
static tResult StretchBlit (const disptb::graphicslib::dengar::cImage &oSrcImage, const disptb::graphicslib::dengar::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).
 
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).
 
static tResult AlphaBlend (disptb::graphicslib::dengar::cImage *pSourceImage, disptb::graphicslib::dengar::cImage *pDestImage, disptb::graphicslib::dengar::cImage *pMaskImage)
 Alpha blends an image to a destination image.
 
static tResult BilinearStretchBlit (disptb::graphicslib::dengar::cImage &oSrc, disptb::graphicslib::dengar::cImage &oDest)
 Copies an image to another using the bilinear algorithm.
 
static tResult SetTransparency (disptb::graphicslib::dengar::cImage *pImage, disptb::graphicslib::dengar::cColor oColor)
 Helper method for setting transparency in bitmaps.
 
static tUInt8 RedValue (tUInt32 nColor)
 Returns the red component of a color.
 
static tUInt8 GreenValue (tUInt32 nColor)
 Returns the green component of a color.
 
static tUInt8 BlueValue (tUInt32 nColor)
 Returns the blue component of a color.
 
static tFloat64 Brightness (tFloat64 fRed, tFloat64 fGreen, tFloat64 fBlue)
 Calculates the bringhtness value of a color.
 
static tUInt8 Brightness (tInt nRed, tInt nGreen, tInt nBlue)
 Calculates the bringhtness value of a color.
 
static tUInt8 Brightness (tColor nColor)
 Calculates the bringhtness value of a color.
 
static tUInt8 Brightness (tUInt32 nColor)
 Calculates the bringhtness value of a color.
 
static tInt BrightnessValue (tInt nRed, tInt nGreen, tInt nBlue)
 Calculates the bringhtness value of a color without scaling it down.
 
static tInt CalcAlignedMemSize (tInt nBytes, tInt nAlignment)
 Calculate the size of a given number of bytes to match a given alignment.
 
static tInt GuessPixelFormat (const tBitmapFormat *pFormat)
 Tries to guess the PixelFormat based on the other parameters of a bitmap format.
 
static tInt GetBitsPerPixelFromFormat (tInt nFormat)
 Retrieve image resolution from image format.
 
static tInt GetDefaultFormatFromBpp (tInt nBpp)
 Retrieve image format based on image resolution.
 
static tChar const * GetPixelFormatIdentifier (const tInt nImage)
 Returns the image format as string (enum to string)
 
static int32_t GetNextPowerOfTwo (int32_t const a)
 
static int32_t CalcBitsPerPixelFromPixelFormat (int32_t const oPixelFormat)
 
static bool NeedAlphaBlend (int32_t const oPixelFormat)
 

Static Public Attributes

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

Protected Member Functions

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

Static Protected Member Functions

static tResult Blit_impl (const tUInt8 *pSrcBitmapData, const tBitmapFormat *psSrcBitmapFormat, tUInt8 *pDestBitmapData, const tBitmapFormat *psDestBitmapFormat, tInt nFlags)
 Internal blitting operation.
 
static tResult StretchBlit_impl (const tUInt8 *pSrcBitmapData, const tBitmapFormat *psSrcBitmapFormat, tUInt8 *pDestBitmapData, const tBitmapFormat *psDestBitmapFormat, tInt nFlags, tUInt32 ui32Mask=0x0)
 Internal blitting operation.
 
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.
 
static tUInt8 BlendPixel (tUInt8 c1, tUInt8 c2, tUInt8 c3, tUInt8 c4, tInt alpha_y, tInt alpha_x)
 
static tUInt32 BlendRGB32 (tUInt32 c1, tUInt32 c2, tUInt32 c3, tUInt32 c4, tInt alpha_y, tInt alpha_x)
 
static tUInt16 AdjustMasks (tUInt16 iSMask, tUInt16 iDMask, tInt &iPos)
 

Protected Attributes

tBool m_bReference
 flag indicating the m_pBitmap pointer is used as a reference
 
tBitmapFormat m_sFormat
 current format of bitmap
 
tWin32BitmapInfo * m_psBitmapInfo
 current bitmap info, windows style
 
tInt m_nBitmapInfoSize
 size of windows bitmap info
 
tColor * m_pPalette
 array of colors making up the palette
 
tUInt8 * m_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_xRGB_8888 = 70 ,
  PF_xBGR_8888 = 71 , PF_RGBx_8888 = 72 , PF_BGRx_8888 = 73 , PF_ARGB_1555 = 74 ,
  PF_RGBA_5551 = 75 , PF_ABGR_1555 = 76 , PF_BGRA_5551 = 77 , 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 107 of file image.h.

Constructor & Destructor Documentation

◆ cImage() [1/3]

cImage ( )
inline

Default constructor.

Definition at line 130 of file image.h.

◆ cImage() [2/3]

cImage ( const cImage & oImage)
inline

Copy constructor.

Parameters
oImage[in] the other instance of cImage.

Definition at line 139 of file image.h.

◆ cImage() [3/3]

cImage ( const IImage & oImage)
inline

Copy constructor.

Parameters
oImage[in] the other instance of IImage.

Definition at line 147 of file image.h.

◆ ~cImage()

virtual ~cImage ( )
inlinevirtual

Destructor.

Definition at line 157 of file image.h.

Member Function Documentation

◆ AdjustMasks()

static tUInt16 AdjustMasks ( tUInt16 iSMask,
tUInt16 iDMask,
tInt & iPos )
inlinestaticprotected

Definition at line 4585 of file image.h.

◆ Alloc()

tResult Alloc ( const tBitmapFormat * psFormat)
inlineprotected

Allocates the image's bitmap buffer.

Parameters
psFormat[in] Specifies the image format.
Returns
Standard result code.

Definition at line 2881 of file image.h.

◆ AllocBitmapInfo()

tResult AllocBitmapInfo ( )
inlineprotected

Allocate space for bitmap info.

Returns
Standard result code.

Definition at line 3035 of file image.h.

◆ AllocImpl()

tResult AllocImpl ( tInt nSize,
tHandle * hMemory,
tVoid ** pBuffer )
inlineprotected

Internal implementation of the allocation function.

Parameters
nSize[in] Size of allocation.
hMemory[in] Memory handle.
pBuffer[in] Destination buffer.
Returns
Standard result code.

Definition at line 2950 of file image.h.

◆ AllocPalette()

tResult AllocPalette ( tInt nPaletteSize)
inlineprotected

Allocate space for a palette.

Parameters
nPaletteSize[in] Size of palette.
Returns
Standard result code.

Definition at line 2990 of file image.h.

◆ AlphaBlend()

static tResult AlphaBlend ( disptb::graphicslib::dengar::cImage * pSourceImage,
disptb::graphicslib::dengar::cImage * pDestImage,
disptb::graphicslib::dengar::cImage * pMaskImage )
inlinestatic

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

Definition at line 1857 of file image.h.

◆ Attach() [1/2]

tResult Attach ( tUInt8 * pBitmap,
const tBitmapFormat * psFormat,
const tColor * pPalette = nullptr )
inline

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

Definition at line 315 of file image.h.

◆ Attach() [2/2]

tResult Attach ( tUInt8 * pBitmap,
tInt nWidth,
tInt nHeight,
tInt nBitsPerPixel,
tInt nBytesPerLine = 0 )
inline

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

Definition at line 276 of file image.h.

◆ BilinearStretchBlit()

static tResult BilinearStretchBlit ( disptb::graphicslib::dengar::cImage & oSrc,
disptb::graphicslib::dengar::cImage & oDest )
inlinestatic

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

Definition at line 1942 of file image.h.

◆ BlendPixel()

static tUInt8 BlendPixel ( tUInt8 c1,
tUInt8 c2,
tUInt8 c3,
tUInt8 c4,
tInt alpha_y,
tInt alpha_x )
inlinestaticprotected

Definition at line 4552 of file image.h.

◆ BlendRGB32()

static tUInt32 BlendRGB32 ( tUInt32 c1,
tUInt32 c2,
tUInt32 c3,
tUInt32 c4,
tInt alpha_y,
tInt alpha_x )
inlinestaticprotected

Definition at line 4562 of file image.h.

◆ Blit() [1/3]

tResult Blit ( const cImage & oDestImage,
tInt nFlags = 0 )
inline

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_NOERRORif all went well.
ERR_NOT_SUPPORTEDif the blit needed a nont supported conversion
ERR_POINTERif any of the input pointer was NULL

Definition at line 1641 of file image.h.

◆ Blit() [2/3]

static tResult Blit ( const disptb::graphicslib::dengar::cImage & oSrcImage,
const disptb::graphicslib::dengar::cImage & oDestImage,
tInt nFlags = 0 )
inlinestatic

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_NOERRORif all went well.
ERR_NOT_SUPPORTEDif the blit needed a nont supported conversion
ERR_POINTERif any of the input pointer was NULL

Definition at line 1708 of file image.h.

◆ Blit() [3/3]

static tResult Blit ( const tUInt8 * pSrcBitmapData,
const tBitmapFormat * psSrcBitmapFormat,
tUInt8 * pDestBitmapData,
const tBitmapFormat * psDestBitmapFormat,
tInt nFlags = 0 )
inlinestatic

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_NOERRORif all went well.
ERR_NOT_SUPPORTEDif the blit needed a nont supported conversion
ERR_POINTERif any of the input pointer was NULL

Definition at line 1731 of file image.h.

◆ Blit_impl()

static tResult Blit_impl ( const tUInt8 * pSrcBitmapData,
const tBitmapFormat * psSrcBitmapFormat,
tUInt8 * pDestBitmapData,
const tBitmapFormat * psDestBitmapFormat,
tInt nFlags )
inlinestaticprotected

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.

Definition at line 3114 of file image.h.

◆ BlueValue()

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.

Definition at line 2159 of file image.h.

◆ Brightness() [1/4]

static tUInt8 Brightness ( tColor nColor)
inlinestatic

Calculates the bringhtness value of a color.

Parameters
nColor[in] The color.
Returns
The brightness.

Definition at line 2213 of file image.h.

◆ Brightness() [2/4]

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.

Definition at line 2173 of file image.h.

◆ Brightness() [3/4]

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.

Definition at line 2201 of file image.h.

◆ Brightness() [4/4]

static tUInt8 Brightness ( tUInt32 nColor)
inlinestatic

Calculates the bringhtness value of a color.

Parameters
nColor[in] The color as RGBA.
Returns
The brightness.

Definition at line 2227 of file image.h.

◆ BrightnessValue()

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.

Definition at line 2187 of file image.h.

◆ CalcAlignedMemSize()

static tInt CalcAlignedMemSize ( tInt nBytes,
tInt nAlignment )
inlinestatic

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

Definition at line 2577 of file image.h.

◆ CalcBitsPerPixelFromPixelFormat()

static int32_t CalcBitsPerPixelFromPixelFormat ( int32_t const oPixelFormat)
inlinestatic

Definition at line 4427 of file image.h.

◆ ChangeDepth()

tResult ChangeDepth ( tInt nBitsPerPixel,
tInt nBytesPerLine = 0,
tUInt32 ui32Mask = 0x0 )
inline

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

Definition at line 1164 of file image.h.

◆ ChangePixelFormat()

tResult ChangePixelFormat ( tInt nFormat,
tUInt32 ui32Flags = 0 )
inline

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

Definition at line 1306 of file image.h.

◆ Compare()

tBool Compare ( const disptb::graphicslib::dengar::cImage & oImage)
inline

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

Definition at line 2481 of file image.h.

◆ Convert() [1/4]

tResult Convert ( const tBitmapFormat * psFormat,
tUInt32 ui32Mask = 0x0 )
inline

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

Definition at line 1210 of file image.h.

◆ Convert() [2/4]

static tResult Convert ( const tUInt8 * pSrcBitmapData,
const tBitmapFormat * psSrcBitmapFormat,
tUInt8 * pDestBitmapData,
const tBitmapFormat * psDestBitmapFormat,
tInt nFlags,
tUInt32 ui32Mask )
inlinestatic

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.

Definition at line 1822 of file image.h.

◆ Convert() [3/4]

tResult Convert ( tInt nWidth,
tInt nHeight,
tInt nBitsPerPixel,
tInt nBytesPerLine = 0,
tUInt32 ui32Mask = 0x0 )
inline

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

Definition at line 1185 of file image.h.

◆ Convert() [4/4]

tResult Convert ( tInt oPixelFormat)
inline

Converts the image to a new image format.

Parameters
oPixelFormat[in] The new pixel format.
Return values
ERR_INVALID_ARGif given format is incompatible.
ERR_UNKNOWN_FORMATif format is too special.
ERR_NOERRORif all went well

Definition at line 1282 of file image.h.

◆ Convert_impl()

static tResult Convert_impl ( const tUInt8 * pSrcBitmapData,
const tBitmapFormat * psSrcBitmapFormat,
tUInt8 * pDestBitmapData,
const tBitmapFormat * psDestBitmapFormat,
tInt nFlags,
tUInt32 ui32Mask )
inlinestaticprotected

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.

Definition at line 3309 of file image.h.

◆ CountDifferences()

tInt CountDifferences ( const disptb::graphicslib::dengar::cImage & oImage)
inline

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

Definition at line 2522 of file image.h.

◆ Create() [1/2]

tResult Create ( const tBitmapFormat * psFormat,
const tColor * pPalette = nullptr,
const tUInt8 * pBitmap = nullptr )
inline

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

Definition at line 230 of file image.h.

◆ Create() [2/2]

tResult Create ( tInt nWidth,
tInt nHeight,
tInt nBitsPerPixel,
tInt nBytesPerLine = 0,
const tUInt8 * pBitmap = nullptr,
tInt nPixelFormat = 0 )
inline

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

Definition at line 186 of file image.h.

◆ Destroy()

tVoid Destroy ( )
inlinevirtual

Destroy the instance.

Implements IImage.

Definition at line 165 of file image.h.

◆ Flip()

tResult Flip ( )
inline

Flips the image upside down.

Return values
ERR_NOERRORif all went well
ERR_UNEXPECTEDif the image formats height is zero
ERR_MEMORYif internal memory allocation failed
ERR_POINTERif internal bitmap pointer is null

Definition at line 969 of file image.h.

◆ FlipAlpha()

tResult FlipAlpha ( )
inline

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

Definition at line 1494 of file image.h.

◆ FlipRGB()

tResult FlipRGB ( )
inline

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

Definition at line 1468 of file image.h.

◆ FlipRGBFormat()

static tInt FlipRGBFormat ( tInt nPixelFormat)
inlinestatic

Returns the format with flipped RGB.

Example: PF_RGB_888 gets flipped to PF_BGR_888

Parameters
nPixelFormat[in] The new pixel format, see tPixelFormat.
Returns
the opposite RGB format, see tPixelFormat.

Definition at line 635 of file image.h.

◆ FlipToBGRFormat()

static tInt FlipToBGRFormat ( tInt nPixelFormat)
inlinestatic

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 tPixelFormat.
Returns
the associated BGR format, see tPixelFormat.

Definition at line 664 of file image.h.

◆ FlipToRGBFormat()

static tInt FlipToRGBFormat ( tInt nPixelFormat)
inlinestatic

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 tPixelFormat.
Returns
the associated RGB format, see tPixelFormat.

Definition at line 687 of file image.h.

◆ Free()

tResult Free ( )
inlineprotected

Frees the image's bitmap buffer.

Returns
Standard result code.

Definition at line 2916 of file image.h.

◆ FreeBitmapInfo()

tResult FreeBitmapInfo ( )
inlineprotected

Free space from bitmap info.

Returns
Standard result code.

Definition at line 3089 of file image.h.

◆ FreeImpl()

tResult FreeImpl ( tHandle hMemory)
inlineprotected

Internal implementation of the free function.

Parameters
hMemory[in] Memory handle.
Returns
Standard result code.

Definition at line 2976 of file image.h.

◆ FreePalette()

tResult FreePalette ( )
inlineprotected

Frees space from palette.

Returns
Standard result code.

Definition at line 3016 of file image.h.

◆ GetBitmap()

tUInt8 * GetBitmap ( ) const
inlinevirtual

Returns a pointer to the raw data.

Returns
a pointer to the raw data. NULL if image is not initialised.

Implements IImage.

Definition at line 897 of file image.h.

◆ GetBitmapInfo()

tWin32BitmapInfo * GetBitmapInfo ( )
inlineoverridevirtual

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.

Definition at line 923 of file image.h.

◆ GetBitmapInfoSize()

tInt GetBitmapInfoSize ( )
inline

Returns the size of the Win32 image descriptor.

Returns
The size of the Win32 image descriptor.

Definition at line 941 of file image.h.

◆ GetBitmapLine()

tUInt8 * GetBitmapLine ( tInt y) const
inlinevirtual

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

Implements IImage.

Definition at line 911 of file image.h.

◆ GetBits()

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

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

Implements IImage.

Definition at line 1688 of file image.h.

◆ GetBitsPerPixel()

tInt GetBitsPerPixel ( ) const
inlinevirtual

Returns the bits per pixel of the image.

Returns
The bits per pixel of the image.

Implements IImage.

Definition at line 727 of file image.h.

◆ GetBitsPerPixelFromFormat()

static tInt GetBitsPerPixelFromFormat ( tInt nFormat)
inlinestatic

Retrieve image resolution from image format.

Parameters
nFormat[in] Image format.
Returns
Image resolution.

Definition at line 2635 of file image.h.

◆ GetBytesPerLine()

tInt GetBytesPerLine ( ) const
inlinevirtual

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.

Implements IImage.

Definition at line 739 of file image.h.

◆ GetDefaultFormatFromBpp()

static tInt GetDefaultFormatFromBpp ( tInt nBpp)
inlinestatic

Retrieve image format based on image resolution.

Parameters
nBpp[in] Image resolution.
Returns
Image format.

Definition at line 2647 of file image.h.

◆ GetFormat()

const tBitmapFormat * GetFormat ( ) const
inlineoverridevirtual

Returns the current bitmap format of the image.

See also
tBitmapFormat
Returns
Pointer to the current bitmap format of the image.

Implements IImage.

Definition at line 776 of file image.h.

◆ GetHeight()

tInt GetHeight ( ) const
inlinevirtual

Returns the height of the image.

Returns
The height of the image.

Implements IImage.

Definition at line 717 of file image.h.

◆ GetNextPowerOfTwo()

static int32_t GetNextPowerOfTwo ( int32_t const a)
inlinestatic

Definition at line 4415 of file image.h.

◆ GetPalette()

tColor * GetPalette ( ) const
inlinevirtual

Returns the color palette.

Returns
The color palette.

Implements IImage.

Definition at line 838 of file image.h.

◆ GetPaletteEntry()

tColor GetPaletteEntry ( tInt nIdx) const
inlinevirtual

Returns a color palette entry.

  • Parameters
    nIdx[in] The index of the entry, starting at 0.
    Returns
    The color palette entry.

Implements IImage.

Definition at line 860 of file image.h.

◆ GetPaletteSize()

tInt GetPaletteSize ( ) const
inlinevirtual

Returns the color palette size.

Returns
The color palette size.

Implements IImage.

Definition at line 848 of file image.h.

◆ GetPixelFormat()

tInt GetPixelFormat ( ) const
inlinevirtual

Returns the pixel format.

Returns
The pixel format, see tPixelFormat.

Implements IImage.

Definition at line 611 of file image.h.

◆ GetPixelFormatIdentifier()

static tChar const * GetPixelFormatIdentifier ( const tInt nImage)
inlinestatic

Returns the image format as string (enum to string)

Parameters
nImage[in] Image format.
Returns
pixel identifier as string.

Definition at line 2666 of file image.h.

◆ GetPixelFormatStr()

char const * GetPixelFormatStr ( ) const
inline

Retrieves the image's pixel format as string.

Returns
Returns the image's pixel format as human readable string.

Definition at line 623 of file image.h.

◆ GetRatio()

tFloat64 GetRatio ( ) const
inlinevirtual

Returns the aspect ratio of the image.

Returns
The aspect ratio of the image.

Implements IImage.

Definition at line 759 of file image.h.

◆ GetSize()

tInt GetSize ( ) const
inlinevirtual

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

Implements IImage.

Definition at line 749 of file image.h.

◆ GetWidth()

tInt GetWidth ( ) const
inlinevirtual

Returns the width of the image.

Returns
The width of the image.

Implements IImage.

Definition at line 707 of file image.h.

◆ GreenValue()

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.

Definition at line 2147 of file image.h.

◆ GuessPixelFormat()

static tInt GuessPixelFormat ( const tBitmapFormat * pFormat)
inlinestatic

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.

Definition at line 2603 of file image.h.

◆ Initialize()

tResult Initialize ( )
inlineprotected

Initialize the image.

Returns
Standard result code.

Definition at line 2859 of file image.h.

◆ Load()

tResult Load ( const tChar * strFile,
tUInt32 nFlags = 0 )
inline

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 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

Definition at line 364 of file image.h.

◆ MakeAlphaChannel()

tResult MakeAlphaChannel ( const tColor & sColorKey,
tBool bClearTransparent = tFalse )
inline

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

Definition at line 1574 of file image.h.

◆ Mirror()

tResult Mirror ( )
inline

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

Definition at line 1010 of file image.h.

◆ NeedAlphaBlend()

static bool NeedAlphaBlend ( int32_t const oPixelFormat)
inlinestatic

Definition at line 4495 of file image.h.

◆ operator IImage *()

operator IImage * ( )
inline

instance of IImage

Returns
object

Definition at line 955 of file image.h.

◆ operator=()

Set the current image to the image oImage.

Parameters
oImage[in] Given Image.
Returns
Returns a reference to the given image.

Definition at line 4403 of file image.h.

◆ RedValue()

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.

Definition at line 2135 of file image.h.

◆ Release()

tResult Release ( )
inline

Frees all allocated resources.

Returns
always returns ERR_NOERROR

Definition at line 585 of file image.h.

◆ Resize()

tResult Resize ( tInt nWidth,
tInt nHeight )
inline

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

Definition at line 1128 of file image.h.

◆ Save()

tResult Save ( const tChar * strFile)
inline

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
ERR_NOT_IMPLif this function is called in non WIN32 environments.

Definition at line 458 of file image.h.

◆ SetBits()

tResult SetBits ( const tUInt8 * pSrcBitmapData,
const tBitmapFormat * psSrcBitmapFormat )
inline

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_POINTERif pSrcBitmapData or psSrcBitmapFormat
ERR_MEMORYif a problem occured during creation of new image buffer
ERR_NOERRORif all went well

Definition at line 1660 of file image.h.

◆ SetPalette()

tResult SetPalette ( tInt nPaletteSize,
const tColor * pPalette )
inline

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

Definition at line 791 of file image.h.

◆ SetPaletteEntry()

tResult SetPaletteEntry ( tInt nIdx,
const tColor & sColor )
inline

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

Definition at line 880 of file image.h.

◆ SetPixelFormat()

tResult SetPixelFormat ( tInt nPixelFormat)
inline

Sets the pixel format used.

Does NOT perform a conversion.

Parameters
nPixelFormat[in] The new pixel format, see tPixelFormat.
Returns
Always returns ERR_NOERROR.

Definition at line 599 of file image.h.

◆ SetTransparency()

static tResult SetTransparency ( disptb::graphicslib::dengar::cImage * pImage,
disptb::graphicslib::dengar::cColor oColor )
inlinestatic

Helper method for setting transparency in bitmaps.

(BMP doesn't know anything about transparency) The alpha channel for all pixels with the given color will be set to 0. If the images is of format other than PF_RGBA_8888 and PF_BGRA_8888 it will be converted to PF_RGBA_8888.

Parameters
pImage[in/out] Pointer to the image which gets transparent pixels
oColor[in] The color of the pixels which will converted to transparent
Returns
ERR_INVALID_FORMAT if an image with not supported format is passed ERR_POINTER if either pImage, pImage->GetBitmap() or pImage->GetBitmapInfo() is NULL ERR_NOERROR if succeeded

Definition at line 2081 of file image.h.

◆ StretchBlit() [1/2]

static tResult StretchBlit ( const disptb::graphicslib::dengar::cImage & oSrcImage,
const disptb::graphicslib::dengar::cImage & oDestImage,
tInt nFlags = 0 )
inlinestatic

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

Definition at line 1755 of file image.h.

◆ StretchBlit() [2/2]

static tResult StretchBlit ( const tUInt8 * pSrcBitmapData,
const tBitmapFormat * psSrcBitmapFormat,
tUInt8 * pDestBitmapData,
const tBitmapFormat * psDestBitmapFormat,
tInt nFlags = 0 )
inlinestatic

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

Definition at line 1780 of file image.h.

◆ StretchBlit_impl()

static tResult StretchBlit_impl ( const tUInt8 * pSrcBitmapData,
const tBitmapFormat * psSrcBitmapFormat,
tUInt8 * pDestBitmapData,
const tBitmapFormat * psDestBitmapFormat,
tInt nFlags,
tUInt32 ui32Mask = 0x0 )
inlinestaticprotected

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.

Definition at line 3182 of file image.h.

◆ UFromRGB()

tUInt8 UFromRGB ( tUInt8 * pPixel)
inlineprotected

Definition at line 4542 of file image.h.

◆ VFromRGB()

tUInt8 VFromRGB ( tUInt8 * pPixel)
inlineprotected

Definition at line 4547 of file image.h.

◆ YFromRGB()

tUInt8 YFromRGB ( tUInt8 * pPixel)
inlineprotected

Definition at line 4537 of file image.h.

◆ Yuv2Rgb()

void Yuv2Rgb ( tUInt8 y,
tUInt8 u,
tUInt8 v,
tUInt8 * pPixel )
inlineprotected

Definition at line 4524 of file image.h.

Member Data Documentation

◆ m_bReference

tBool m_bReference
protected

flag indicating the m_pBitmap pointer is used as a reference

Definition at line 114 of file image.h.

◆ m_hBitmapMemory

tHandle m_hBitmapMemory
protected

Handle for bitmap memory.

Definition at line 122 of file image.h.

◆ m_nBitmapInfoSize

tInt m_nBitmapInfoSize
protected

size of windows bitmap info

Definition at line 118 of file image.h.

◆ m_nDefaultLineAlignment

tInt m_nDefaultLineAlignment = 4
inlinestatic

the default line alignment, currently power of 2

Definition at line 111 of file image.h.

◆ m_nDefaultMemoryAlignment

tInt m_nDefaultMemoryAlignment = 16
inlinestatic

the default memory alignment used, currently 16

Definition at line 110 of file image.h.

◆ m_nGreyPaletteSize

tInt m_nGreyPaletteSize
protected

size of palette

Definition at line 124 of file image.h.

◆ m_pBitmap

tUInt8* m_pBitmap
protected

actual pixel data, may be reference to data of other pic

Definition at line 121 of file image.h.

◆ m_pPalette

tColor* m_pPalette
protected

array of colors making up the palette

Definition at line 120 of file image.h.

◆ m_psBitmapInfo

tWin32BitmapInfo* m_psBitmapInfo
protected

current bitmap info, windows style

Definition at line 117 of file image.h.

◆ m_sFormat

tBitmapFormat m_sFormat
protected

current format of bitmap

Definition at line 116 of file image.h.