13 #include <adtf_base.h>
100 tResult
Create(tInt nWidth, tInt nHeight, tInt nBitsPerPixel, tInt nBytesPerLine = 0,
const tUInt8* pBitmap =
nullptr,
101 tInt nPixelFormat = 0);
117 tResult
Create(
const tBitmapFormat* psFormat,
const tColor* pPalette =
nullptr,
const tUInt8* pBitmap =
nullptr);
133 tResult
Attach(tUInt8* pBitmap, tInt nWidth, tInt nHeight, tInt nBitsPerPixel, tInt nBytesPerLine = 0);
170 tResult
Load(
const tChar* strFile, tUInt32 nFlags = 0);
186 tResult
Save(
const tChar* strFile);
302 tResult
SetPalette(tInt nPaletteSize,
const tColor* pPalette);
379 return dynamic_cast<IImage*
>(
this);
418 tResult
Resize(tInt nWidth, tInt nHeight);
436 tResult
ChangeDepth(tInt nBitsPerPixel, tInt nBytesPerLine = 0, tUInt32 ui32Mask = 0x0);
452 tResult
Convert(tInt nWidth, tInt nHeight, tInt nBitsPerPixel, tInt nBytesPerLine = 0, tUInt32 ui32Mask = 0x0);
603 static tResult
Blit(
const tUInt8* pSrcBitmapData,
605 tUInt8* pDestBitmapData,
647 tUInt8* pDestBitmapData,
684 static tResult
Convert(
const tUInt8* pSrcBitmapData,
686 tUInt8* pDestBitmapData,
741 return ((tUInt8) (nColor));
753 return ((tUInt8) (((tUInt16) (nColor)) >> 8));
765 return ((tUInt8) ((nColor) >> 16));
777 static inline tFloat64
Brightness(tFloat64 fRed, tFloat64 fGreen, tFloat64 fBlue)
779 return (0.114 * fRed + 0.587 * fGreen + 0.299 * fBlue);
793 return 116 * nRed + 602 * nGreen + 306 * nBlue;
805 static inline tUInt8
Brightness(tInt nRed, tInt nGreen, tInt nBlue)
848 tResult LoadResource(tInt nResourceId, tHandle hModule=NULL, tUInt32 nFlags=0);
863 tResult CaptureScreen(tInt x, tInt y, tInt nWidth, tInt nHeight);
872 tHandle CreateRegion();
973 tResult
AllocImpl(tInt nSize, tHandle* hMemory, tVoid** pBuffer);
1028 tUInt8* pDestBitmapData,
1046 tUInt8* pDestBitmapData,
1049 tUInt32 ui32Mask = 0x0);
1066 tUInt8* pDestBitmapData,
Image and bitmap handling.
Image and bitmap handling.
static tInt m_nDefaultLineAlignment
the default line alignment, currently power of 2
static tResult SetTransparency(disptb::graphicslib::dengar::cImage *pImage, disptb::graphicslib::dengar::cColor oColor)
Helper method for setting transparency in bitmaps.
tUInt8 * GetBitmapLine(tInt y) const
Returns a pointer to raw data of a line.
tResult SetPalette(tInt nPaletteSize, const tColor *pPalette)
Sets a color palette.
static tInt CalcAlignedMemSize(tInt nBytes, tInt nAlignment)
Calculate the size of a given number of bytes to match a given alignment.
disptb::graphicslib::dengar::cImage & operator=(const disptb::graphicslib::dengar::cImage &oImage)
Set the current image to the image oImage.
tResult FreeBitmapInfo()
Free space from bitmap info.
tResult Convert(tInt nWidth, tInt nHeight, tInt nBitsPerPixel, tInt nBytesPerLine=0, tUInt32 ui32Mask=0x0)
Converts the image to new dimensions and color depth.
tResult Save(const tChar *strFile)
Saves the image to a file.
static tInt GuessPixelFormat(const tBitmapFormat *pFormat)
Tries to guess the PixelFormat based on the other parameters of a bitmap format.
cImage()
Default constructor.
tInt GetBitmapInfoSize()
Returns the size of the Win32 image descriptor.
tResult Alloc(const tBitmapFormat *psFormat)
Allocates the image's bitmap buffer.
tBool Compare(const disptb::graphicslib::dengar::cImage &oImage)
Compares the bitmaps of two images.
static tInt GetDefaultFormatFromBpp(tInt nBpp)
Retrieve image format based on image resolution.
static tResult BilinearStretchBlit(disptb::graphicslib::dengar::cImage &oSrc, disptb::graphicslib::dengar::cImage &oDest)
Copies an image to another using the bilinear algorithm.
tResult Resize(tInt nWidth, tInt nHeight)
Resizes the image to the new height nHeight and width nWidth.
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 tInt FlipToBGRFormat(tInt nPixelFormat)
Returns the pixel format flipped to BGR.
tInt GetPixelFormat() const
Returns the pixel format.
tResult FlipAlpha()
Flips the alpha part from left to right and back:ARGB <-> RGBA and ABGR <-> BGRA.
tUInt8 * m_pBitmap
actual pixel data, may be reference to data of other pic
tInt m_nBitmapInfoSize
size of windows bitmap info
virtual ~cImage()
Destructor.
tResult Attach(tUInt8 *pBitmap, const tBitmapFormat *psFormat, const tColor *pPalette=nullptr)
Attaches an image reference.
tWin32BitmapInfo * m_psBitmapInfo
current bitmap info, windows style
tResult Free()
Frees the image's bitmap buffer.
static tFloat64 Brightness(tFloat64 fRed, tFloat64 fGreen, tFloat64 fBlue)
Calculates the bringhtness value of a color.
tInt m_nGreyPaletteSize
size of palette
static tResult StretchBlit_impl(const tUInt8 *pSrcBitmapData, const tBitmapFormat *psSrcBitmapFormat, tUInt8 *pDestBitmapData, const tBitmapFormat *psDestBitmapFormat, tInt nFlags, tUInt32 ui32Mask=0x0)
Internal blitting operation.
tResult FlipRGB()
Flips RGB to BGR and the other way around.
cImage(const cImage &oImage)
Copy constructor.
tResult Attach(tUInt8 *pBitmap, tInt nWidth, tInt nHeight, tInt nBitsPerPixel, tInt nBytesPerLine=0)
Attaches an image reference.
tResult SetPixelFormat(tInt nPixelFormat)
Sets the pixel format used.
tInt GetBytesPerLine() const
Returns the bytes per line of the image.
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 tInt GetBitsPerPixelFromFormat(tInt nFormat)
Retrieve image resolution from image format.
static tResult Blit_impl(const tUInt8 *pSrcBitmapData, const tBitmapFormat *psSrcBitmapFormat, tUInt8 *pDestBitmapData, const tBitmapFormat *psDestBitmapFormat, tInt nFlags)
Internal blitting operation.
static tUInt8 RedValue(tUInt32 nColor)
Returns the red component of a color.
tResult AllocPalette(tInt nPaletteSize)
Allocate space for a palette.
tUInt8 * GetBitmap() const
Returns a pointer to the raw data.
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 ...
tInt GetWidth() const
Returns the width of the image.
tResult GetBits(tUInt8 *pDestBitmapData, const tBitmapFormat *psDestBitmapFormat, tInt nFlags=0)
Retrieves the image's bitmap data.
tResult FreePalette()
Frees space from palette.
tResult Create(tInt nWidth, tInt nHeight, tInt nBitsPerPixel, tInt nBytesPerLine=0, const tUInt8 *pBitmap=nullptr, tInt nPixelFormat=0)
Creates a new image.
static tInt FlipToRGBFormat(tInt nPixelFormat)
Returns the pixel format flipped to RGB.
tColor GetPaletteEntry(tInt nIdx) const
Returns a color palette entry.
tInt GetPaletteSize() const
Returns the color palette size.
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.
tResult Create(const tBitmapFormat *psFormat, const tColor *pPalette=nullptr, const tUInt8 *pBitmap=nullptr)
Creates a new image from a bitmap format description.
tColor * GetPalette() const
Returns the color palette.
tResult Release()
Frees all allocated resources.
tResult Flip()
Flips the image upside down.
tResult AllocBitmapInfo()
Allocate space for bitmap info.
tResult ChangeDepth(tInt nBitsPerPixel, tInt nBytesPerLine=0, tUInt32 ui32Mask=0x0)
Changes the color depth.
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.
tResult Mirror()
Mirrors the image.
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.
tResult SetBits(const tUInt8 *pSrcBitmapData, const tBitmapFormat *psSrcBitmapFormat)
Sets the image's bitmap data.
tInt CountDifferences(const disptb::graphicslib::dengar::cImage &oImage)
Compares the bitmaps of two images and counts the amount of different pixels.
static tUInt8 GreenValue(tUInt32 nColor)
Returns the green component of a color.
tResult FreeImpl(tHandle hMemory)
Internal implementation of the free function.
tVoid Destroy()
Destroy the instance.
tResult AllocImpl(tInt nSize, tHandle *hMemory, tVoid **pBuffer)
Internal implementation of the allocation function.
tBool m_bReference
flag indicating the m_pBitmap pointer is used as a reference
static tInt m_nDefaultMemoryAlignment
the default memory alignment used, currently 16
tWin32BitmapInfo * GetBitmapInfo() override
Generates a Win32 image descriptor.
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 ...
static tInt FlipRGBFormat(tInt nPixelFormat)
Returns the format with flipped RGB.
tResult Initialize()
Initialize the image.
static tUInt8 Brightness(tColor nColor)
Calculates the bringhtness value of a color.
tColor * m_pPalette
array of colors making up the palette
const tBitmapFormat * GetFormat() const override
Returns the current bitmap format of the image.
tHandle m_hBitmapMemory
Handle for bitmap memory.
tResult Blit(const cImage &oDestImage, tInt nFlags=0)
Copies bitmap data from one image to another.
tResult Load(const tChar *strFile, tUInt32 nFlags=0)
Loads an image from a file.
static tUInt8 BlueValue(tUInt32 nColor)
Returns the blue component of a color.
tResult Convert(const tBitmapFormat *psFormat, tUInt32 ui32Mask=0x0)
Converts the image to a new image format.
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.
tInt GetHeight() const
Returns the height of the image.
tInt GetSize() const
Returns the size of the image in bytes.
static tUInt8 Brightness(tInt nRed, tInt nGreen, tInt nBlue)
Calculates the bringhtness value of a color.
tResult SetPaletteEntry(tInt nIdx, const tColor &sColor)
Sets an entry of the color palette.
A_UTILS_D(cImage)
D-Pointer implementation.
tResult MakeAlphaChannel(const tColor &sColorKey, tBool bClearTransparent=tFalse)
Creates an alpha channel.
tResult ChangePixelFormat(tInt nFormat, tUInt32 ui32Flags=0)
Changes the pixel format used.
tFloat64 GetRatio() const
Returns the aspect ratio of the image.
tInt GetBitsPerPixel() const
Returns the bits per pixel of the image.
tBitmapFormat m_sFormat
current format of bitmap
static tChar const *const GetPixelFormatIdentifier(const tInt nImage)
Returns the image format as string (enum to string)
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Struct to get the informations and the color about a bitmap.