diff options
author | Armin Le Grand <alg@apache.org> | 2013-10-29 17:40:43 +0000 |
---|---|---|
committer | Armin Le Grand <alg@apache.org> | 2013-10-29 17:40:43 +0000 |
commit | ba54ce4fc788605fc96235f432b455311faee406 (patch) | |
tree | 9315fd0008e5eb512f047f1dc3e77beac3e36ea0 /drawinglayer | |
parent | f15874d8f976f3874bdbcb53429eeefa65c28841 (diff) |
i123564 corrected some aspects when working whith bitmaps with low color depth or small size
Notes
merged as: 36f21914b31a28f75ec2195c266424a18408f747
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/source/processor2d/vclprocessor2d.cxx | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index 59ef189d4240..b14fdc6c4140 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -470,8 +470,9 @@ namespace drawinglayer aGraphicRange.transform(mpOutputDevice->GetViewTransformation() * aLocalTransform); // extract discrete size of graphic - const sal_Int32 nBWidth(basegfx::fround(aGraphicRange.getWidth())); - const sal_Int32 nBHeight(basegfx::fround(aGraphicRange.getHeight())); + // caution: when getting to zero, nothing would be painted; thus, do not allow this + const sal_Int32 nBWidth(std::max(sal_Int32(1), basegfx::fround(aGraphicRange.getWidth()))); + const sal_Int32 nBHeight(std::max(sal_Int32(1), basegfx::fround(aGraphicRange.getHeight()))); // only do something when bitmap fill has a size in discrete units if(nBWidth > 0 && nBHeight > 0) @@ -483,9 +484,17 @@ namespace drawinglayer static bool bEnablePreScaling(true); const bool bPreScaled(bEnablePreScaling && nBWidth * nBHeight < (250 * 250)); + // ... but only up to a maximum size, else it gets too expensive if(bPreScaled) { - // ... but only up to a maximum size, else it gets too expensive + // if color depth is below 24bit, expand before scaling for better quality. + // This is even needed for low colors, else the scale will produce + // a bitmap in gray or Black/White (!) + if(aBitmapEx.GetBitCount() < 24) + { + aBitmapEx.Convert(BMP_CONVERSION_24BIT); + } + aBitmapEx.Scale(aNeededBitmapSizePixel, BMP_SCALE_INTERPOLATE); } |