summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2012-10-10 09:19:15 +0000
committerArmin Le Grand <alg@apache.org>2012-10-10 09:19:15 +0000
commit54c0f6f5b605ae05eade910fd2b672adf1d0d7fc (patch)
tree6512502a7f79c7ff2e54b3a9210aa8c8db870886 /vcl
parent424079cb8348d77e40f7d3291578bdffbe662f34 (diff)
#121183# Added buffering non-bitmap formats in Graphic
Notes
Notes: merged as: 7567b64e7d1009e8a51e06204480c341c99c0410
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/gdi/impgraph.cxx116
1 files changed, 65 insertions, 51 deletions
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 9db1168156ee..dec4f063dfb0 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -554,74 +554,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 )
@@ -654,8 +661,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;