diff options
author | Armin Le Grand <alg@apache.org> | 2013-10-29 17:40:43 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-11-05 12:37:15 +0000 |
commit | 36f21914b31a28f75ec2195c266424a18408f747 (patch) | |
tree | fae33ceb49e725416a2e154862d3dd83c534d8dc /drawinglayer | |
parent | 7098f83ec3121f2fb8d077795575c600744ed85a (diff) |
Resolves: i123564 corrected some aspects when working with bitmaps...
with low color depth or small size
(cherry picked from commit ba54ce4fc788605fc96235f432b455311faee406)
Conflicts:
cui/source/tabpages/tpbitmap.cxx
Change-Id: I10677414ab7d1904dbb29cd395a0c0334e0faa03
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 cf5289a484bd..1cd768e9a31a 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -484,8 +484,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) @@ -497,9 +498,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); } |