summaryrefslogtreecommitdiff
path: root/vcl/source/gdi/bitmap3.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-06-25 16:36:28 +0100
committerAndras Timar <andras.timar@collabora.com>2014-06-29 14:49:02 -0700
commitc97f745f328dd2cfccfcda5ed6460aae0085251a (patch)
treeb2e3eacac87856ef276d2a138ca9d4328499e01e /vcl/source/gdi/bitmap3.cxx
parent22a09c25c8f56e3aab3ac1de6009461b4f063862 (diff)
Related: fdo#33455 retain color on scaling of 1 bit depth pngs
load test doc and zoom in and out and at certain zoom levels its correctly black and at others its red (cherry picked from commit be9d65bb5f5a83c19eec02a037b8f808de70ecb8) Change-Id: I445ce672742ddb6d6592ef419bf5e14c5f09a5b5 Reviewed-on: https://gerrit.libreoffice.org/9923 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'vcl/source/gdi/bitmap3.cxx')
-rw-r--r--vcl/source/gdi/bitmap3.cxx28
1 files changed, 18 insertions, 10 deletions
diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx
index 4fbe1b8e156d..ede020c488c3 100644
--- a/vcl/source/gdi/bitmap3.cxx
+++ b/vcl/source/gdi/bitmap3.cxx
@@ -857,9 +857,7 @@ sal_Bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, sal_uInt32
{
bool bRetval(false);
-#ifdef DBG_UTIL
const sal_uInt16 nStartCount(GetBitCount());
-#endif
if(basegfx::fTools::equalZero(rScaleX) || basegfx::fTools::equalZero(rScaleY))
{
@@ -873,6 +871,22 @@ sal_Bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, sal_uInt32
bRetval = true;
}
+ //fdo#33455
+ //
+ //If we start with a 1 bit image, then after scaling it in any mode except
+ //BMP_SCALE_FAST we have a a 24bit image which is perfectly correct, but we
+ //are going to down-shift it to mono again and Bitmap::ImplMakeMono just
+ //has "Bitmap aNewBmp( GetSizePixel(), 1 );" to create a 1 bit bitmap which
+ //will default to black/white and the colors mapped to which ever is closer
+ //to black/white
+ //
+ //So the easiest thing to do to retain the colors of 1 bit bitmaps is to
+ //just use the fast scale rather than attempting to count unique colors in
+ //the other converters and pass all the info down through
+ //Bitmap::ImplMakeMono
+ if (nStartCount == 1 && nScaleFlag != BMP_SCALE_NONE)
+ nScaleFlag = BMP_SCALE_FAST;
+
switch(nScaleFlag)
{
case BMP_SCALE_NONE :
@@ -892,7 +906,7 @@ sal_Bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, sal_uInt32
}
case BMP_SCALE_SUPER :
{
- if(GetSizePixel().Width() < 2 || GetSizePixel().Height() < 2)
+ if (GetSizePixel().Width() < 2 || GetSizePixel().Height() < 2)
{
// fallback to ImplScaleFast
bRetval = ImplScaleFast( rScaleX, rScaleY );
@@ -934,13 +948,7 @@ sal_Bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, sal_uInt32
}
}
-#ifdef DBG_UTIL
- if(bRetval && nStartCount != GetBitCount())
- {
- OSL_ENSURE(false, "Bitmap::Scale has changed the ColorDepth, this should *not* happen (!)");
- }
-#endif
-
+ OSL_ENSURE(!bRetval || nStartCount == GetBitCount(), "Bitmap::Scale has changed the ColorDepth, this should *not* happen (!)");
return bRetval;
}