[ATL][ATL_APITEST] CImage testcase should cover all formats (#5653)

Strengthen CImage testcase and improve CImage class.
ROSTESTS-387, CORE-19008
This commit is contained in:
Katayama Hirofumi MZ 2023-09-09 08:42:55 +09:00 committed by GitHub
parent fdeb169a27
commit 97b64c45c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 326 additions and 229 deletions

View file

@ -33,8 +33,8 @@ public:
enum DIBOrientation
{
DIBOR_DEFAULT, // default
DIBOR_BOTTOMUP, // bottom-up DIB
DIBOR_TOPDOWN // top-down DIB
DIBOR_TOPDOWN, // top-down DIB
DIBOR_BOTTOMUP // bottom-up DIB
};
CImage() noexcept
@ -283,6 +283,17 @@ public:
return pb;
}
const void *GetBits() const noexcept
{
ATLASSERT(IsDIBSection());
const BYTE *pb = (const BYTE *)m_bm.bmBits;
if (m_eOrientation == DIBOR_BOTTOMUP)
{
pb += m_bm.bmWidthBytes * (m_bm.bmHeight - 1);
}
return pb;
}
int GetBPP() const noexcept
{
ATLASSERT(m_hBitmap);
@ -350,6 +361,15 @@ public:
return pb;
}
const void* GetPixelAddress(int x, int y) const noexcept
{
ATLASSERT(IsDIBSection());
const BYTE *pb = (const BYTE *)GetBits();
pb += GetPitch() * y;
pb += (GetBPP() * x) / 8;
return pb;
}
COLORREF GetTransparentColor() const noexcept
{
return m_clrTransparentColor;
@ -1020,6 +1040,8 @@ private:
}
private:
// FIXME: MS ATL CImage has m_nWidth, m_nHeight, m_nPitch, m_nBPP, and m_pBits.
// FIXME: MS ATL CImage hasn't m_eOrientation, m_bm, and m_ds.
HBITMAP m_hBitmap;
mutable HBITMAP m_hOldBitmap;
mutable HDC m_hDC;
@ -1142,14 +1164,22 @@ private:
m_bIsDIBSection = (::GetObject(hBitmap, size, &m_ds) == size);
bool bOK = (::GetObject(hBitmap, sizeof(BITMAP), &m_bm) != 0);
if (!bOK)
return;
if (bOK)
m_hBitmap = hBitmap;
if (m_bIsDIBSection && eOrientation == DIBOR_DEFAULT)
{
m_hBitmap = hBitmap;
m_eOrientation = eOrientation;
m_bHasAlphaChannel = (m_bm.bmBitsPixel == 32);
m_clrTransparentColor = CLR_INVALID;
if (m_ds.dsBmih.biHeight < 0)
eOrientation = DIBOR_TOPDOWN;
else
eOrientation = DIBOR_BOTTOMUP;
}
m_eOrientation = eOrientation;
m_bHasAlphaChannel = (m_bm.bmBitsPixel == 32);
m_clrTransparentColor = CLR_INVALID;
}
BOOL CreateInternal(int nWidth, int nHeight, int nBPP,