diff options
author | Luboš Luňák <l.lunak@centrum.cz> | 2020-05-21 15:02:37 +0000 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2020-05-22 13:25:56 +0200 |
commit | aff8471dbffdd6d26e63533d7ffa8ddea6b2396b (patch) | |
tree | 462ec7a678be8233ac69b0a3398e38f4455376fb | |
parent | c200aa27ee4a0f5a89af6e970c2c22580029eded (diff) |
convert properly SkiaSalBitmap to WinSalBitmap (tdf#133152)
The code didn't account for topdown bitmaps.
Change-Id: Ia326834cfd6d2d022579fdde24828f7e0a8d8b3e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94643
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r-- | vcl/inc/skia/salbmp.hxx | 1 | ||||
-rw-r--r-- | vcl/win/gdi/salgdi2.cxx | 19 |
2 files changed, 16 insertions, 4 deletions
diff --git a/vcl/inc/skia/salbmp.hxx b/vcl/inc/skia/salbmp.hxx index 7eb2a8eb72a6..0761217d4eb9 100644 --- a/vcl/inc/skia/salbmp.hxx +++ b/vcl/inc/skia/salbmp.hxx @@ -60,6 +60,7 @@ public: virtual bool InterpretAs8Bit() override; virtual bool ConvertToGreyscale() override; + const BitmapPalette& Palette() const { return mPalette; } // Returns the contents as SkImage (possibly GPU-backed). const sk_sp<SkImage>& GetSkImage() const; diff --git a/vcl/win/gdi/salgdi2.cxx b/vcl/win/gdi/salgdi2.cxx index 6ccf3140c169..fdac864d0f32 100644 --- a/vcl/win/gdi/salgdi2.cxx +++ b/vcl/win/gdi/salgdi2.cxx @@ -43,6 +43,7 @@ #include <config_features.h> #if HAVE_FEATURE_SKIA #include <skia/win/gdiimpl.hxx> +#include <skia/salbmp.hxx> #endif @@ -113,6 +114,10 @@ void convertToWinSalBitmap(SalBitmap& rSalBitmap, WinSalBitmap& rWinSalBitmap) { aBitmapPalette = pGLSalBitmap->GetBitmapPalette(); } +#if HAVE_FEATURE_SKIA + if(SkiaSalBitmap* pSkiaSalBitmap = dynamic_cast<SkiaSalBitmap*>(&rSalBitmap)) + aBitmapPalette = pSkiaSalBitmap->Palette(); +#endif BitmapBuffer* pRead = rSalBitmap.AcquireBuffer(BitmapAccessMode::Read); @@ -121,13 +126,19 @@ void convertToWinSalBitmap(SalBitmap& rSalBitmap, WinSalBitmap& rWinSalBitmap) sal_uInt8* pSource(pRead->mpBits); sal_uInt8* pDestination(pWrite->mpBits); + long readRowChange = pRead->mnScanlineSize; + if(pRead->mnFormat & ScanlineFormat::TopDown) + { + pSource += pRead->mnScanlineSize * (pRead->mnHeight - 1); + readRowChange = -readRowChange; + } std::unique_ptr<ColorScanlineConverter> pConverter; - if (pRead->mnFormat == ScanlineFormat::N24BitTcRgb) + if (RemoveScanline(pRead->mnFormat) == ScanlineFormat::N24BitTcRgb) pConverter.reset(new ColorScanlineConverter(ScanlineFormat::N24BitTcRgb, 3, pRead->mnScanlineSize)); - else if (pRead->mnFormat == ScanlineFormat::N32BitTcRgba) + else if (RemoveScanline(pRead->mnFormat) == ScanlineFormat::N32BitTcRgba) pConverter.reset(new ColorScanlineConverter(ScanlineFormat::N32BitTcRgba, 4, pRead->mnScanlineSize)); if (pConverter) @@ -135,7 +146,7 @@ void convertToWinSalBitmap(SalBitmap& rSalBitmap, WinSalBitmap& rWinSalBitmap) for (long y = 0; y < pRead->mnHeight; y++) { pConverter->convertScanline(pSource, pDestination); - pSource += pRead->mnScanlineSize; + pSource += readRowChange; pDestination += pWrite->mnScanlineSize; } } @@ -144,7 +155,7 @@ void convertToWinSalBitmap(SalBitmap& rSalBitmap, WinSalBitmap& rWinSalBitmap) for (long y = 0; y < pRead->mnHeight; y++) { memcpy(pDestination, pSource, pRead->mnScanlineSize); - pSource += pRead->mnScanlineSize; + pSource += readRowChange; pDestination += pWrite->mnScanlineSize; } } |