summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2019-09-23 18:53:09 +0200
committerLuboš Luňák <l.lunak@collabora.com>2019-11-27 09:55:06 +0100
commit06986d2eb8154230f2980567a80344c12a5e87e8 (patch)
tree7980d3d9f5519c722f4491d8016d0042b5cb4422 /vcl/source
parent17e61ec9620bdb52232428d8a94d0731d2c4a4fa (diff)
better support for <8 bpp in SkiaSalBitmap
Change-Id: Ife79abfb9c36925405fd0b7da40f5274c0339117
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/bitmap/salbmp.cxx43
1 files changed, 43 insertions, 0 deletions
diff --git a/vcl/source/bitmap/salbmp.cxx b/vcl/source/bitmap/salbmp.cxx
index 0cf6fd3ab93a..c7183e117598 100644
--- a/vcl/source/bitmap/salbmp.cxx
+++ b/vcl/source/bitmap/salbmp.cxx
@@ -184,4 +184,47 @@ std::unique_ptr< sal_uInt8[] > SalBitmap::convertDataTo24Bpp( const sal_uInt8* s
return data;
}
+std::unique_ptr< sal_uInt8[] > SalBitmap::convertDataTo32Bpp( const sal_uInt8* src,
+ int width, int height, int bitCount, int bytesPerRow, const BitmapPalette& palette, bool toBgra )
+{
+ std::unique_ptr< sal_uInt8[] > data( new sal_uInt8[width * height * 4] );
+ std::unique_ptr<ImplPixelFormat> pSrcFormat(ImplPixelFormat::GetFormat(bitCount, palette));
+
+ const sal_uInt8* pSrcData = src;
+ sal_uInt8* pDstData = data.get();
+
+ sal_uInt32 nY = height;
+ while( nY-- )
+ {
+ pSrcFormat->StartLine( pSrcData );
+
+ sal_uInt32 nX = width;
+ if (toBgra)
+ {
+ while( nX-- )
+ {
+ const BitmapColor& c = pSrcFormat->ReadPixel();
+ *pDstData++ = c.GetBlue();
+ *pDstData++ = c.GetGreen();
+ *pDstData++ = c.GetRed();
+ *pDstData++ = 0xff;
+ }
+ }
+ else // RGBA
+ {
+ while( nX-- )
+ {
+ const BitmapColor& c = pSrcFormat->ReadPixel();
+ *pDstData++ = c.GetRed();
+ *pDstData++ = c.GetGreen();
+ *pDstData++ = c.GetBlue();
+ *pDstData++ = 0xff;
+ }
+ }
+
+ pSrcData += bytesPerRow;
+ }
+ return data;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */