vcl/source/gdi/bitmap3.cxx | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-)
New commits: commit db298f22a04e409a555d7c3ccec4c1dae91a6e1b Author: Caolán McNamara <caol...@redhat.com> Date: Wed Jun 25 16:36:28 2014 +0100 Related: fdo#33455 retain color on scaling of 1 bit depth pngs Change-Id: I445ce672742ddb6d6592ef419bf5e14c5f09a5b5 (cherry picked from commit be9d65bb5f5a83c19eec02a037b8f808de70ecb8) diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx index 7ee6405..0384e00 100644 --- a/vcl/source/gdi/bitmap3.cxx +++ b/vcl/source/gdi/bitmap3.cxx @@ -859,9 +859,7 @@ bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nSc { bool bRetval(false); -#ifdef DBG_UTIL const sal_uInt16 nStartCount(GetBitCount()); -#endif if(basegfx::fTools::equalZero(rScaleX) || basegfx::fTools::equalZero(rScaleY)) { @@ -875,6 +873,22 @@ bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nSc 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 : @@ -894,7 +908,7 @@ bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nSc } 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 ); @@ -936,13 +950,7 @@ bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nSc } } -#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; }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits