diff options
author | Rüdiger Timm <rt@openoffice.org> | 2007-04-26 09:37:15 +0000 |
---|---|---|
committer | Rüdiger Timm <rt@openoffice.org> | 2007-04-26 09:37:15 +0000 |
commit | e646727bd359182a4db5d606f490393ad3deb70a (patch) | |
tree | 815fdff70240028dbc6e10bb132863c2f25bde1d /vcl/source/gdi/outdev2.cxx | |
parent | 6a46f7ff102281fc8b59191badd1d7f9f714484e (diff) |
INTEGRATION: CWS vcl75 (1.33.86); FILE MERGED
2007/03/13 19:01:27 pl 1.33.86.1: #i75264# limit sclaed bitmap output to a reasonable size
Diffstat (limited to 'vcl/source/gdi/outdev2.cxx')
-rw-r--r-- | vcl/source/gdi/outdev2.cxx | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/vcl/source/gdi/outdev2.cxx b/vcl/source/gdi/outdev2.cxx index 23d0087cf31b..d9aa894d192f 100644 --- a/vcl/source/gdi/outdev2.cxx +++ b/vcl/source/gdi/outdev2.cxx @@ -4,9 +4,9 @@ * * $RCSfile: outdev2.cxx,v $ * - * $Revision: 1.33 $ + * $Revision: 1.34 $ * - * last change: $Author: ihi $ $Date: 2006-11-14 15:22:58 $ + * last change: $Author: rt $ $Date: 2007-04-26 10:37:15 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -712,6 +712,54 @@ void OutputDevice::ImplDrawBitmap( const Point& rDestPt, const Size& rDestSize, if ( nMirrFlags ) aBmp.Mirror( nMirrFlags ); + /* #i75264# + * sometimes a bitmap is scaled to a ridiculous size and drawn + * to a quite normal VDev, so only a very small part of + * the scaled bitmap will be visible. However actually scaling + * the bitmap will use so much memory that we end with a crash. + * Workaround: since only a small part of the scaled bitmap will + * be actually drawn anyway (because of clipping on the device + * boundary), limit the destination and source rectangles so + * that the destination rectangle will overlap the device but only + * be reasonably (say factor 2) larger than the device itself. + */ + if( aPosAry.mnDestWidth > 2048 || aPosAry.mnDestHeight > 2048 ) + { + if( meOutDevType == OUTDEV_WINDOW || + (meOutDevType == OUTDEV_VIRDEV && mpPDFWriter == 0 ) ) + { + // reduce scaling to something reasonable taking into account the output size + if( aPosAry.mnDestWidth > 3*mnOutWidth ) + { + int nFactor = aPosAry.mnDestWidth/(mnOutWidth*2); + long nNewDestWidth = aPosAry.mnDestWidth/nFactor; + long nNewSrcWidth = aPosAry.mnSrcWidth/nFactor; + if( aPosAry.mnDestX + nNewDestWidth < (mnOutWidth*3/2) ) + { + int nMoveTile = -aPosAry.mnDestX / nNewDestWidth; + aPosAry.mnDestX += nMoveTile * nNewDestWidth; + aPosAry.mnSrcX += nMoveTile * nNewSrcWidth; + } + aPosAry.mnDestWidth = nNewDestWidth; + aPosAry.mnSrcWidth = nNewSrcWidth; + } + if( aPosAry.mnDestHeight > 3*mnOutHeight ) + { + int nFactor = aPosAry.mnDestHeight/(mnOutHeight*2); + long nNewDestHeight = aPosAry.mnDestHeight/nFactor; + long nNewSrcHeight = aPosAry.mnSrcHeight/nFactor; + if( aPosAry.mnDestY + nNewDestHeight < (mnOutHeight*3/2) ) + { + int nMoveTile = -aPosAry.mnDestY / nNewDestHeight; + aPosAry.mnDestY += nMoveTile * nNewDestHeight; + aPosAry.mnSrcY += nMoveTile * nNewSrcHeight; + } + aPosAry.mnDestHeight = nNewDestHeight; + aPosAry.mnSrcHeight = nNewSrcHeight; + } + } + } + mpGraphics->DrawBitmap( &aPosAry, *aBmp.ImplGetImpBitmap()->ImplGetSalBitmap(), this ); } } |