41typedef tUInt32 DWORD_PTR;
44#define ALPHA_DEFAULT 0
47#define RGB565(R, G, B) (tUInt16)(((((tUInt16) B) >> 3) << 11) | ((((tUInt16) G) >> 2) << 5) | (((tUInt16) R) >> 3))
48#define GetRed_RGB565(RGB) (((RGB) & 0x1F) << 3)
49#define GetGreen_RGB565(RGB) ((((RGB) >> 5) & 0x3F) << 2)
50#define GetBlue_RGB565(RGB) (((RGB) >> 11) << 3)
52#define BGR565(R, G, B) (tUInt16)(((((tUInt16) R) >> 3) << 11) | ((((tUInt16) G) >> 2) << 5) | (((tUInt16) B) >> 3))
53#define GetRed_BGR565(RGB) (((RGB) >> 11) << 3)
54#define GetGreen_BGR565(RGB) ((((RGB) >> 5) & 0x3F) << 2)
55#define GetBlue_BGR565(RGB) (((RGB) & 0x1F) << 3)
57#define RGB555(R, G, B) (tUInt16)(((((tUInt16) B) >> 3) << 10) | ((((tUInt16) G) >> 3) << 5) | (((tUInt16) R) >> 3))
58#define GetRed_RGB555(RGB) (((RGB) & 0x1F) << 3)
59#define GetGreen_RGB555(RGB) ((((RGB) >> 5) & 0x1F) << 3)
60#define GetBlue_RGB555(RGB) (((RGB) >> 10) << 3)
62#define BGR555(R, G, B) (tUInt16)(((((tUInt16) R) >> 3) << 10) | ((((tUInt16) G) >> 3) << 5) | (((tUInt16) B) >> 3))
63#define GetRed_BGR555(RGB) (((RGB) >> 10) << 3)
64#define GetGreen_BGR555(RGB) ((((RGB) >> 5) & 0x1F) << 3)
65#define GetBlue_BGR555(RGB) (((RGB) & 0x1F) << 3)
67#define RGBA4444(R, G, B, A) \
68 (tUInt16)(((((tUInt16) A) >> 4) << 12) | ((((tUInt16) B) >> 4) << 8) | ((((tUInt16) G) >> 4) << 4) | \
70#define GetRed_RGBA4444(RGB) (((RGB) & 0xf) << 4)
71#define GetGreen_RGBA4444(RGB) ((RGB) & 0xf0)
72#define GetBlue_RGBA4444(RGB) (((RGB) & 0xf00) >> 4)
73#define GetAlpha_RGBA4444(RGB) (((RGB) & 0xf000) >> 8)
75#define ABGR4444(R, G, B, A) \
76 (tUInt16)(((((tUInt16) R) >> 4) << 12) | ((((tUInt16) G) >> 4) << 8) | ((((tUInt16) B) >> 4) << 4) | \
78#define GetRed_ABGR4444(RGB) (((RGB) & 0xf000) >> 8)
79#define GetGreen_ABGR4444(RGB) (((RGB) & 0xf00) >> 4)
80#define GetBlue_ABGR4444(RGB) ((RGB) & 0xf0)
81#define GetAlpha_ABGR4444(RGB) (((RGB) & 0xf) << 4)
83#define GET_REMAINDER(v, v1, v2, max) ((((max) + 1) * (v) * (v2)) / (v1) - ((max) + 1) * (((v) * (v2)) / (v1)))
189 tInt nBytesPerLine = 0,
190 const tUInt8* pBitmap =
nullptr,
191 tInt nPixelFormat = 0)
197 l_sFormat.
nPixelFormat = (nPixelFormat != 0) ?
static_cast<int16_t
>(nPixelFormat) :
199 l_sFormat.
nWidth = nWidth;
201 l_sFormat.
nBitsPerPixel =
static_cast<int16_t
>(nBitsPerPixel);
211 RETURN_IF_FAILED(
Create(&l_sFormat, NULL, pBitmap));
230 tResult
Create(
const tBitmapFormat* psFormat,
const tColor* pPalette =
nullptr,
const tUInt8* pBitmap =
nullptr)
234 RETURN_IF_POINTER_NULL(psFormat);
236 RETURN_IF_FAILED(
Alloc(psFormat));
238 if (pPalette != NULL)
276 tResult
Attach(tUInt8* pBitmap, tInt nWidth, tInt nHeight, tInt nBitsPerPixel, tInt nBytesPerLine = 0)
280 RETURN_IF_POINTER_NULL(pBitmap);
285 l_sFormat.
nWidth = nWidth;
287 l_sFormat.
nBitsPerPixel =
static_cast<int16_t
>(nBitsPerPixel);
296 RETURN_IF_FAILED(
Attach(pBitmap, &l_sFormat, NULL));
319 RETURN_IF_POINTER_NULL(pBitmap);
320 RETURN_IF_POINTER_NULL(psFormat);
326 if (pPalette != NULL)
364 tResult
Load(
const tChar* strFile, tUInt32 nFlags = 0)
367 RETURN_IF_POINTER_NULL(strFile)
374 adtf::util::cFile oFile;
375 RETURN_IF_FAILED(oFile.Open(strFile, adtf::util::cFile::OM_Read))
378 RETURN_IF_FAILED(oFile.ReadAll(&sFileHeader,
sizeof(sFileHeader)))
382 RETURN_ERROR(ERR_INVALID_FILE);
386 RETURN_IF_FAILED(oFile.ReadAll(&sBitmapHeader,
sizeof(sBitmapHeader)));
391 RETURN_ERROR(ERR_NOT_SUPPORTED);
395 tUInt16 nBytesPerLine =
404 RETURN_IF_FAILED(oFile.ReadAll(
m_pPalette, nPaletteBytes));
407 if (oFile.SetFilePos(sFileHeader.
ui32DataOffset, adtf::util::cFile::FP_Begin) == -1)
409 RETURN_ERROR(ERR_INVALID_FILE);
438 RETURN_IF_FAILED(
Flip());
458 tResult
Save(
const tChar* strFile)
476 return oImg.
Save(strFile);
501 return oImg.
Save(strFile);
520 return oImg.
Save(strFile);
523 adtf::util::cFile oFile;
524 tResult nResult = oFile.Open(strFile, adtf::util::cFile::OM_Write);
525 if (IS_FAILED(nResult))
530 tInt l_nPaletteSize =
m_sFormat.nPaletteSize;
536 tInt nPaletteBytes = l_nPaletteSize *
sizeof(tColor);
547 nResult = oFile.WriteAll(&sFileHeader,
sizeof(sFileHeader));
548 if (IS_FAILED(nResult))
556 if (IS_FAILED(nResult))
564 nResult = oFile.WriteAll(
m_pPalette, nPaletteBytes);
565 if (IS_FAILED(nResult))
573 nResult = oFile.WriteAll(
m_pBitmap, nBitmapBytes);
601 m_sFormat.nPixelFormat =
static_cast<int16_t
>(nPixelFormat);
637 switch (nPixelFormat)
666 switch (nPixelFormat)
689 switch (nPixelFormat)
761 tFloat64 l_fImageRatio = 1.0;
767 return l_fImageRatio;
791 tResult
SetPalette(tInt nPaletteSize,
const tColor* pPalette)
797 RETURN_ERROR(ERR_NOT_SUPPORTED);
800 if (nPaletteSize > 0)
804 if (pPalette != NULL)
806 adtf::util::cMemoryBlock::MemCopy(
m_pPalette, pPalette, nPaletteSize *
sizeof(*pPalette));
816 for (tInt l_nIdx = 0; l_nIdx < nPaletteSize; l_nIdx++)
818 l_nColValue = (tUInt8) ((l_nIdx * 255) / nPaletteSize);
820 (tUInt8) l_nColValue;
862 if (nIdx >= 0 && nIdx <
m_sFormat.nPaletteSize)
867 tColor l_sCol = {0, 0, 0, 0};
882 if (nIdx >= 0 && nIdx <
m_sFormat.nPaletteSize)
889 RETURN_ERROR(ERR_INVALID_ARG);
957 return dynamic_cast<IImage*
>(
this);
974 RETURN_ERROR(ERR_UNEXPECTED);
977 tUInt8* pLineBuffer =
new tUInt8[
m_sFormat.nBytesPerLine];
978 if (pLineBuffer == NULL)
980 RETURN_ERROR(ERR_MEMORY);
983 tInt nBytesPerLine =
m_sFormat.nBytesPerLine;
991 adtf::util::cMemoryBlock::MemCopy(pLineBuffer, pSrc, nBytesPerLine);
992 adtf::util::cMemoryBlock::MemCopy(pSrc, pDest, nBytesPerLine);
993 adtf::util::cMemoryBlock::MemCopy(pDest, pLineBuffer, nBytesPerLine);
999 delete[] pLineBuffer;
1015 RETURN_ERROR(ERR_UNEXPECTED);
1025 for (tInt y = 0; y <
m_sFormat.nHeight; y++)
1034 while (pLeft < pRight)
1046 tUInt16* pui16Left = (tUInt16*) pLeft;
1047 tUInt16* pui16Right = (tUInt16*) pRight;
1048 while (pui16Left < pui16Right)
1050 ui16Buf = *pui16Left;
1051 *pui16Left = *pui16Right;
1052 *pui16Right = ui16Buf;
1061 while (pLeft < pRight)
1087 tUInt32* pui32Left = (tUInt32*) pLeft;
1088 tUInt32* pui32Right = (tUInt32*) pRight;
1089 while (pui32Left < pui32Right)
1091 ui32Buf = *pui32Left;
1092 *pui32Left = *pui32Right;
1093 *pui32Right = ui32Buf;
1102 RETURN_ERROR(ERR_NOT_SUPPORTED);
1130 if ((nWidth < 1) || (nHeight < 1))
1132 RETURN_ERROR(ERR_INVALID_ARG);
1164 tResult
ChangeDepth(tInt nBitsPerPixel, tInt nBytesPerLine = 0, tUInt32 ui32Mask = 0x0)
1185 tResult
Convert(tInt nWidth, tInt nHeight, tInt nBitsPerPixel, tInt nBytesPerLine = 0, tUInt32 ui32Mask = 0x0)
1188 adtf::util::cMemoryBlock::MemSet(&sNewFormat, 0,
sizeof(sNewFormat));
1189 sNewFormat.
nWidth = nWidth;
1191 sNewFormat.
nBitsPerPixel =
static_cast<int16_t
>(nBitsPerPixel);
1193 return Convert(&sNewFormat, ui32Mask);
1212 RETURN_IF_POINTER_NULL(psFormat);
1226 RETURN_ERROR(ERR_INVALID_ARG);
1237 RETURN_IF_FAILED(oTempImage.
Create(&sNewFormat));
1238 tResult nResult = ERR_NOERROR;
1260 RETURN_IF_FAILED(nResult);
1286 fmt.
nBitsPerPixel = tInt16(CalcBitsPerPixelFromPixelFormat(oPixelFormat));
1313 m_sFormat.nPixelFormat =
static_cast<int16_t
>(fmt);
1318 LOG_ERROR(
"Got PF_UNKNOWN");
1319 RETURN_ERROR(ERR_UNKNOWN_FORMAT);
1327 auto nBpp =
static_cast<int32_t
>(CalcBitsPerPixelFromPixelFormat(nFormat));
1330 RETURN_ERROR(ERR_NOT_SUPPORTED);
1360 tUInt8* pU = pV + nYUPlaneSize;
1361 tInt nLineWidthUV = (
m_sFormat.nWidth + 1) / 2;
1362 tInt nLineWidthRGB =
m_sFormat.nBytesPerLine;
1363 tUInt8* pPixel = pRGB;
1364 for (tInt32 nY = 0; nY <
m_sFormat.nHeight; ++nY)
1366 for (tInt32 nX = 0; nX <
m_sFormat.nWidth; ++nX)
1368 Yuv2Rgb(pY[nX], pU[nX / 2], pV[nX / 2], pPixel + nX * 3);
1371 pPixel += nLineWidthRGB;
1390 m_sFormat.nPixelFormat =
static_cast<int16_t
>(nFormat);
1408 tInt nLineWidthRGB =
m_sFormat.nBytesPerLine;
1411 for (tInt32 nY = 0; nY <
m_sFormat.nHeight; ++nY)
1413 for (tInt32 nX = 0; nX <
m_sFormat.nWidth; ++nX)
1415 pY[nX] = YFromRGB(pRGBLine + nX * 3);
1417 pRGBLine += nLineWidthRGB;
1423 tUInt8* pU = pV + nYUPlaneSize;
1424 tInt nLineWidth = (
m_sFormat.nWidth + 1) / 2;
1425 nLineWidthRGB += nLineWidthRGB;
1426 for (tInt32 nY = 0; nY <
m_sFormat.nHeight; nY += 2)
1428 for (tInt32 nX = 0; nX <
m_sFormat.nWidth; nX += 2)
1430 tUInt8* pPixel = pRGBLine + nX * 3;
1431 pU[nX / 2] = UFromRGB(pPixel);
1432 pV[nX / 2] = VFromRGB(pPixel);
1434 pRGBLine += nLineWidthRGB;
1447 m_sFormat.nPixelFormat =
static_cast<int16_t
>(nFormat);
1453 RETURN_ERROR(ERR_NOT_SUPPORTED);
1481 default: RETURN_NOERROR;
1498 RETURN_ERROR(ERR_UNEXPECTED);
1501 tBool bAlphaFromHighToLow = tFalse;
1508 bAlphaFromHighToLow = tTrue;
1514 bAlphaFromHighToLow = tTrue;
1520 bAlphaFromHighToLow = tFalse;
1526 bAlphaFromHighToLow = tFalse;
1529 default: RETURN_ERROR(ERR_NOT_SUPPORTED);
1532 tUInt32* pLine = (tUInt32*)
GetBitmap();
1534 if (bAlphaFromHighToLow)
1537 for (tInt nLine = 0; nLine <
m_sFormat.nHeight; nLine++)
1539 for (tInt nPos = 0; nPos <
m_sFormat.nWidth; nPos++)
1541 pLine[nPos] = (pLine[nPos] >> 24) | (pLine[nPos] << 8);
1549 for (tInt nLine = 0; nLine <
m_sFormat.nHeight; nLine++)
1551 for (tInt nPos = 0; nPos <
m_sFormat.nWidth; nPos++)
1553 pLine[nPos] = (pLine[nPos] << 24) | (pLine[nPos] >> 8);
1583 RETURN_IF_POINTER_NULL(pBitmap);
1585 tUInt8* pLine = pBitmap;
1587 tUInt8* pPixelAlpha;
1591 tInt nSteps = nBytesPerLine / 4;
1593 tUInt32 ui32CompValue = (tUInt32) sColorKey.nBlue | ((tUInt32) sColorKey.nGreen << 8) |
1594 ((tUInt32) sColorKey.nRed << 16) | ((tUInt32) sColorKey.nAlpha << 24);
1595 ui32CompValue = ui32CompValue & 0x00FFFFFF;
1597 for (tInt nLine = 0; nLine < nHeight; nLine++)
1599 ptr = (tUInt32*) pLine;
1600 pPixelAlpha = pLine + 3;
1602 for (tInt nStep = 0; nStep < nSteps; nStep++)
1604 if ((*ptr & 0x00FFFFFF) == ui32CompValue)
1607 if (bClearTransparent)
1614 *pPixelAlpha = 0xFF;
1621 pLine += nBytesPerLine;
1662 RETURN_IF_POINTER_NULL(pSrcBitmapData);
1663 RETURN_IF_POINTER_NULL(psSrcBitmapFormat);
1665 if (0 != adtf::util::cMemoryBlock::MemCmp(psSrcBitmapFormat, m_pMyFormat,
sizeof(*pSrcBitmapData)) ||
1669 RETURN_IF_FAILED(
Create(psSrcBitmapFormat));
1731 static tResult
Blit(
const tUInt8* pSrcBitmapData,
1733 tUInt8* pDestBitmapData,
1737 return Blit_impl(pSrcBitmapData, psSrcBitmapFormat, pDestBitmapData, psDestBitmapFormat, nFlags);
1782 tUInt8* pDestBitmapData,
1786 return StretchBlit_impl(pSrcBitmapData, psSrcBitmapFormat, pDestBitmapData, psDestBitmapFormat, nFlags);
1822 static tResult
Convert(
const tUInt8* pSrcBitmapData,
1824 tUInt8* pDestBitmapData,
1829 RETURN_IF_POINTER_NULL(pSrcBitmapData);
1830 RETURN_IF_POINTER_NULL(psSrcBitmapFormat);
1831 RETURN_IF_POINTER_NULL(pDestBitmapData);
1832 RETURN_IF_POINTER_NULL(psDestBitmapFormat);
1833 if (psSrcBitmapFormat->
nWidth != psDestBitmapFormat->
nWidth ||
1836 return StretchBlit_impl(pSrcBitmapData, psSrcBitmapFormat, pDestBitmapData, psDestBitmapFormat, nFlags,
1841 return Convert_impl(pSrcBitmapData, psSrcBitmapFormat, pDestBitmapData, psDestBitmapFormat, nFlags,
1861 RETURN_IF_POINTER_NULL(pSourceImage);
1862 RETURN_IF_POINTER_NULL(pDestImage);
1863 RETURN_IF_POINTER_NULL(pMaskImage);
1864 RETURN_IF_POINTER_NULL(pSourceImage->
GetBitmap());
1865 RETURN_IF_POINTER_NULL(pDestImage->
GetBitmap());
1866 RETURN_IF_POINTER_NULL(pMaskImage->
GetBitmap());
1873 RETURN_ERROR(ERR_UNEXPECTED);
1878 RETURN_ERROR(ERR_NOT_SUPPORTED);
1884 RETURN_ERROR(ERR_NOT_SUPPORTED);
1887 tUInt8* pSourceBuffer = pSourceImage->
GetBitmap();
1888 tUInt8* pDestBuffer = pDestImage->
GetBitmap();
1889 tUInt8* pMaskBuffer = pMaskImage->
GetBitmap();
1891 tUInt8* pSrcLine = pSourceBuffer;
1892 tUInt8* pDestLine = pDestBuffer;
1893 tUInt8* pMaskLine = pMaskBuffer;
1899 tInt nHeight = pSourceImage->
GetHeight();
1900 tInt nWidth = pSourceImage->
GetWidth();
1903 for (tInt y = 0; y < nHeight; y++)
1909 for (tInt x = 0; x < nWidth; x++)
1911 nAlpha = *(pMask++);
1912 *(pDest) = (tUInt8) (((*pDest * nAlpha) + (*pSrc * (255 - nAlpha))) / 255);
1915 *(pDest) = (tUInt8) (((*pDest * nAlpha) + (*pSrc * (255 - nAlpha))) / 255);
1918 *(pDest) = (tUInt8) (((*pDest * nAlpha) + (*pSrc * (255 - nAlpha))) / 255);
1947 RETURN_ERROR(ERR_NOT_IMPL);
1952 RETURN_ERROR(ERR_NOT_SUPPORTED);
1954 tUInt8* pSrcBitmapData = oSrc.
GetBitmap();
1955 tUInt8* pDestBitmapData = oDest.
GetBitmap();
1957 RETURN_IF_POINTER_NULL(pSrcBitmapData);
1958 RETURN_IF_POINTER_NULL(pDestBitmapData);
1963 RETURN_IF_POINTER_NULL(psSrcBitmapFormat);
1964 RETURN_IF_POINTER_NULL(psDestBitmapFormat);
1966 tInt l_nCopyWidth = psDestBitmapFormat->
nWidth;
1967 tInt l_nCopyHeight = psDestBitmapFormat->
nHeight;
1969 const tUInt8* l_pSrcLine = pSrcBitmapData;
1970 const tUInt8* l_pSrcLine2 = pSrcBitmapData;
1972 tUInt8* l_pDestLine = pDestBitmapData;
1973 tInt l_nBytesPerPixel = psSrcBitmapFormat->
nBitsPerPixel / 8;
1975 tInt nCopySrcStep = psSrcBitmapFormat->
nWidth;
1976 tInt nCopySrcMax = l_nCopyWidth * nCopySrcStep;
1981 for (tInt y = 0; y < l_nCopyHeight; y++)
1983 y_weight = GET_REMAINDER(y, psSrcBitmapFormat->
nHeight, psDestBitmapFormat->
nHeight, 256);
1985 y2 = (y * psSrcBitmapFormat->
nHeight) / l_nCopyHeight;
1987 if (y3 >= psSrcBitmapFormat->
nHeight)
1990 l_pSrcLine = pSrcBitmapData + y2 * psSrcBitmapFormat->
nBytesPerLine;
1991 l_pSrcLine2 = pSrcBitmapData + y3 * psSrcBitmapFormat->
nBytesPerLine;
1993 l_pDestLine = pDestBitmapData + y * psDestBitmapFormat->
nBytesPerLine;
1995 if (l_nBytesPerPixel == 4)
1997 tUInt32* l_pui32SrcLine = (tUInt32*) l_pSrcLine;
1998 tUInt32* l_pui32SrcLine2 = (tUInt32*) l_pSrcLine2;
1999 tUInt32* l_pui32DestLine = (tUInt32*) l_pDestLine;
2001 tUInt32 v, v1, v2, v3, v4;
2004 for (tInt x = 0; x < nCopySrcMax; x += nCopySrcStep)
2007 GET_REMAINDER(x / nCopySrcStep, psSrcBitmapFormat->
nWidth, psDestBitmapFormat->
nWidth, 256);
2009 x2 = x + nCopySrcStep;
2010 if (x2 >= nCopySrcMax)
2013 v1 = *(l_pui32SrcLine + x / l_nCopyWidth);
2014 v2 = *(l_pui32SrcLine2 + x / l_nCopyWidth);
2015 v3 = *(l_pui32SrcLine + x2 / l_nCopyWidth);
2016 v4 = *(l_pui32SrcLine2 + x2 / l_nCopyWidth);
2018 v = BlendRGB32(v1, v2, v3, v4, y_weight, x_weight);
2020 *(l_pui32DestLine++) = v;
2023 else if (l_nBytesPerPixel == 3)
2025 tUInt8* l_pui8SrcLine = (tUInt8*) l_pSrcLine;
2026 tUInt8* l_pui8SrcLine2 = (tUInt8*) l_pSrcLine2;
2027 tUInt8* l_pui8DestLine = (tUInt8*) l_pDestLine;
2029 tUInt8 v, v1, v2, v3, v4;
2032 for (tInt x = 0; x < nCopySrcMax; x += nCopySrcStep)
2035 GET_REMAINDER(x / nCopySrcStep, psSrcBitmapFormat->
nWidth, psDestBitmapFormat->
nWidth, 256);
2037 x2 = x + nCopySrcStep;
2038 if (x2 >= nCopySrcMax)
2041 v1 = *(l_pui8SrcLine + (x / l_nCopyWidth) * 3);
2042 v2 = *(l_pui8SrcLine2 + (x / l_nCopyWidth) * 3);
2043 v3 = *(l_pui8SrcLine + (x2 / l_nCopyWidth) * 3);
2044 v4 = *(l_pui8SrcLine2 + (x2 / l_nCopyWidth) * 3);
2045 v = BlendPixel(v1, v2, v3, v4, y_weight, x_weight);
2047 *(l_pui8DestLine++) = v;
2049 v1 = *(l_pui8SrcLine + (x / l_nCopyWidth) * 3 + 1);
2050 v2 = *(l_pui8SrcLine2 + (x / l_nCopyWidth) * 3 + 1);
2051 v3 = *(l_pui8SrcLine + (x2 / l_nCopyWidth) * 3 + 1);
2052 v4 = *(l_pui8SrcLine2 + (x2 / l_nCopyWidth) * 3 + 1);
2053 v = BlendPixel(v1, v2, v3, v4, y_weight, x_weight);
2055 *(l_pui8DestLine++) = v;
2057 v1 = *(l_pui8SrcLine + (x / l_nCopyWidth) * 3 + 2);
2058 v2 = *(l_pui8SrcLine2 + (x / l_nCopyWidth) * 3 + 2);
2059 v3 = *(l_pui8SrcLine + (x2 / l_nCopyWidth) * 3 + 2);
2060 v4 = *(l_pui8SrcLine2 + (x2 / l_nCopyWidth) * 3 + 2);
2061 v = BlendPixel(v1, v2, v3, v4, y_weight, x_weight);
2063 *(l_pui8DestLine++) = v;
2084 RETURN_IF_POINTER_NULL(pImage);
2085 RETURN_IF_POINTER_NULL(pImage->
GetBitmap());
2098 RETURN_IF_FAILED(pImage->
Convert(&oFormat));
2103 auto pPixel = (tUInt32*) pImage->
GetBitmap();
2109 for (tInt nY = 0; nY < nHeight; nY++)
2111 for (tInt nX = 0; nX < nWidth; nX++)
2113 if ((pPixel[nX] & 0x00ffffff) == nTranspColor)
2115 pPixel[nX] = 0x00000000;
2119 pPixel[nX] = pPixel[nX] | 0xff000000;
2137 return ((tUInt8) (nColor));
2149 return ((tUInt8) (((tUInt16) (nColor)) >> 8));
2161 return ((tUInt8) ((nColor) >> 16));
2173 static inline tFloat64
Brightness(tFloat64 fRed, tFloat64 fGreen, tFloat64 fBlue)
2175 return (0.114 * fRed + 0.587 * fGreen + 0.299 * fBlue);
2189 return 116 * nRed + 602 * nGreen + 306 * nBlue;
2201 static inline tUInt8
Brightness(tInt nRed, tInt nGreen, tInt nBlue)
2248 tResult LoadResource(tInt nResourceId, tHandle hModule = NULL, tUInt32 nFlags = 0)
2252 HRSRC hResource = ::FindResource((HMODULE) hModule, MAKEINTRESOURCE(nResourceId), RT_BITMAP);
2253 if (NULL == hResource)
2255 RETURN_ERROR(ERR_NOT_FOUND);
2258 HGLOBAL hResourceData = ::LoadResource((HMODULE) hModule, hResource);
2259 if (NULL == hResourceData)
2261 RETURN_ERROR(ERR_NOACCESS);
2264 BITMAPINFOHEADER* pBitmap = (BITMAPINFOHEADER*) ::LockResource(hResourceData);
2265 if (NULL == pBitmap)
2267 ::FreeResource(hResourceData);
2268 RETURN_ERROR(ERR_NOACCESS);
2273 if (pBitmap->biBitCount <= 8)
2275 BITMAPINFO* pBitmapHeader = (BITMAPINFO*) pBitmap;
2277 nPaletteSize = (1 << pBitmap->biBitCount);
2278 pPalette = (tVoid*) &pBitmapHeader->bmiColors[0];
2286 tUInt8* pBitmapData = (tUInt8*) pBitmap + pBitmap->biSize + nPaletteSize *
sizeof(tUInt32);
2288 tResult nResult =
Create(pBitmap->biWidth, pBitmap->biHeight, pBitmap->biBitCount, 0, pBitmapData);
2289 if (IS_OK(nResult) && NULL != pPalette)
2291 nResult =
SetPalette(nPaletteSize, (tColor*) pPalette);
2294 UnlockResource(hResourceData);
2295 ::FreeResource(hResourceData);
2297 if (IS_FAILED(nResult))
2338 tResult CaptureScreen(tInt x, tInt y, tInt nWidth, tInt nHeight)
2340 RETURN_IF_FAILED(
Create(nWidth, nHeight, 24));
2341 if ((nWidth < 1) || (nHeight < 1) || (x < 0) || (y < 0))
2343 RETURN_ERROR(ERR_INVALID_ARG);
2345 HDC hdcScreen = ::GetDC(NULL);
2346 HDC hdcCapture = ::CreateCompatibleDC(hdcScreen);
2347 HBITMAP bmCapture = ::CreateCompatibleBitmap(hdcScreen, nWidth, nHeight);
2349 ::SetStretchBltMode(hdcCapture, COLORONCOLOR);
2350 ::SelectObject(hdcCapture, bmCapture);
2352 ::StretchBlt(hdcCapture, 0, 0, nWidth, nHeight, hdcScreen, x, y, nWidth, nHeight, SRCCOPY);
2354 ::GetDIBits(hdcCapture, bmCapture, 0, nHeight,
GetBitmap(), (BITMAPINFO*)
GetBitmapInfo(), DIB_RGB_COLORS);
2356 ::DeleteObject(bmCapture);
2357 ::DeleteDC(hdcCapture);
2359 ::ReleaseDC(NULL, hdcScreen);
2371 tHandle CreateRegion()
2380 default:
return NULL;
2385 tBool bVFlip = tTrue;
2390 tUInt8* pLine = pImage;
2393 pLine += nBytesPerLine * (
GetHeight() - 1);
2399 tInt rgn_start = -1;
2405 for (tInt x = 0; x <
GetWidth(); x++)
2407 bTransparent = tFalse;
2409 if (nBytesPerPixel >= 3)
2415 if (r == 0xFF && g == 0x00 && b == 0xFF)
2417 bTransparent = tTrue;
2424 bTransparent = tTrue;
2439 HRGN hLocalRgn = ::CreateRectRgn(rgn_start, y, x, y + 1);
2440 ::CombineRgn(hRgn, hRgn, hLocalRgn, RGN_DIFF);
2441 ::DeleteObject(hLocalRgn);
2447 ptr += nBytesPerPixel;
2452 HRGN hLocalRgn = ::CreateRectRgn(rgn_start, y,
GetWidth(), y + 1);
2453 ::CombineRgn(hRgn, hRgn, hLocalRgn, RGN_DIFF);
2454 ::DeleteObject(hLocalRgn);
2461 pLine -= nBytesPerLine;
2465 pLine += nBytesPerLine;
2469 return (tHandle) hRgn;
2483 if (
this == &oImage)
2502 for (tInt nLine = 0; nLine <
m_sFormat.nHeight; nLine++)
2504 tInt nOffset = nLine *
m_sFormat.nBytesPerLine;
2505 if (adtf::util::cMemoryBlock::MemCmp(
GetBitmap() + nOffset, oImage.
GetBitmap() + nOffset,
2506 nBytesToCompare) != 0)
2524 if (
this == &oImage)
2542 tInt nBytesPerPixel =
m_sFormat.nBitsPerPixel / 8;
2543 tInt nBytesToCompare =
m_sFormat.nWidth * nBytesPerPixel;
2545 for (tInt nLine = 0; nLine <
m_sFormat.nHeight; nLine++)
2547 tInt nOffset = nLine *
m_sFormat.nBytesPerLine;
2550 tUInt8* pRefLine = oImage.
GetBitmap() + nOffset;
2552 for (tInt i = 0; i < nBytesToCompare; i += nBytesPerPixel)
2554 for (tInt p = 0; p < nBytesPerPixel; p++)
2556 if (pLine[i + p] != pRefLine[i + p])
2589 if (nBytes % nAlignment)
2591 return (nBytes + (nAlignment - (nBytes % nAlignment)));
2612 if (nExpectedSize >
static_cast<tUInt
>(pFormat->
nSize))
2637 return CalcBitsPerPixelFromPixelFormat(nFormat);
2680 return "8 bit greyscale";
2692 return "10 bit greyscale";
2696 return "12 bit greyscale";
2700 return "14 bit greyscale";
2704 return "16 bit greyscale";
2708 return "12 bit RGB";
2712 return "15 bit RGB";
2716 return "16 bit RGB";
2720 return "16 bit RGBA";
2724 return "16 bit ABGR";
2728 return "10 bit RIII";
2732 return "12 bit RIII";
2736 return "14 bit RIII";
2740 return "16 bit RIII";
2744 return "15 bit BGR";
2748 return "16 bit BGR";
2752 return "16 bit RGBA 5551";
2756 return "16 bit BGRA 5551";
2760 return "16 bit ARGB 1555";
2764 return "16 bit ABGR 1555";
2770 case PF_GREYSCALE_18:
2772 return "18 bit greyscale";
2774 case PF_GREYSCALE_20:
2776 return "20 bit greyscale";
2778 case PF_GREYSCALE_22:
2780 return "22 bit greyscale";
2784 return "24 bit greyscale";
2788 return "24 bit RGB";
2792 return "24 bit BGR";
2800 return "32 bit ARGB";
2804 return "32 bit ABGR";
2808 return "32 bit RGBA";
2812 return "32 bit BGRA";
2816 return "32 bit xRGB";
2820 return "32 bit xBGR";
2824 return "32 bit RGBx";
2828 return "32 bit BGRx";
2832 return "32bit greyscale";
2836 return "32 bit float greyscale";
2840 return "24 bit YUV420P";
2848 return "NOT DEFINED";
2901 if (psFormat->
nSize > 0)
2950 tResult
AllocImpl(tInt nSize, tHandle* hMemory, tVoid** pBuffer)
2957 *hMemory = (tHandle)
new tUInt8[nMemBlockSize];
2958 if (*hMemory == NULL)
2960 RETURN_ERROR(ERR_MEMORY);
2978 delete[] ((tUInt8*) hMemory);
2999 if (nPaletteSize != 0)
3004 RETURN_ERROR(ERR_MEMORY);
3039 tInt l_nPaletteSize =
m_sFormat.nPaletteSize;
3040 if (l_nPaletteSize == 0 &&
m_pPalette != NULL)
3045 tInt nBitmapInfoSize =
sizeof(
tWin32BitmapInfo) +
sizeof(tColor) * l_nPaletteSize;
3050 RETURN_ERROR(ERR_MEMORY);
3053 adtf::util::cMemoryBlock::MemSet(
m_psBitmapInfo, 0, nBitmapInfoSize);
3075 if (l_nPaletteSize > 0 &&
m_pPalette != NULL)
3078 adtf::util::cMemoryBlock::MemCopy(l_aPalette,
m_pPalette, l_nPaletteSize *
sizeof(tColor));
3116 tUInt8* pDestBitmapData,
3120 RETURN_IF_POINTER_NULL(pSrcBitmapData);
3121 RETURN_IF_POINTER_NULL(psSrcBitmapFormat);
3122 RETURN_IF_POINTER_NULL(pDestBitmapData);
3123 RETURN_IF_POINTER_NULL(psDestBitmapFormat);
3127 return Convert_impl(pSrcBitmapData, psSrcBitmapFormat, pDestBitmapData, psDestBitmapFormat, nFlags, 0x0);
3131 tInt l_nCopyHeight = std::min<tInt>(psSrcBitmapFormat->
nHeight, psDestBitmapFormat->
nHeight);
3133 const tUInt8* l_pSrcLine = pSrcBitmapData;
3134 tUInt8* l_pDestLine = pDestBitmapData;
3138 l_pDestLine += psDestBitmapFormat->
nBytesPerLine * (l_nCopyHeight - 1);
3140 for (tInt y = 0; y < l_nCopyHeight; y++)
3142 adtf::util::cMemoryBlock::MemCopy(l_pDestLine, l_pSrcLine, l_nCopyWidth);
3152 adtf::util::cMemoryBlock::MemCopy(l_pDestLine, l_pSrcLine,
3157 for (tInt y = 0; y < l_nCopyHeight; y++)
3159 adtf::util::cMemoryBlock::MemCopy(l_pDestLine, l_pSrcLine, l_nCopyWidth);
3184 tUInt8* pDestBitmapData,
3187 tUInt32 ui32Mask = 0x0)
3189 RETURN_IF_POINTER_NULL(pSrcBitmapData);
3190 RETURN_IF_POINTER_NULL(psSrcBitmapFormat);
3191 RETURN_IF_POINTER_NULL(pDestBitmapData);
3192 RETURN_IF_POINTER_NULL(psDestBitmapFormat);
3197 if (psSrcBitmapFormat->
nWidth == psDestBitmapFormat->
nWidth &&
3200 return Convert_impl(pSrcBitmapData, psSrcBitmapFormat, pDestBitmapData, psDestBitmapFormat, nFlags,
3206 adtf::util::cMemoryBlock::MemCopy(&oNewFormat, psSrcBitmapFormat,
sizeof(
tBitmapFormat));
3217 pSrcBitmapData = oTempImage.
GetBitmap();
3218 psSrcBitmapFormat = oTempImage.
GetFormat();
3222 if (psSrcBitmapFormat->
nWidth == psDestBitmapFormat->
nWidth &&
3225 return Blit(pSrcBitmapData, psSrcBitmapFormat, pDestBitmapData, psDestBitmapFormat, nFlags);
3228 tInt l_nCopyWidth = psDestBitmapFormat->
nWidth;
3229 tInt l_nCopyHeight = psDestBitmapFormat->
nHeight;
3231 const tUInt8* l_pSrcLine = pSrcBitmapData;
3232 tUInt8* l_pDestLine = pDestBitmapData;
3233 tInt l_nBytesPerPixel = psSrcBitmapFormat->
nBitsPerPixel / 8;
3235 tInt nCopySrcStep = psSrcBitmapFormat->
nWidth;
3236 tInt nCopySrcMax = l_nCopyWidth * nCopySrcStep;
3241 for (tInt y = 0; y < l_nCopyHeight; y++)
3243 y2 = tInt(y * tFloat(psSrcBitmapFormat->
nHeight) / l_nCopyHeight);
3245 l_pSrcLine = pSrcBitmapData + y2 * psSrcBitmapFormat->
nBytesPerLine;
3246 l_pDestLine = pDestBitmapData + y * psDestBitmapFormat->
nBytesPerLine;
3248 if (l_nBytesPerPixel == 1)
3250 for (tInt x = 0; x < nCopySrcMax; x += nCopySrcStep)
3252 *(l_pDestLine++) = *(l_pSrcLine + x / l_nCopyWidth);
3255 else if (l_nBytesPerPixel == 2)
3257 tUInt16* l_pui16SrcLine = (tUInt16*) l_pSrcLine;
3258 tUInt16* l_pui16DestLine = (tUInt16*) l_pDestLine;
3260 for (tInt x = 0; x < nCopySrcMax; x += nCopySrcStep)
3262 *(l_pui16DestLine++) = *(l_pui16SrcLine + x / l_nCopyWidth);
3265 else if (l_nBytesPerPixel == 3)
3267 const tUInt8* l_pSrc;
3269 for (tInt x = 0; x < l_nCopyWidth; x++)
3271 x2 = tInt(x * tFloat(psSrcBitmapFormat->
nWidth) / l_nCopyWidth);
3273 l_pDest = l_pDestLine + x * l_nBytesPerPixel;
3274 l_pSrc = l_pSrcLine + x2 * l_nBytesPerPixel;
3276 *l_pDest++ = *l_pSrc++;
3277 *l_pDest++ = *l_pSrc++;
3278 *l_pDest++ = *l_pSrc++;
3281 else if (l_nBytesPerPixel == 4)
3283 tUInt32* l_pui32SrcLine = (tUInt32*) l_pSrcLine;
3284 tUInt32* l_pui32DestLine = (tUInt32*) l_pDestLine;
3286 for (tInt x = 0; x < nCopySrcMax; x += nCopySrcStep)
3288 *(l_pui32DestLine++) = *(l_pui32SrcLine + x / l_nCopyWidth);
3311 tUInt8* pDestBitmapData,
3319 RETURN_ERROR(ERR_UNKNOWN_FORMAT);
3325 RETURN_ERROR(ERR_UNKNOWN_FORMAT);
3330 RETURN_ERROR(ERR_NOT_SUPPORTED);
3333 const tUInt8* l_pSrcLine = pSrcBitmapData;
3334 tUInt8* l_pDestLine = pDestBitmapData;
3336 tInt l_nSrcBytesPerPixel = psSrcBitmapFormat->
nBitsPerPixel / 8;
3337 tInt l_nDestBytesPerPixel = psDestBitmapFormat->
nBitsPerPixel / 8;
3339 tInt l_nCopyWidth = std::min<tInt>(psSrcBitmapFormat->
nWidth, psDestBitmapFormat->
nWidth);
3340 tInt l_nCopyHeight = std::min<tInt>(psSrcBitmapFormat->
nHeight, psDestBitmapFormat->
nHeight);
3342 tUInt8 nRed, nGreen, nBlue;
3357 tInt nShiftBits = 0;
3358 if (ui32Mask != 0x0)
3360 tUInt32 ui32TempMask;
3361 for (ui32TempMask = ui32Mask; !(ui32TempMask & 0x01); ui32TempMask >>= 1)
3367 for (; (ui32TempMask & 0x01); ui32TempMask >>= 1)
3384 l_pDestLine += (l_nCopyHeight - 1) * psDestBitmapFormat->
nBytesPerLine;
3388 for (tInt y = 0; y < l_nCopyHeight; y++)
3393 adtf::util::cMemoryBlock::MemCopy(l_pDestLine, l_pSrcLine, l_nCopyWidth * l_nSrcBytesPerPixel);
3395 else if (l_nSrcBytesPerPixel == 1)
3399 RETURN_ERROR(ERR_NOT_SUPPORTED);
3402 const tUInt8* l_pSrc = l_pSrcLine;
3405 if (l_nDestBytesPerPixel == 3)
3407 tUInt8* l_pDest = l_pDestLine;
3408 for (tInt x = 0; x < l_nCopyWidth; x++)
3417 else if (l_nDestBytesPerPixel == 4)
3419 tUInt32* l_pDest = (tUInt32*) l_pDestLine;
3420 tInt rs = 0, gs = 0, bs = 0;
3442 default: RETURN_ERROR(ERR_NOT_SUPPORTED);
3445 for (tInt x = 0; x < l_nCopyWidth; x++)
3447 tUInt32 k8 = *(l_pSrc++);
3448 *l_pDest++ = (k8 << bs) | (k8 << gs) | (k8 << rs);
3451 else if (l_nDestBytesPerPixel == 2)
3453 tUInt16* l_pDest = (tUInt16*) l_pDestLine;
3457 for (tInt x = 0; x < l_nCopyWidth; x++)
3460 *(l_pDest++) = RGB555(c8, c8, c8);
3465 for (tInt x = 0; x < l_nCopyWidth; x++)
3468 *(l_pDest++) = RGB565(c8, c8, c8);
3475 for (tInt x = 0; x < l_nCopyWidth; x++)
3478 *(l_pDest++) = (((tUInt16) c8) << 8);
3483 for (tInt x = 0; x < l_nCopyWidth; x++)
3486 *(l_pDest++) = (tUInt16) ((((tUInt32) c8) << nShiftBits) & ui32Mask);
3492 else if (l_nSrcBytesPerPixel == 2)
3494 if (l_nDestBytesPerPixel == 1)
3496 tUInt16* l_pSrc = (tUInt16*) l_pSrcLine;
3497 tUInt8* l_pDest = l_pDestLine;
3500 for (tInt x = 0; x < l_nCopyWidth; x++)
3503 nRed = GetRed_RGB555(c16);
3504 nGreen = GetGreen_RGB555(c16);
3505 nBlue = GetBlue_RGB555(c16);
3506 *(l_pDest++) =
Brightness((tInt) nRed, (tInt) nGreen, (tInt) nBlue);
3511 for (tInt x = 0; x < l_nCopyWidth; x++)
3514 nRed = GetRed_RGB565(c16);
3515 nGreen = GetGreen_RGB565(c16);
3516 nBlue = GetBlue_RGB565(c16);
3517 *(l_pDest++) =
Brightness((tInt) nRed, (tInt) nGreen, (tInt) nBlue);
3524 for (tInt x = 0; x < l_nCopyWidth; x++)
3526 *(l_pDest++) = (tUInt8) (*(l_pSrc++) >> 8);
3531 for (tInt x = 0; x < l_nCopyWidth; x++)
3533 *(l_pDest++) = (tUInt8) (((*(l_pSrc++)) & ui32Mask) >> nShiftBits);
3538 else if (l_nDestBytesPerPixel == 2)
3540 tUInt16* l_pDest = (tUInt16*) l_pDestLine;
3541 tUInt16* l_pSrc = (tUInt16*) l_pSrcLine;
3543 tInt iSRPos, iSGPos, iSBPos, iSAPos = 16;
3544 tInt iDRPos, iDGPos, iDBPos, iDAPos = 16;
3545 tUInt16 iSMask, iSGMask, iSAMask = 0;
3546 tUInt16 iDMask, iDGMask, iDAMask = 0;
3554 iSMask = iSGMask = 0xf;
3560 iSMask = iSGMask = 0x1f;
3566 iSMask = iSGMask = 0x1f;
3587 iSMask = iSGMask = 0xf;
3595 iSMask = iSGMask = 0xf;
3598 default: RETURN_ERROR(ERR_NOT_SUPPORTED);
3607 iDMask = iDGMask = 0xf;
3613 iDMask = iDGMask = 0x1f;
3619 iDMask = iDGMask = 0x1f;
3640 iDMask = iDGMask = 0xf;
3648 iDMask = iDGMask = 0xf;
3651 default: RETURN_ERROR(ERR_NOT_SUPPORTED);
3654 tUInt16 iDRMask = iDMask;
3655 tUInt16 iDBMask = iDMask;
3656 tUInt16 iSRMask = iSMask;
3657 tUInt16 iSBMask = iSMask;
3659 iDRMask = AdjustMasks(iSRMask, iDRMask, iSRPos);
3660 iDBMask = AdjustMasks(iSBMask, iDBMask, iSBPos);
3661 iDGMask = AdjustMasks(iSGMask, iDGMask, iSGPos);
3662 iSAMask = AdjustMasks(iSAMask, iDAMask, iSAPos);
3667 iDRMask >>= -iSRPos;
3671 for (tInt x = 0; x < l_nCopyWidth; x++)
3673 tUInt16 c = *l_pSrc++;
3675 *l_pDest++ = (((c >> iSRPos) & iDRMask) << iDRPos) | (((c >> iSGPos) & iDGMask) << iDGPos) |
3676 (((c >> iSBPos) & iDBMask) << iDBPos) | (((c >> iSAPos) & iSAMask) << iDAPos);
3679 else if (l_nDestBytesPerPixel == 3)
3681 tUInt8* l_pDest = l_pDestLine;
3682 tUInt16* l_pSrc = (tUInt16*) l_pSrcLine;
3684 tInt iSl, iSRr, iSGl, iSGr, iSBr;
3739 default: RETURN_ERROR(ERR_NOT_SUPPORTED);
3752 default: RETURN_ERROR(ERR_NOT_SUPPORTED);
3755 for (tInt x = 0; x < l_nCopyWidth; x++)
3757 tUInt16
const k16 = *l_pSrc++;
3758 l_pDest[iDR] =
static_cast<uint8_t
>((k16 >> iSRr) << iSl);
3759 l_pDest[1] =
static_cast<uint8_t
>((k16 >> iSGr) << iSGl);
3760 l_pDest[iDB] =
static_cast<uint8_t
>((k16 >> iSBr) << iSl);
3764 else if (l_nDestBytesPerPixel == 4)
3766 tUInt8* l_pDest = l_pDestLine;
3767 tUInt16* l_pSrc = (tUInt16*) l_pSrcLine;
3769 tInt iSl, iSRr, iSGl, iSGr, iSBr, iSAr = 16;
3819 default: RETURN_ERROR(ERR_NOT_SUPPORTED);
3822 tInt iDR, iDG, iDB, iDA;
3850 default: RETURN_ERROR(ERR_NOT_SUPPORTED);
3853 for (tInt x = 0; x < l_nCopyWidth; x++)
3855 tUInt16
const k16 = *l_pSrc++;
3856 l_pDest[iDR] =
static_cast<uint8_t
>((k16 >> iSRr) << iSl);
3857 l_pDest[iDG] =
static_cast<uint8_t
>((k16 >> iSGr) << iSGl);
3858 l_pDest[iDB] =
static_cast<uint8_t
>((k16 >> iSBr) << iSl);
3859 l_pDest[iDA] =
static_cast<uint8_t
>((k16 >> iSAr) << iSl);
3864 else if (l_nSrcBytesPerPixel == 3)
3866 const tUInt8* l_pSrc = l_pSrcLine;
3867 if (l_nDestBytesPerPixel == 1)
3871 RETURN_ERROR(ERR_NOT_SUPPORTED);
3874 tUInt8* l_pDest = l_pDestLine;
3875 tInt ri = 0, gi = 0, bi = 0;
3889 default: RETURN_ERROR(ERR_NOT_SUPPORTED);
3892 for (tInt x = 0; x < l_nCopyWidth; x++)
3894 *(l_pDest++) =
Brightness(l_pSrc[ri], l_pSrc[gi], l_pSrc[bi]);
3898 else if (l_nDestBytesPerPixel == 2)
3900 tUInt16* l_pDest = (tUInt16*) l_pDestLine;
3913 default: RETURN_ERROR(ERR_NOT_SUPPORTED);
3916 tInt iDr, iDRl, iDGr, iDGl, iDBl, iDAl = 16;
3917 tBool bDestGrey = tFalse;
3968 default: RETURN_ERROR(ERR_NOT_SUPPORTED);
3973 for (tInt x = 0; x < l_nCopyWidth; x++)
3975 *l_pDest++ =
static_cast<uint16_t
>(
3982 for (tInt x = 0; x < l_nCopyWidth; x++)
3985 (((tUInt16) l_pSrc[iSR] >> iDr) << iDRl) | (((tUInt16) l_pSrc[1] >> iDGr) << iDGl) |
3986 (((tUInt16) l_pSrc[iSB] >> iDr) << iDBl) | (((tUInt16) ALPHA_DEFAULT >> iDr) << iDAl);
3991 else if (l_nDestBytesPerPixel == 3)
3993 tUInt8* l_pDest = l_pDestLine;
3995 tInt iDR, iDB, iSR, iSB;
4007 default: RETURN_ERROR(ERR_NOT_SUPPORTED);
4020 default: RETURN_ERROR(ERR_NOT_SUPPORTED);
4023 for (tInt x = 0; x < l_nCopyWidth; x++)
4025 l_pDest[iDR] = l_pSrc[iSR];
4026 l_pDest[1] = l_pSrc[1];
4027 l_pDest[iDB] = l_pSrc[iSB];
4032 else if (l_nDestBytesPerPixel == 4)
4034 tUInt8* l_pDest = l_pDestLine;
4037 tInt iDR, iDG, iDB, iDA;
4051 default: RETURN_ERROR(ERR_NOT_SUPPORTED);
4080 default: RETURN_ERROR(ERR_NOT_SUPPORTED);
4083 for (tInt x = 0; x < l_nCopyWidth; x++)
4085 l_pDest[iDR] = l_pSrc[iSR];
4086 l_pDest[iDG] = l_pSrc[iSG];
4087 l_pDest[iDB] = l_pSrc[iSB];
4088 l_pDest[iDA] = ALPHA_DEFAULT;
4094 else if (l_nSrcBytesPerPixel == 4)
4096 if (l_nDestBytesPerPixel == 1)
4100 RETURN_ERROR(ERR_NOT_SUPPORTED);
4103 tUInt8* l_pSrc = (tUInt8*) l_pSrcLine;
4104 tUInt8* l_pDest = l_pDestLine;
4105 tInt ri = 0, gi = 0, bi = 0;
4129 default: RETURN_ERROR(ERR_NOT_SUPPORTED);
4132 for (tInt x = 0; x < l_nCopyWidth; x++)
4134 *(l_pDest++) =
Brightness(l_pSrc[ri], l_pSrc[gi], l_pSrc[bi]);
4138 else if (l_nDestBytesPerPixel == 2)
4140 tUInt16* l_pDest = (tUInt16*) l_pDestLine;
4141 tUInt8* l_pSrc = (tUInt8*) l_pSrcLine;
4143 tInt iSR, iSG, iSB, iSA;
4171 default: RETURN_ERROR(ERR_NOT_SUPPORTED);
4174 tInt iDr, iDRl, iDGr, iDGl, iDBl, iDAl = 16;
4224 default: RETURN_ERROR(ERR_NOT_SUPPORTED);
4227 for (tInt x = 0; x < l_nCopyWidth; x++)
4230 (((tUInt16) l_pSrc[iSR] >> iDr) << iDRl) | (((tUInt16) l_pSrc[iSG] >> iDGr) << iDGl) |
4231 (((tUInt16) l_pSrc[iSB] >> iDr) << iDBl) | (((tUInt16) l_pSrc[iSA] >> iDr) << iDAl);
4235 else if (l_nDestBytesPerPixel == 3)
4237 const tUInt8* l_pSrc = l_pSrcLine;
4238 tUInt8* l_pDest = l_pDestLine;
4265 default: RETURN_ERROR(ERR_NOT_SUPPORTED);
4280 default: RETURN_ERROR(ERR_NOT_SUPPORTED);
4283 for (tInt x = 0; x < l_nCopyWidth; x++)
4285 l_pDest[iDR] = l_pSrc[iSR];
4286 l_pDest[iDG] = l_pSrc[iSG];
4287 l_pDest[iDB] = l_pSrc[iSB];
4292 else if (l_nDestBytesPerPixel == 4)
4294 const tUInt8* l_pSrc = l_pSrcLine;
4295 tUInt8* l_pDest = (tUInt8*) l_pDestLine;
4297 tInt iSA, iSR, iSG, iSB;
4324 default: RETURN_ERROR(ERR_NOT_SUPPORTED);
4327 tInt iDA, iDR, iDG, iDB;
4354 default: RETURN_ERROR(ERR_NOT_SUPPORTED);
4357 for (tInt x = 0; x < l_nCopyWidth; x++)
4359 l_pDest[iDA] = l_pSrc[iSA];
4360 l_pDest[iDR] = l_pSrc[iSR];
4361 l_pDest[iDG] = l_pSrc[iSG];
4362 l_pDest[iDB] = l_pSrc[iSB];
4369 RETURN_ERROR(ERR_NOT_SUPPORTED);
4405 if (
this == &oImage)
4415 static int32_t GetNextPowerOfTwo(int32_t
const a)
4418 int32_t rval = (a > 0) ? a - 1 : 0;
4427 static int32_t CalcBitsPerPixelFromPixelFormat(int32_t
const oPixelFormat)
4429 switch (oPixelFormat)
4450 case IImage::PF_RIII_10:
return 16;
4451 case IImage::PF_RIII_12:
return 16;
4452 case IImage::PF_RIII_14:
return 16;
4453 case IImage::PF_RIII_16:
return 16;
4454 case IImage::PF_BGR_565:
return 16;
4455 case IImage::PF_BGR_555:
return 16;
4460 case IImage::PF_GREYSCALE_18:
return 24;
4461 case IImage::PF_GREYSCALE_20:
return 24;
4462 case IImage::PF_GREYSCALE_22:
return 24;
4495 static bool NeedAlphaBlend(int32_t
const oPixelFormat)
4497 switch (oPixelFormat)
4519 default:
return false;
4524 inline void Yuv2Rgb(tUInt8 y, tUInt8 u, tUInt8 v, tUInt8* pPixel)
4526 int32_t
const c = y - 16;
4527 int32_t
const d = u - 128;
4528 int32_t
const e = v - 128;
4529 int32_t
const r = (298 * c + 409 * e + 128) >> 8;
4530 int32_t
const g = (298 * c - 100 * d - 208 * e + 128) >> 8;
4531 int32_t
const b = (298 * c + 516 * d + 128) >> 8;
4532 pPixel[0] =
static_cast<uint8_t
>(std::clamp(r, 0, 255));
4533 pPixel[1] =
static_cast<uint8_t
>(std::clamp(g, 0, 255));
4534 pPixel[2] =
static_cast<uint8_t
>(std::clamp(b, 0, 255));
4537 inline tUInt8 YFromRGB(tUInt8* pPixel)
4539 return ((66 * pPixel[0] + 129 * pPixel[1] + 25 * pPixel[2] + 128) >> 8) + 16;
4542 inline tUInt8 UFromRGB(tUInt8* pPixel)
4544 return ((-38 * pPixel[0] - 74 * pPixel[1] + 112 * pPixel[2] + 128) >> 8) + 128;
4547 inline tUInt8 VFromRGB(tUInt8* pPixel)
4549 return ((112 * pPixel[0] - 94 * pPixel[1] - 18 * pPixel[2] + 128) >> 8) + 128;
4552 static tUInt8 BlendPixel(tUInt8 c1, tUInt8 c2, tUInt8 c3, tUInt8 c4, tInt alpha_y, tInt alpha_x)
4554 tInt a1 = alpha_x * alpha_y;
4555 tInt a2 = alpha_x * (256 - alpha_y);
4556 tInt a3 = (256 - alpha_x) * alpha_y;
4557 tInt a4 = (256 - alpha_x) * (256 - alpha_y);
4559 return (tUInt8) (((tInt) c1 * a1 + (tInt) c2 * a2 + (tInt) c3 * a3 + (tInt) c4 * a4) >> 16);
4562 static tUInt32 BlendRGB32(tUInt32 c1, tUInt32 c2, tUInt32 c3, tUInt32 c4, tInt alpha_y, tInt alpha_x)
4564 tInt a1 = alpha_x * alpha_y;
4565 tInt a2 = alpha_x * (256 - alpha_y);
4566 tInt a3 = (256 - alpha_x) * alpha_y;
4567 tInt a4 = (256 - alpha_x) * (256 - alpha_y);
4569 tUInt8* pb1 = (tUInt8*) &c1;
4570 tUInt8* pb2 = (tUInt8*) &c2;
4571 tUInt8* pb3 = (tUInt8*) &c3;
4572 tUInt8* pb4 = (tUInt8*) &c4;
4575 tUInt8* pb = (tUInt8*) &c;
4577 pb[1] = (tUInt8) (((tInt) pb1[0] * a1 + (tInt) pb2[0] * a2 + (tInt) pb3[0] * a3 + (tInt) pb4[0] * a4) >> 16);
4578 pb[2] = (tUInt8) (((tInt) pb1[1] * a1 + (tInt) pb2[1] * a2 + (tInt) pb3[1] * a3 + (tInt) pb4[1] * a4) >> 16);
4579 pb[3] = (tUInt8) (((tInt) pb1[2] * a1 + (tInt) pb2[2] * a2 + (tInt) pb3[2] * a3 + (tInt) pb4[2] * a4) >> 16);
4580 pb[0] = (tUInt8) (((tInt) pb1[3] * a1 + (tInt) pb2[3] * a2 + (tInt) pb3[3] * a3 + (tInt) pb4[3] * a4) >> 16);
4585 static tUInt16 AdjustMasks(tUInt16 iSMask, tUInt16 iDMask, tInt& iPos)
4587 if (iSMask == 0 || iDMask == 0)
4592 if (iSMask == iDMask)
4597 while (iSMask > iDMask)
4603 tInt iMoveCount = 0;
4604 while ((iSMask | (iSMask - 1)) < iDMask)
4610 return (iDMask >> iMoveCount) << iMoveCount;
@ PF_BGRA_5551
16 bit BGRA (R: 5 bit, G: 5 bit, B: 5 bit, Alpha:1bit)
@ PF_32BIT
32 bit This definition is a placeholder a 32 Bit format, bitorder is undefined.
@ PF_RGB_888
24 bit RGB (R: 8 bit, G: 8 bit, B: 8 bit) - default format for 24 bpp
@ PF_GREYSCALE_FLOAT32
32 bit greyscale float value
@ PF_GREYSCALE_10
10 bit greyscale To setup Format use tBitmapFormat::nBitsPerPixel = 16 !
@ PF_YUV420P_888
24 bit YUV (Y: 8 bit, U: 8 bit, V: 8 bit) - Y = luminance, U+V = chrominance If using this format in ...
@ PF_16BIT
16 bit This definition is a placeholder a 16 Bit format, bitorder is undefined.
@ PF_GREYSCALE_24
24 bit greyscale
@ PF_RGBA_8888
32 bit RGBA (R: 8 bit, G: 8 bit, B: 8 bit, A: 8 bit) with alpha value - default format for 32 bpp
@ PF_RGB_555
15 bit RGB (R: 5 bit, G: 5 bit, B: 5 bit) - default format for 16 bpp
@ PF_xRGB_8888
32 bit aligned memory with only 24 Bit valid RGB data. A=255.
@ PF_RGB_565
16 bit RGB (R: 5 bit, G: 6 bit, B: 5 bit)
@ PF_BGRA_8888
32 bit BGRA (B: 8 bit, G: 8 bit, R: 8 bit, A: 8 bit) with alpha value - inverted RGB + A
@ PF_ARGB_1555
16 bit ARGB (R: 5 bit, G: 5 bit, B: 5 bit, Alpha:1bit)
@ PF_24BIT
24 bit This definition is a placeholder a 24 Bit format, bitorder is undefined.
@ PF_ABGR_1555
16 bit ABGR (R: 5 bit, G: 5 bit, B: 5 bit, Alpha:1bit)
@ PF_BGRx_8888
32 bit aligned memory with only 24 Bit valid RGB data. A=255.
@ PF_RGBx_8888
32 bit aligned memory with only 24 Bit valid RGB data. A=255.
@ PF_ARGB_8888
32 bit ARGB (A: 8 bit, R: 8 bit, G: 8 bit, B: 8 bit) with alpha value
@ PF_GREYSCALE_16
16 bit greyscale
@ PF_ABGR_8888
32 bit ABGR (A: 8 bit, B: 8 bit, G: 8 bit, R: 8 bit) with alpha value - inverted RGBA
@ PF_RGB_444
12 bit RGB (R: 4 bit, G: 4 bit, B: 4 bit)
@ PF_BGR_888
24 bit BGR (B: 8 bit, G: 8 bit, R: 8 bit) - inverted RGB
@ PF_GREYSCALE_8
8 bit greyscale - default format for 8 bpp
@ PF_xBGR_8888
32 bit aligned memory with only 24 Bit valid RGB data. A=255.
@ PF_GREYSCALE_12
12 bit greyscale To setup Format use tBitmapFormat::nBitsPerPixel = 16 !
@ PF_RGBA_5551
16 bit RGBA (R: 5 bit, G: 5 bit, B: 5 bit, Alpha:1bit)
@ PF_GREYSCALE_14
14 bit greyscale To setup Format use tBitmapFormat::nBitsPerPixel = 16 !
@ PF_ABGR_4444
16 bit ABGR (A: 4 bit, B: 4 bit, G: 4 bit, R: 4 bit) with alpha value - inverted RGBA
@ PF_RGB_8
8 bit RGB (R: 3 bit, G: 3 bit, B: 2 Bit) - palletized 8 bpp format
@ PF_RGBA_4444
16 bit RGBA (R: 4 bit, G: 4 bit, B: 4 bit, A: 4 bit) with alpha value
@ PF_GREYSCALE_32
32 bit greyscale
cImage()
Default constructor.
Image and bitmap handling.
virtual tUInt8 * GetBitmap() const =0
Returns a pointer to the raw data.
virtual tInt GetWidth() const =0
Returns the width of the image.
@ PF_BGRA_5551
16 bit BGRA (R: 5 bit, G: 5 bit, B: 5 bit, Alpha:1bit)
@ PF_32BIT
32 bit This definition is a placeholder a 32 Bit format, bitorder is undefined.
@ PF_RGB_888
24 bit RGB (R: 8 bit, G: 8 bit, B: 8 bit) - default format for 24 bpp
@ PF_GREYSCALE_FLOAT32
32 bit greyscale float value
@ PF_GREYSCALE_10
10 bit greyscale To setup Format use tBitmapFormat::nBitsPerPixel = 16 !
@ PF_YUV420P_888
24 bit YUV (Y: 8 bit, U: 8 bit, V: 8 bit) - Y = luminance, U+V = chrominance If using this format in ...
@ PF_16BIT
16 bit This definition is a placeholder a 16 Bit format, bitorder is undefined.
@ PF_GREYSCALE_24
24 bit greyscale
@ PF_RGBA_8888
32 bit RGBA (R: 8 bit, G: 8 bit, B: 8 bit, A: 8 bit) with alpha value - default format for 32 bpp
@ PF_RGB_555
15 bit RGB (R: 5 bit, G: 5 bit, B: 5 bit) - default format for 16 bpp
@ PF_xRGB_8888
32 bit aligned memory with only 24 Bit valid RGB data. A=255.
@ PF_RGB_565
16 bit RGB (R: 5 bit, G: 6 bit, B: 5 bit)
@ PF_BGRA_8888
32 bit BGRA (B: 8 bit, G: 8 bit, R: 8 bit, A: 8 bit) with alpha value - inverted RGB + A
@ PF_ARGB_1555
16 bit ARGB (R: 5 bit, G: 5 bit, B: 5 bit, Alpha:1bit)
@ PF_24BIT
24 bit This definition is a placeholder a 24 Bit format, bitorder is undefined.
@ PF_ABGR_1555
16 bit ABGR (R: 5 bit, G: 5 bit, B: 5 bit, Alpha:1bit)
@ PF_BGRx_8888
32 bit aligned memory with only 24 Bit valid RGB data. A=255.
@ PF_RGBx_8888
32 bit aligned memory with only 24 Bit valid RGB data. A=255.
@ PF_ARGB_8888
32 bit ARGB (A: 8 bit, R: 8 bit, G: 8 bit, B: 8 bit) with alpha value
@ PF_GREYSCALE_16
16 bit greyscale
@ PF_ABGR_8888
32 bit ABGR (A: 8 bit, B: 8 bit, G: 8 bit, R: 8 bit) with alpha value - inverted RGBA
@ PF_RGB_444
12 bit RGB (R: 4 bit, G: 4 bit, B: 4 bit)
@ PF_BGR_888
24 bit BGR (B: 8 bit, G: 8 bit, R: 8 bit) - inverted RGB
@ PF_GREYSCALE_8
8 bit greyscale - default format for 8 bpp
@ PF_xBGR_8888
32 bit aligned memory with only 24 Bit valid RGB data. A=255.
@ PF_UNKNOWN
unknown / not set
@ PF_GREYSCALE_12
12 bit greyscale To setup Format use tBitmapFormat::nBitsPerPixel = 16 !
@ PF_RGBA_5551
16 bit RGBA (R: 5 bit, G: 5 bit, B: 5 bit, Alpha:1bit)
@ PF_GREYSCALE_14
14 bit greyscale To setup Format use tBitmapFormat::nBitsPerPixel = 16 !
@ PF_ABGR_4444
16 bit ABGR (A: 4 bit, B: 4 bit, G: 4 bit, R: 4 bit) with alpha value - inverted RGBA
@ PF_RGB_8
8 bit RGB (R: 3 bit, G: 3 bit, B: 2 Bit) - palletized 8 bpp format
@ PF_RGBA_4444
16 bit RGBA (R: 4 bit, G: 4 bit, B: 4 bit, A: 4 bit) with alpha value
@ PF_GREYSCALE_32
32 bit greyscale
virtual tInt GetPixelFormat() const =0
Returns the pixel format.
virtual tInt GetBytesPerLine() const =0
Returns the bytes per line of the image.
@ LF_FLIP_VERTICAL
perform a vertical flip
@ LF_SWAP_RGB
this flag is ignored, since it is not longer needed
virtual tInt GetBitsPerPixel() const =0
Returns the bits per pixel of the image.
@ BLIT_VerticalFlip
Blit with vertical flip.
virtual tInt GetHeight() const =0
Returns the height of the image.
tUInt32 GetRGBA() const
Gets a four Byte value containing the 3 color channels and the alphachannel.
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.
tWin32BitmapInfo * GetBitmapInfo() override
Generates a Win32 image descriptor.
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.
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.
const tBitmapFormat * GetFormat() const override
Returns the current bitmap format of the image.
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.
tColor * GetPalette() const
Returns the color palette.
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.
static tChar const * GetPixelFormatIdentifier(const tInt nImage)
Returns the image format as string (enum to string)
tResult FlipRGB()
Flips RGB to BGR and the other way around.
tUInt8 * GetBitmapLine(tInt y) const
Returns a pointer to raw data of a line.
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.
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.
cImage(const IImage &oImage)
Copy constructor.
tResult GetBits(tUInt8 *pDestBitmapData, const tBitmapFormat *psDestBitmapFormat, tInt nFlags=0)
Retrieves the image's bitmap data.
disptb::graphicslib::dengar::cImage & operator=(const disptb::graphicslib::dengar::cImage &oImage)
Set the current image to the image oImage.
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.
char const * GetPixelFormatStr() const
Retrieves the image's pixel format as string.
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.
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.
tUInt8 * GetBitmap() const
Returns a pointer to the raw data.
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.
tResult Convert(tInt oPixelFormat)
Converts the image to a new image format.
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
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
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.
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
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Namespace for functionality provided by the Display Toolbox.
Struct to get the informations and the color about a bitmap.