summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorAriel Constenla-Haile <arielch@apache.org>2012-07-06 16:11:37 +0100
committerMichael Meeks <michael.meeks@suse.com>2012-07-06 20:29:14 +0100
commit7ec3e51acad7c32cd0bdb5f221fc2f4047c3a4a4 (patch)
tree627b410bc46ccc12abf5497b322ae362aa4adc58 /sfx2
parente2799d253b1dc62967693aa5bccd7360a9520967 (diff)
Check if Bitmap is empty before trying to scale it
http://svn.apache.org/viewvc?view=revision&revision=1224936
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/dialog/filedlghelper.cxx44
1 files changed, 23 insertions, 21 deletions
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index eaca88fe4cb1..5ca226d1c8d6 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -721,34 +721,36 @@ IMPL_LINK_NOARG(FileDialogHelper_Impl, TimeOutHdl_Impl)
// 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 );
- // Convert to true color, to allow CopyPixel
- aBmp.Convert( BMP_CONVERSION_24BIT );
+ // 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;
+ }
}
}