do not assume SalBitmap is zero-initialized (tdf#134152)
This code apparently expected that bitmaps are initialized with
the first color in the palette, but that's not guaranteed to be
the case (fails at least with Skia and X11 'gen' bitmaps).
Change-Id: Ie4f7412e0a6c4c1110fc5fbb8ab5bed3c96f652f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96864
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
(cherry picked from commit 7f75271f91862f333707aae065f40af4d96a89a9)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96873
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx
index cf46607..80c6879 100644
--- a/vcl/source/gdi/bitmapex.cxx
+++ b/vcl/source/gdi/bitmapex.cxx
@@ -1035,9 +1035,9 @@
// clear bitmap with dest color
if(aChangedBitmap.GetBitCount() <= 8)
{
// do NOT use erase; for e.g. 8bit Bitmaps, the nearest color to the given
// erase color is determined and used -> this may be different from what is
// wanted here. Better create a new bitmap with the needed color explicitly
// For e.g. 8bit Bitmaps, the nearest color to the given erase color is
// determined and used -> this may be different from what is wanted here.
// Better create a new bitmap with the needed color explicitly.
Bitmap::ScopedReadAccess xReadAccess(aChangedBitmap);
OSL_ENSURE(xReadAccess, "Got no Bitmap ReadAccess ?!?");
@@ -1051,10 +1051,7 @@
&aNewPalette);
}
}
else
{
aChangedBitmap.Erase(Color(pReplace->getBColor()));
}
aChangedBitmap.Erase(Color(pReplace->getBColor()));
}
else
{