ADTF_DISPLAY_TOOLBOX
3.8.0 (ADTF 3.14.3)
|
Image and bitmap handling. More...
Public Member Functions | |
cImage () | |
Default constructor. | |
cImage (const cImage &oImage) | |
Copy constructor. More... | |
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. More... | |
tResult | Create (const tBitmapFormat *psFormat, const tColor *pPalette=nullptr, const tUInt8 *pBitmap=nullptr) |
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=nullptr) |
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 tBitmapFormat * | GetFormat () const override |
Returns the current bitmap format of the image. More... | |
tResult | SetPalette (tInt nPaletteSize, const tColor *pPalette) |
Sets a color palette. More... | |
tColor * | GetPalette () 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... | |
tUInt8 * | GetBitmap () const |
Returns a pointer to the raw data. More... | |
tUInt8 * | GetBitmapLine (tInt y) const |
Returns a pointer to raw data of a line. More... | |
tWin32BitmapInfo * | GetBitmapInfo () override |
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. More... | |
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 disptb::graphicslib::dengar::cImage &oImage) |
Compares the bitmaps of two images. More... | |
tInt | CountDifferences (const disptb::graphicslib::dengar::cImage &oImage) |
Compares the bitmaps of two images and counts the amount of different pixels. More... | |
disptb::graphicslib::dengar::cImage & | operator= (const disptb::graphicslib::dengar::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 disptb::graphicslib::dengar::cImage &oSrcImage, const disptb::graphicslib::dengar::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 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). 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 (disptb::graphicslib::dengar::cImage *pSourceImage, disptb::graphicslib::dengar::cImage *pDestImage, disptb::graphicslib::dengar::cImage *pMaskImage) |
Alpha blends an image to a destination image. More... | |
static tResult | BilinearStretchBlit (disptb::graphicslib::dengar::cImage &oSrc, disptb::graphicslib::dengar::cImage &oDest) |
Copies an image to another using the bilinear algorithm. More... | |
static tResult | SetTransparency (disptb::graphicslib::dengar::cImage *pImage, disptb::graphicslib::dengar::cColor oColor) |
Helper method for setting transparency in bitmaps. 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 (const tInt 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 | |
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 | |
Private Member Functions | |
A_UTILS_D (cImage) | |
D-Pointer implementation. | |
Additional Inherited Members | |
![]() | |
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... | |
Image and bitmap handling.
The cImage class encapsulates basic image handling methods.
Copy constructor.
oImage | [in] the other instance of cImage. |
|
protected |
Allocates the image's bitmap buffer.
psFormat | [in] Specifies the image format. |
|
protected |
Allocate space for bitmap info.
|
protected |
Internal implementation of the allocation function.
nSize | [in] Size of allocation. |
hMemory | [in] Memory handle. |
pBuffer | [in] Destination buffer. |
|
protected |
Allocate space for a palette.
nPaletteSize | [in] Size of palette. |
|
static |
Alpha blends an image to a destination image.
pSourceImage | [in] The source image. |
pDestImage | [in] The destination image. |
pMaskImage | [in] The image that contains the alpha mask to use. |
ERR_NOT_SUPPORTED | if pSourceImage or pDestImage are not PF_RGB_888, PF_BGR_888, PF_RGBA or PF_BGRA |
ERR_NOERROR | if all went well |
tResult Attach | ( | tUInt8 * | pBitmap, |
const tBitmapFormat * | psFormat, | ||
const tColor * | pPalette = nullptr |
||
) |
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.
pBitmap | [in] The external bitmap. |
psFormat | [in] The format description of the bitmap. |
pPalette | [in] An optional color palette array. |
ERR_NOERRO | if all went well |
ERR_FAILED | if a palette is provided, but bits per pixel is not 8 |
ERR_MEMORY | if memory allocation for the palette failed |
ERR_NOERROR | if all went well |
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.
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. |
ERR_POINTER | if pBitmap is NULL. |
ERR_NOERROR | if all went well |
|
static |
Copies an image to another using the bilinear algorithm.
oSrc | [in] The source image. |
oDest | [in] The destination image. |
ERR_POINTER | if either source or destination have no bitmap data or format data |
ERR_NOERROR | if all went well |
ERR_ERR_NOT_SUPPORTED | if the pixelformat is not either PF_RGB_888 or PF_RGBA_8888 |
ERR_NOT_IMPL | if 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.
oDestImage | [in] Specifies the destination image. |
nFlags | [in] Flags, see tBlitFlags |
ERR_NOERROR | if all went well. |
ERR_NOT_SUPPORTED | if the blit needed a nont supported conversion |
ERR_POINTER | if any of the input pointer was NULL |
|
static |
Copies bitmap data from one image to another.
The Blit method copies bitmap data from one image to another.
oSrcImage | [in] Specifies the source image. |
oDestImage | [in] Specifies the destination image. |
nFlags | [in] Flags, see tBlitFlags |
ERR_NOERROR | if all went well. |
ERR_NOT_SUPPORTED | if the blit needed a nont supported conversion |
ERR_POINTER | if any of the input pointer was NULL |
|
static |
Copies bitmap data from one image to another.
The Blit method copies bitmap data from one image to another.
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 |
ERR_NOERROR | if all went well. |
ERR_NOT_SUPPORTED | if the blit needed a nont supported conversion |
ERR_POINTER | if any of the input pointer was NULL |
|
staticprotected |
Internal blitting operation.
pSrcBitmapData | [in] Source bitmap data. |
psSrcBitmapFormat | [in] Source bitmap format. |
pDestBitmapData | [in] Destination bitmap data. |
psDestBitmapFormat | [in] Destination bitmap format. |
nFlags | [in] Blitting flags. |
|
inlinestatic |
Returns the blue component of a color.
nColor | [in] The color. |
Definition at line 763 of file image.h.
Referenced by cImage::Brightness().
|
inlinestatic |
Calculates the bringhtness value of a color.
nColor | [in] The color. |
Definition at line 817 of file image.h.
References cImage::BrightnessValue().
|
inlinestatic |
|
inlinestatic |
Calculates the bringhtness value of a color.
nRed | [in] The red component. |
nGreen | [in] The green component. |
nBlue | [in] The blue component. |
Definition at line 805 of file image.h.
References cImage::BrightnessValue().
|
inlinestatic |
Calculates the bringhtness value of a color.
nColor | [in] The color as RGBA. |
Definition at line 829 of file image.h.
References cImage::BlueValue(), cImage::BrightnessValue(), cImage::GreenValue(), and cImage::RedValue().
|
inlinestatic |
Calculates the bringhtness value of a color without scaling it down.
nRed | [in] The red component. |
nGreen | [in] The green component. |
nBlue | [in] The blue component. |
Definition at line 791 of file image.h.
Referenced by cImage::Brightness().
|
static |
Calculate the size of a given number of bytes to match a given alignment.
nBytes | number of bytes to align |
nAlignment | bytes to align with. |
tResult ChangeDepth | ( | tInt | nBitsPerPixel, |
tInt | nBytesPerLine = 0 , |
||
tUInt32 | ui32Mask = 0x0 |
||
) |
Changes the color depth.
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. |
ERR_NOERROR | if all went well |
ERR_MEMORY | if memory reallocation failed |
ERR_POINTER | if 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
nFormat | [in] The new pixel format tPixelFormat. |
ui32Flags | unused |
ERR_NOT_SUPPORTED | if conversion is not supported. |
ERR_NOERROR | if all went well |
tBool Compare | ( | const disptb::graphicslib::dengar::cImage & | oImage | ) |
Compares the bitmaps of two images.
The format of both images must be the same.
oImage | The image for comparison |
tResult Convert | ( | const tBitmapFormat * | psFormat, |
tUInt32 | ui32Mask = 0x0 |
||
) |
Converts the image to a new image format.
psFormat | [in] The new format. |
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 |
ERR_POINTER | if psFormat is NULL |
ERR_INVAILD_ARGUMENT | if nWidth or nHeight <= 0 |
ERR_MEMORY | if memory reallocation failed |
ERR_POINTER | if no image has been created, attached or loaded yet |
ERR_NOERROR | if all went well |
|
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
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 |
ERR_NOERROR | if all went well. |
ERR_NOT_SUPPORTED | if conversio is not supported. |
tResult Convert | ( | tInt | nWidth, |
tInt | nHeight, | ||
tInt | nBitsPerPixel, | ||
tInt | nBytesPerLine = 0 , |
||
tUInt32 | ui32Mask = 0x0 |
||
) |
Converts the image to new dimensions and color depth.
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. |
ERR_INVAILD_ARGUMENT | if nWidth or nHeight <= 0 |
ERR_MEMORY | if memory reallocation failed |
ERR_POINTER | if no image has been created, attached or loaded yet |
ERR_NOERROR | if all went well |
|
staticprotected |
will convert the bitmap from one format to another one.
[in] | nFlags | additional flags, allowed values
|
[in] | pSrcBitmapData | pointer to the source bitmap Data |
[in] | psSrcBitmapFormat | pointer to the bitmap format description |
[in] | pDestBitmapData | pointer to the destination bitmap |
[in] | psDestBitmapFormat | pointer to the destination bitmap format description |
[in] | ui32Mask | mask for bit conversions |
tInt CountDifferences | ( | const disptb::graphicslib::dengar::cImage & | oImage | ) |
Compares the bitmaps of two images and counts the amount of different pixels.
The format of both images must be the same.
oImage | The image for comparison |
tResult Create | ( | const tBitmapFormat * | psFormat, |
const tColor * | pPalette = nullptr , |
||
const tUInt8 * | pBitmap = nullptr |
||
) |
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.
psFormat | [in] The format description. |
pPalette | [in] An optional color palette array. |
pBitmap | [in] A bitmap that the image data should be initialized with. |
ERR_POINTER | if psFormat is NULL |
ERR_MEMORY | if memory allocation for the data buffer failed |
ERR_NOERROR | if all went well |
tResult Create | ( | tInt | nWidth, |
tInt | nHeight, | ||
tInt | nBitsPerPixel, | ||
tInt | nBytesPerLine = 0 , |
||
const tUInt8 * | pBitmap = nullptr , |
||
tInt | nPixelFormat = 0 |
||
) |
Creates a new image.
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 |
ERR_MEMORY | if memory allocation for the data buffer failed, else ERR_NOERROR |
ERR_NOERROR | if all went well |
tResult Flip | ( | ) |
Flips the image upside down.
ERR_NOERROR | if all went well |
ERR_UNEXPECTED | if the image formats height is zero |
ERR_MEMORY | if internal memory allocation failed |
ERR_POINTER | if internal bitmap pointer is null |
tResult FlipAlpha | ( | ) |
Flips the alpha part from left to right and back:ARGB <-> RGBA and ABGR <-> BGRA.
ERR_UNEXPECTED | if the BitsPerLine are zero |
ERR_NOT_SUPPORTED | if Format is not PF_ABGR_8888, PF_BGRA_8888, PF_ARGB_8888 or PF_ARGB_8888 |
tResult FlipRGB | ( | ) |
Flips RGB to BGR and the other way around.
ERR_NOT_SUPPORTED | if 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_NOERROR | if all went well |
|
static |
Returns the format with flipped RGB.
Example: PF_RGB_888 gets flipped to PF_BGR_888
nPixelFormat | [in] The new pixel format, see cImage::tPixelFormat. |
|
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
nPixelFormat | [in] The new pixel format, see cImage::tPixelFormat. |
|
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
nPixelFormat | [in] The new pixel format, see cImage::tPixelFormat. |
|
protected |
Frees the image's bitmap buffer.
|
protected |
Free space from bitmap info.
|
protected |
Internal implementation of the free function.
hMemory | [in] Memory handle. |
|
protected |
Frees space from palette.
|
virtual |
Returns a pointer to the raw data.
Implements IImage.
|
overridevirtual |
Generates a Win32 image descriptor.
The GetBitmapInfo method generates a Win32 image descriptor structure.
Implements IImage.
tInt GetBitmapInfoSize | ( | ) |
Returns the size of the Win32 image descriptor.
|
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!
y | [in] The line number, starting at 0. |
Implements IImage.
|
virtual |
Retrieves the image's bitmap data.
The GetBits method retrieves the image's bitmap data.
pDestBitmapData | [in] Specifies the destination bitmap data. |
psDestBitmapFormat | [in] Specifies the destination bitmap format. |
nFlags | [in] Flags, see tBlitFlags |
ERR_NOERROR | if all went well. |
ERR_POINTER | if oSrcBitmapData or pSrcBitmapFormat is NULL |
Implements IImage.
|
virtual |
|
static |
Retrieve image resolution from image format.
nFormat | [in] Image format. |
|
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
Implements IImage.
|
static |
Retrieve image format based on image resolution.
nBpp | [in] Image resolution. |
|
overridevirtual |
Returns the current bitmap format of the image.
Implements IImage.
|
virtual |
|
virtual |
|
virtual |
Returns a color palette entry.
nIdx | [in] The index of the entry, starting at 0. |
Implements IImage.
|
virtual |
|
virtual |
|
static |
Returns the image format as string (enum to string)
nImage | [in] Image format. |
|
virtual |
|
virtual |
Returns the size of the image in bytes.
Implements IImage.
|
virtual |
|
inlinestatic |
Returns the green component of a color.
nColor | [in] The color. |
Definition at line 751 of file image.h.
Referenced by cImage::Brightness().
|
static |
Tries to guess the PixelFormat based on the other parameters of a bitmap format.
[in] | pFormat | The input format to base the guess on. If the nPixelFormat member is set to something other than PF_UNKNOWN, this value is returned. |
|
protected |
Initialize the image.
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.
strFile | [in] The filename. |
nFlags | [in] Special Flags, see tLoadFlags. |
ERR_NOERROR | if all went well |
ERR_POINTER | if strFile is NULL |
ERR_NOERROR | if all went well. |
ERR_OPEN_FAILED | if the file could not be opened ( e.g. does not exist ) |
ERR_INVALID_FILE | if file could be opened but is no compatible bitmap |
ERR_NOT_SUPPORTED | if the file's bits per pixel is less than 8 |
ERR_MEMORY | if memory allocation for the buffer failed |
tResult MakeAlphaChannel | ( | const tColor & | sColorKey, |
tBool | bClearTransparent = tFalse |
||
) |
Creates an alpha channel.
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. |
ERR_NOERROR | if all went well. |
ERR_NOT_SUPPORTED | if no conversion could be found to convert to PF_RGBA_888 |
ERR_POINTER | if no image has been loaded, attached or created yet |
tResult Mirror | ( | ) |
Mirrors the image.
ERR_NOERROR | if all went well |
ERR_NOT_SUPPORTED | if executed on unsupported pixel format |
ERR_UNEXPECTED | if no bitmap data is associated |
|
inline |
disptb::graphicslib::dengar::cImage& operator= | ( | const disptb::graphicslib::dengar::cImage & | oImage | ) |
Set the current image to the image oImage.
oImage | [in] Given Image. |
|
inlinestatic |
Returns the red component of a color.
nColor | [in] The color. |
Definition at line 739 of file image.h.
Referenced by cImage::Brightness().
tResult Release | ( | ) |
Frees all allocated resources.
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().
nWidth | [in] The new width. |
nHeight | [in] The new height. |
ERR_NOERROR | if all went well. |
ERR_INVAILD_ARGUMENT | if nWidth or nHeight <= 0 |
ERR_MEMORY | if memory reallocation failed |
ERR_POINTER | if 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.
strFile | [in] The filename. |
ERR_NOERROR | if all went well |
ERR_POINTER | if strFile is NULL |
ERR_OPEN_FAILED | if the file could not be created |
ERR_DEVICE_IO | if there was an error while writing |
ERR_NOT_IMPL | if this function is called in non WIN32 environments. |
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.
pSrcBitmapData | [in] Specifies the source bitmap data. |
psSrcBitmapFormat | [in] Specifies the source bitmap format. |
ERR_POINTER | if pSrcBitmapData or psSrcBitmapFormat |
ERR_MEMORY | if a problem occured during creation of new image buffer |
ERR_NOERROR | if all went well |
tResult SetPalette | ( | tInt | nPaletteSize, |
const tColor * | pPalette | ||
) |
Sets a color palette.
nPaletteSize | [in] The size of the pPalette array |
pPalette | [in] The color palette array. If this is NULL, initialises palette as greyscale |
ERR_NOERROR | if all went well. |
ERR_NOT_SUPPORTED | if bits per pixel are not 8 |
ERR_MEMORY | if memory allocation for the palette failed |
tResult SetPaletteEntry | ( | tInt | nIdx, |
const tColor & | sColor | ||
) |
Sets an entry of the color palette.
nIdx | [in] The index of the entry, starting at 0. |
sColor | [in] The new color value. |
ERR_INVALID_ARG | if nIdx is not part of the palette |
ERR_NOERROR | if all went well |
tResult SetPixelFormat | ( | tInt | nPixelFormat | ) |
Sets the pixel format used.
Does NOT perform a conversion.
nPixelFormat | [in] The new pixel format, see cImage::tPixelFormat. |
|
static |
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.
pImage | [in/out] Pointer to the image which gets transparent pixels |
oColor | [in] The color of the pixels which will converted to transparent |
|
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).
oSrcImage | [in] Specifies the source image. |
oDestImage | [in] Specifies the destination image. |
nFlags | [in] Flags, see tBlitFlags |
ERR_NOERROR | if all went well. |
ERR_NO_SUPPORTED | if a pixelformat conversion was needed but was not supported |
|
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).
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 |
ERR_NOERROR | if all went well. |
ERR_NO_SUPPORTED | if a pixelformat conversion was needed but was not supported |
|
staticprotected |
Internal blitting operation.
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. |