Kaydet (Commit) 05c870ef authored tarafından Armin Le Grand's avatar Armin Le Grand Kaydeden (comit) Caolán McNamara

Related: #i122923# win only: improved bitmap handling for rendering

(cherry picked from commit 07302c14)

Change-Id: Iba5303085bf4d6fcc79c0d04197429c436666e15
üst 741c430f
...@@ -334,22 +334,21 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap() ...@@ -334,22 +334,21 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap()
sal_uInt8* pSrcRGB(pRGB->mpBits); sal_uInt8* pSrcRGB(pRGB->mpBits);
const sal_uInt32 nExtraRGB(pRGB->mnScanlineSize - (nW * 3)); const sal_uInt32 nExtraRGB(pRGB->mnScanlineSize - (nW * 3));
const bool bTopDown(pRGB->mnFormat & BMP_FORMAT_TOP_DOWN); const bool bTopDown(pRGB->mnFormat & BMP_FORMAT_TOP_DOWN);
const Gdiplus::Rect aAllRect(0, 0, nW, nH);
Gdiplus::BitmapData aGdiPlusBitmapData;
pRetval->LockBits(&aAllRect, Gdiplus::ImageLockModeWrite, PixelFormat24bppRGB, &aGdiPlusBitmapData);
// copy data to Gdiplus::Bitmap; format is BGR here in both cases, so memcpy is possible
for(sal_uInt32 y(0); y < nH; y++) for(sal_uInt32 y(0); y < nH; y++)
{ {
const sal_uInt32 nYInsert(bTopDown ? y : nH - y - 1); const sal_uInt32 nYInsert(bTopDown ? y : nH - y - 1);
sal_uInt8* targetPixels = (sal_uInt8*)aGdiPlusBitmapData.Scan0 + (nYInsert * aGdiPlusBitmapData.Stride);
for(sal_uInt32 x(0); x < nW; x++) memcpy(targetPixels, pSrcRGB, nW * 3);
{ pSrcRGB += nW * 3 + nExtraRGB;
const sal_uInt8 nB(*pSrcRGB++);
const sal_uInt8 nG(*pSrcRGB++);
const sal_uInt8 nR(*pSrcRGB++);
pRetval->SetPixel(x, nYInsert, Gdiplus::Color(nR, nG, nB));
}
pSrcRGB += nExtraRGB;
} }
pRetval->UnlockBits(&aGdiPlusBitmapData);
} }
} }
...@@ -464,24 +463,30 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlph ...@@ -464,24 +463,30 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlph
const sal_uInt32 nExtraRGB(pRGB->mnScanlineSize - (nW * 3)); const sal_uInt32 nExtraRGB(pRGB->mnScanlineSize - (nW * 3));
const sal_uInt32 nExtraA(pA->mnScanlineSize - nW); const sal_uInt32 nExtraA(pA->mnScanlineSize - nW);
const bool bTopDown(pRGB->mnFormat & BMP_FORMAT_TOP_DOWN); const bool bTopDown(pRGB->mnFormat & BMP_FORMAT_TOP_DOWN);
const Gdiplus::Rect aAllRect(0, 0, nW, nH);
Gdiplus::BitmapData aGdiPlusBitmapData;
pRetval->LockBits(&aAllRect, Gdiplus::ImageLockModeWrite, PixelFormat32bppARGB, &aGdiPlusBitmapData);
// copy data to Gdiplus::Bitmap; format is BGRA; need to mix BGR from Bitmap and
// A from alpha, so inner loop is needed (who invented BitmapEx..?)
for(sal_uInt32 y(0); y < nH; y++) for(sal_uInt32 y(0); y < nH; y++)
{ {
const sal_uInt32 nYInsert(bTopDown ? y : nH - y - 1); const sal_uInt32 nYInsert(bTopDown ? y : nH - y - 1);
sal_uInt8* targetPixels = (sal_uInt8*)aGdiPlusBitmapData.Scan0 + (nYInsert * aGdiPlusBitmapData.Stride);
for(sal_uInt32 x(0); x < nW; x++) for(sal_uInt32 x(0); x < nW; x++)
{ {
const sal_uInt8 nB(*pSrcRGB++); *targetPixels++ = *pSrcRGB++;
const sal_uInt8 nG(*pSrcRGB++); *targetPixels++ = *pSrcRGB++;
const sal_uInt8 nR(*pSrcRGB++); *targetPixels++ = *pSrcRGB++;
const sal_uInt8 nA(0xff - *pSrcA++); *targetPixels++ = 0xff - *pSrcA++;
pRetval->SetPixel(x, nYInsert, Gdiplus::Color(nA, nR, nG, nB));
} }
pSrcRGB += nExtraRGB; pSrcRGB += nExtraRGB;
pSrcA += nExtraA; pSrcA += nExtraA;
} }
pRetval->UnlockBits(&aGdiPlusBitmapData);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment