summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-02-13 13:41:55 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-02-14 07:29:01 +0100
commit6b4d3815a612b688cc5714f8b828a9cc9b109429 (patch)
tree87ee64a86a8af3bbff113fe1a41d35d4121857c7 /vcl
parent2168d709805a847ac012ff87b06e081ca139d064 (diff)
use BitmapTools in TIFFReader
part of making Bitmap an internal detail of vcl. This one is a little trickier because it constructs the palette after it reads the pixel data, so I couldn't use RawBitmap Change-Id: I2f501260beebb541ee451e78d551e13f182a01b1 Reviewed-on: https://gerrit.libreoffice.org/49665 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.cxx38
1 files changed, 29 insertions, 9 deletions
diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx
index 5f3d1062275e..4570be72e436 100644
--- a/vcl/source/bitmap/BitmapTools.cxx
+++ b/vcl/source/bitmap/BitmapTools.cxx
@@ -114,25 +114,45 @@ void loadFromSvg(SvStream& rStream, const OUString& sPath, BitmapEx& rBitmapEx,
BitmapEx CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride, sal_uInt16 nBitCount )
{
assert(nStride >= nWidth);
+ assert( nBitCount == 24 || nBitCount == 32);
Bitmap aBmp( Size( nWidth, nHeight ), nBitCount );
Bitmap::ScopedWriteAccess pWrite(aBmp);
assert(pWrite.get());
- if( pWrite.get() )
+ if( !pWrite )
+ return BitmapEx();
+ std::unique_ptr<AlphaMask> pAlphaMask;
+ AlphaMask::ScopedWriteAccess xMaskAcc;
+ if (nBitCount == 32)
{
- for( long y = 0; y < nHeight; ++y )
+ pAlphaMask.reset( new AlphaMask( Size(nWidth, nHeight) ) );
+ xMaskAcc = AlphaMask::ScopedWriteAccess(*pAlphaMask);
+ }
+ for( long y = 0; y < nHeight; ++y )
+ {
+ sal_uInt8 const *p = pData + y * nStride;
+ Scanline pScanline = pWrite->GetScanline(y);
+ for (long x = 0; x < nWidth; ++x)
{
- sal_uInt8 const *p = pData + y * nStride;
- Scanline pScanline = pWrite->GetScanline(y);
+ BitmapColor col(p[0], p[1], p[2]);
+ pWrite->SetPixelOnData(pScanline, x, col);
+ p += nBitCount/8;
+ }
+ if (nBitCount == 32)
+ {
+ p = pData + y * nStride + 3;
+ Scanline pMaskScanLine = xMaskAcc->GetScanline(y);
for (long x = 0; x < nWidth; ++x)
{
- BitmapColor col(p[0], p[1], p[2]);
- pWrite->SetPixelOnData(pScanline, x, col);
- p += 3;
+ xMaskAcc->SetPixelOnData(pMaskScanLine, x, BitmapColor(*p));
+ p += 4;
}
- }
+ }
}
- return aBmp;
+ if (nBitCount == 32)
+ return BitmapEx(aBmp, *pAlphaMask);
+ else
+ return aBmp;
}
/** Copy block of image data into the bitmap.