summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-03-01 12:00:24 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-03-01 12:40:03 +0100
commit3d400321910ff0fe89ab8c70c59432e676cb1340 (patch)
treeb75317083d3a3cc452ad38b095d74f92b51a7923 /vcl
parenteb1049597bd92d61a2ad319bc9a2c3f9a08dd259 (diff)
tdf#116001 Incorrect Colors in Chart Wall Area
regression from commit b10c7022f1be6e4825269bd5872575b5b53744ef "use RawBitmap in BPixelRasterToBitmapEx" we need to implement alpha support in vcl::bitmap::CreateFromData Change-Id: I68bebbe1dd15e3bb04de312309c1631d6bb7fe2d Reviewed-on: https://gerrit.libreoffice.org/50556 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/bitmap/BitmapTools.cxx35
1 files changed, 29 insertions, 6 deletions
diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx
index a171fd848a39..beda990e5b03 100644
--- a/vcl/source/bitmap/BitmapTools.cxx
+++ b/vcl/source/bitmap/BitmapTools.cxx
@@ -148,7 +148,7 @@ BitmapEx CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHe
{
for( long y = 0; y < nHeight; ++y )
{
- sal_uInt8 const *p = pData + y * nStride;
+ sal_uInt8 const *p = pData + (y * nStride);
Scanline pScanline = pWrite->GetScanline(y);
for (long x = 0; x < nWidth; ++x)
{
@@ -158,7 +158,7 @@ BitmapEx CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHe
}
if (nBitCount == 32)
{
- p = pData + y * nStride + 3;
+ p = pData + (y * nStride) + 3;
Scanline pMaskScanLine = xMaskAcc->GetScanline(y);
for (long x = 0; x < nWidth; ++x)
{
@@ -179,27 +179,50 @@ BitmapEx CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHe
*/
BitmapEx CreateFromData( RawBitmap&& rawBitmap )
{
- Bitmap aBmp( rawBitmap.maSize, /*nBitCount*/24 );
+ auto nBitCount = rawBitmap.GetBitCount();
+ assert( nBitCount == 24 || nBitCount == 32);
+ Bitmap aBmp( rawBitmap.maSize, nBitCount );
Bitmap::ScopedWriteAccess pWrite(aBmp);
assert(pWrite.get());
if( !pWrite )
return BitmapEx();
+ std::unique_ptr<AlphaMask> pAlphaMask;
+ AlphaMask::ScopedWriteAccess xMaskAcc;
+ if (nBitCount == 32)
+ {
+ pAlphaMask.reset( new AlphaMask( rawBitmap.maSize ) );
+ xMaskAcc = AlphaMask::ScopedWriteAccess(*pAlphaMask);
+ }
auto nHeight = rawBitmap.maSize.getHeight();
auto nWidth = rawBitmap.maSize.getWidth();
+ auto nStride = nWidth * nBitCount / 8;
for( long y = 0; y < nHeight; ++y )
{
- sal_uInt8 const *p = rawBitmap.mpData.get() + (y * nWidth * 3);
+ sal_uInt8 const *p = rawBitmap.mpData.get() + (y * nStride);
Scanline pScanline = pWrite->GetScanline(y);
for (long x = 0; x < nWidth; ++x)
{
BitmapColor col(p[0], p[1], p[2]);
pWrite->SetPixelOnData(pScanline, x, col);
- p += 3;
+ p += nBitCount/8;
+ }
+ if (nBitCount == 32)
+ {
+ p = rawBitmap.mpData.get() + (y * nStride) + 3;
+ Scanline pMaskScanLine = xMaskAcc->GetScanline(y);
+ for (long x = 0; x < nWidth; ++x)
+ {
+ xMaskAcc->SetPixelOnData(pMaskScanLine, x, BitmapColor(*p));
+ p += 4;
+ }
}
}
- return aBmp;
+ if (nBitCount == 32)
+ return BitmapEx(aBmp, *pAlphaMask);
+ else
+ return aBmp;
}
#if ENABLE_CAIRO_CANVAS