diff options
author | Armin Le Grand <alg@apache.org> | 2012-10-10 09:19:15 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-06-11 12:30:10 +0100 |
commit | 1691607cc44579bc8193db382d96038177acfc64 (patch) | |
tree | 0c8a621a5871c4ebe8213dc3859a4c9d7308b030 /vcl | |
parent | c0b78901dba033ed112a023a787575ae54ef877d (diff) |
Resolves: #i121183# Added buffering non-bitmap formats in Graphic
(cherry picked from commit 54c0f6f5b605ae05eade910fd2b672adf1d0d7fc)
Change-Id: I4117f4002b14cb8b3811422a5fcbae6a0d2a2d08
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/gdi/impgraph.cxx | 116 |
1 files changed, 65 insertions, 51 deletions
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 2bef0db497fe..01d0341bfa49 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -478,74 +478,81 @@ Bitmap ImpGraphic::ImplGetBitmap(const GraphicConversionParameters& rParameters) } else if( ( meType != GRAPHIC_DEFAULT ) && ImplIsSupportedGraphic() ) { - // calculate size - VirtualDevice aVDev; - Size aDrawSize(aVDev.LogicToPixel(maMetaFile.GetPrefSize(), maMetaFile.GetPrefMapMode())); - - if(rParameters.getSizePixel().Width() && rParameters.getSizePixel().Height()) + if(maEx.IsEmpty()) { - // apply given size if exists - aDrawSize = rParameters.getSizePixel(); - } + // calculate size + VirtualDevice aVDev; + Size aDrawSize(aVDev.LogicToPixel(maMetaFile.GetPrefSize(), maMetaFile.GetPrefMapMode())); - if(aDrawSize.Width() && aDrawSize.Height() && !rParameters.getUnlimitedSize() - && (aDrawSize.Width() > GRAPHIC_MTFTOBMP_MAXEXT || aDrawSize.Height() > GRAPHIC_MTFTOBMP_MAXEXT)) - { - // limit bitmap size to a maximum of GRAPHIC_MTFTOBMP_MAXEXT x GRAPHIC_MTFTOBMP_MAXEXT - double fWH((double)aDrawSize.Width() / (double)aDrawSize.Height()); - - if(fWH <= 1.0) + if(rParameters.getSizePixel().Width() && rParameters.getSizePixel().Height()) { - aDrawSize.setWidth(basegfx::fround(GRAPHIC_MTFTOBMP_MAXEXT * fWH)); - aDrawSize.setHeight(GRAPHIC_MTFTOBMP_MAXEXT); + // apply given size if exists + aDrawSize = rParameters.getSizePixel(); } - else + + if(aDrawSize.Width() && aDrawSize.Height() && !rParameters.getUnlimitedSize() + && (aDrawSize.Width() > GRAPHIC_MTFTOBMP_MAXEXT || aDrawSize.Height() > GRAPHIC_MTFTOBMP_MAXEXT)) { - aDrawSize.setWidth(GRAPHIC_MTFTOBMP_MAXEXT); - aDrawSize.setHeight(basegfx::fround(GRAPHIC_MTFTOBMP_MAXEXT / fWH)); + // limit bitmap size to a maximum of GRAPHIC_MTFTOBMP_MAXEXT x GRAPHIC_MTFTOBMP_MAXEXT + double fWH((double)aDrawSize.Width() / (double)aDrawSize.Height()); + + if(fWH <= 1.0) + { + aDrawSize.setWidth(basegfx::fround(GRAPHIC_MTFTOBMP_MAXEXT * fWH)); + aDrawSize.setHeight(GRAPHIC_MTFTOBMP_MAXEXT); + } + else + { + aDrawSize.setWidth(GRAPHIC_MTFTOBMP_MAXEXT); + aDrawSize.setHeight(basegfx::fround(GRAPHIC_MTFTOBMP_MAXEXT / fWH)); + } } - } - // calculate pixel size. Normally, it's the same as aDrawSize, but may - // need to be extended when hairlines are on the right or bottom edge - Size aPixelSize(aDrawSize); + // calculate pixel size. Normally, it's the same as aDrawSize, but may + // need to be extended when hairlines are on the right or bottom edge + Size aPixelSize(aDrawSize); - if(GRAPHIC_GDIMETAFILE == ImplGetType()) - { - // get hairline and full bound rect - Rectangle aHairlineRect; - const Rectangle aRect(maMetaFile.GetBoundRect(aVDev, &aHairlineRect)); + if(GRAPHIC_GDIMETAFILE == ImplGetType()) + { + // get hairline and full bound rect + Rectangle aHairlineRect; + const Rectangle aRect(maMetaFile.GetBoundRect(aVDev, &aHairlineRect)); + + if(!aRect.IsEmpty() && !aHairlineRect.IsEmpty()) + { + // expand if needed to allow bottom and right hairlines to be added + if(aRect.Right() == aHairlineRect.Right()) + { + aPixelSize.setWidth(aPixelSize.getWidth() + 1); + } - if(!aRect.IsEmpty() && !aHairlineRect.IsEmpty()) + if(aRect.Bottom() == aHairlineRect.Bottom()) + { + aPixelSize.setHeight(aPixelSize.getHeight() + 1); + } + } + } + + if(aVDev.SetOutputSizePixel(aPixelSize)) { - // expand if needed to allow bottom and right hairlines to be added - if(aRect.Right() == aHairlineRect.Right()) + if(rParameters.getAntiAliase()) { - aPixelSize.setWidth(aPixelSize.getWidth() + 1); + aVDev.SetAntialiasing(aVDev.GetAntialiasing() | ANTIALIASING_ENABLE_B2DDRAW); } - if(aRect.Bottom() == aHairlineRect.Bottom()) + if(rParameters.getSnapHorVerLines()) { - aPixelSize.setHeight(aPixelSize.getHeight() + 1); + aVDev.SetAntialiasing(aVDev.GetAntialiasing() | ANTIALIASING_PIXELSNAPHAIRLINE); } - } - } - if(aVDev.SetOutputSizePixel(aPixelSize)) - { - if(rParameters.getAntiAliase()) - { - aVDev.SetAntialiasing(aVDev.GetAntialiasing() | ANTIALIASING_ENABLE_B2DDRAW); - } + ImplDraw( &aVDev, Point(), aDrawSize ); - if(rParameters.getSnapHorVerLines()) - { - aVDev.SetAntialiasing(aVDev.GetAntialiasing() | ANTIALIASING_PIXELSNAPHAIRLINE); + // use maEx as local buffer for rendered metafile + const_cast< ImpGraphic* >(this)->maEx = aVDev.GetBitmap( Point(), aVDev.GetOutputSizePixel() ); } - - ImplDraw( &aVDev, Point(), aDrawSize ); - aRetBmp = aVDev.GetBitmap( Point(), aVDev.GetOutputSizePixel() ); } + + aRetBmp = maEx.GetBitmap(); } if( !!aRetBmp ) @@ -576,8 +583,15 @@ BitmapEx ImpGraphic::ImplGetBitmapEx(const GraphicConversionParameters& rParamet } else if( ( meType != GRAPHIC_DEFAULT ) && ImplIsSupportedGraphic() ) { - const ImpGraphic aMonoMask( maMetaFile.GetMonochromeMtf( COL_BLACK ) ); - aRetBmpEx = BitmapEx(ImplGetBitmap(rParameters), aMonoMask.ImplGetBitmap(rParameters)); + if(maEx.IsEmpty()) + { + const ImpGraphic aMonoMask( maMetaFile.GetMonochromeMtf( COL_BLACK ) ); + + // use maEx as local buffer for rendered metafile + const_cast< ImpGraphic* >(this)->maEx = BitmapEx(ImplGetBitmap(rParameters), aMonoMask.ImplGetBitmap(rParameters)); + } + + aRetBmpEx = maEx; } return aRetBmpEx; |