diff options
author | Carsten Driesner <cd@openoffice.org> | 2002-11-28 13:06:32 +0000 |
---|---|---|
committer | Carsten Driesner <cd@openoffice.org> | 2002-11-28 13:06:32 +0000 |
commit | ee35cc6336e4cb6abe3692619c5a182ea5b75820 (patch) | |
tree | 4206899e3303060829ddeff510f2d4b85a53edc7 /vcl/source/gdi/image.cxx | |
parent | 30ba77179739678ee484756a6bca75763e0ee980 (diff) |
#104553# Don't crash if AddImage is called with empty image. Use a transparent bitmap instead.
Diffstat (limited to 'vcl/source/gdi/image.cxx')
-rw-r--r-- | vcl/source/gdi/image.cxx | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/vcl/source/gdi/image.cxx b/vcl/source/gdi/image.cxx index a318aad09691..e30131defdae 100644 --- a/vcl/source/gdi/image.cxx +++ b/vcl/source/gdi/image.cxx @@ -2,9 +2,9 @@ * * $RCSfile: image.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: sb $ $Date: 2002-08-22 13:57:18 $ + * last change: $Author: cd $ $Date: 2002-11-28 14:06:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -987,10 +987,27 @@ void ImageList::AddImage( USHORT nId, const Image& rImage ) DBG_ASSERT( !mpImplData || (rImage.GetSizePixel() == mpImplData->maImageSize), "ImageList::AddImage(): Wrong Size" ); - ImageType eImageType = rImage.mpImplData->meType; - Size aImageSize = rImage.GetSizePixel(); + BOOL bHasImage = ( rImage.mpImplData != 0 ); + ImageType eImageType = IMAGETYPE_BITMAP; + Size aImageSize; USHORT nIndex; + if ( bHasImage ) + { + eImageType = rImage.mpImplData->meType; + aImageSize = rImage.GetSizePixel(); + } + else + { + if ( mpImplData ) + { + eImageType = IMAGETYPE_BITMAP; + aImageSize = mpImplData->maImageSize; + } + else + return; + } + if ( !mpImplData ) { mpImplData = new ImplImageList; @@ -1035,7 +1052,14 @@ void ImageList::AddImage( USHORT nId, const Image& rImage ) switch ( eImageType ) { case IMAGETYPE_BITMAP: - mpImplData->mpImageBitmap->Replace( nIndex, *((Bitmap*)rImage.mpImplData->mpData) ); + if ( !bHasImage ) + { + // Use empty b/w bitmap with correct size as empty image and black a transparent color + Bitmap aBitmap( aImageSize, 1 ); + mpImplData->mpImageBitmap->Replace( nIndex, aBitmap, COL_BLACK ); + } + else + mpImplData->mpImageBitmap->Replace( nIndex, *((Bitmap*)rImage.mpImplData->mpData) ); break; case IMAGETYPE_IMAGE: |