diff options
author | Ariel Constenla-Haile <arielch@apache.org> | 2011-12-27 14:57:39 +0000 |
---|---|---|
committer | Ariel Constenla-Haile <arielch@apache.org> | 2011-12-27 14:57:39 +0000 |
commit | b79141bda8fdbc778ce647639a803bd4122b4930 (patch) | |
tree | 5b2ce346c9fc907392383437309576b6c36fbad9 | |
parent | 7e2a4b19f5959fad601ac24c161ca512b0a9cf25 (diff) |
Check if Bitmap is empty before trying to scale it
Notes
Notes:
merged as: 7ec3e51acad7c32cd0bdb5f221fc2f4047c3a4a4
-rw-r--r-- | sfx2/source/dialog/filedlghelper.cxx | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 9a862d8222f8..0a945ac8652d 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -749,34 +749,36 @@ IMPL_LINK( FileDialogHelper_Impl, TimeOutHdl_Impl, Timer*, EMPTYARG ) // proper position and painting a frame Bitmap aBmp = maGraphic.GetBitmap(); + if ( !aBmp.IsEmpty() ) + { + // scale the bitmap to the correct size + sal_Int32 nOutWidth = xFilePicker->getAvailableWidth(); + sal_Int32 nOutHeight = xFilePicker->getAvailableHeight(); + sal_Int32 nBmpWidth = aBmp.GetSizePixel().Width(); + sal_Int32 nBmpHeight = aBmp.GetSizePixel().Height(); - // scale the bitmap to the correct size - sal_Int32 nOutWidth = xFilePicker->getAvailableWidth(); - sal_Int32 nOutHeight = xFilePicker->getAvailableHeight(); - sal_Int32 nBmpWidth = aBmp.GetSizePixel().Width(); - sal_Int32 nBmpHeight = aBmp.GetSizePixel().Height(); - - double nXRatio = (double) nOutWidth / nBmpWidth; - double nYRatio = (double) nOutHeight / nBmpHeight; + double nXRatio = (double) nOutWidth / nBmpWidth; + double nYRatio = (double) nOutHeight / nBmpHeight; - if ( nXRatio < nYRatio ) - aBmp.Scale( nXRatio, nXRatio ); - else - aBmp.Scale( nYRatio, nYRatio ); + if ( nXRatio < nYRatio ) + aBmp.Scale( nXRatio, nXRatio ); + else + aBmp.Scale( nYRatio, nYRatio ); - // #94505# Convert to true color, to allow CopyPixel - aBmp.Convert( BMP_CONVERSION_24BIT ); + // #94505# Convert to true color, to allow CopyPixel + aBmp.Convert( BMP_CONVERSION_24BIT ); - // and copy it into the Any - SvMemoryStream aData; + // and copy it into the Any + SvMemoryStream aData; - aData << aBmp; + aData << aBmp; - const Sequence < sal_Int8 > aBuffer( - static_cast< const sal_Int8* >(aData.GetData()), - aData.GetEndOfData() ); + const Sequence < sal_Int8 > aBuffer( + static_cast< const sal_Int8* >(aData.GetData()), + aData.GetEndOfData() ); - aAny <<= aBuffer; + aAny <<= aBuffer; + } } } |