summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorOliver-Rainer Wittmann <orw@apache.org>2014-06-06 12:07:49 +0000
committerAndras Timar <andras.timar@collabora.com>2014-06-10 22:11:10 +0200
commit584febd23a22cf829b69b519d9522005f37bbae2 (patch)
tree28a4e2704e8f0ab944546ecb61c0a68b91635d56 /vcl
parentddcae0154bb23fc489f5761ef95a83e5a436ce84 (diff)
Resolves: #i125000# check last status of newly created...
<Gdiplus::Bitmap> instance before using it. (cherry picked from commit b127235917610b9c68e19df29bb39af496906569) Change-Id: I97364cf963424b0e8d0b52b3c995bd4defdca067 (cherry picked from commit adb1bb21f804c62004f31ad5473d4cf447436b9b) (cherry picked from commit e0c9b690074cd476b03169397cbf1969f2239c1e) Reviewed-on: https://gerrit.libreoffice.org/9670 Tested-by: David Tardon <dtardon@redhat.com> Reviewed-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/win/source/gdi/salbmp.cxx38
1 files changed, 23 insertions, 15 deletions
diff --git a/vcl/win/source/gdi/salbmp.cxx b/vcl/win/source/gdi/salbmp.cxx
index f0e150975e89..3ba430ddb06a 100644
--- a/vcl/win/source/gdi/salbmp.cxx
+++ b/vcl/win/source/gdi/salbmp.cxx
@@ -331,24 +331,32 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap()
if(pRetval)
{
- sal_uInt8* pSrcRGB(pRGB->mpBits);
- const sal_uInt32 nExtraRGB(pRGB->mnScanlineSize - (nW * 3));
- const bool bTopDown(pRGB->mnFormat & BMP_FORMAT_TOP_DOWN);
- const Gdiplus::Rect aAllRect(0, 0, nW, nH);
- Gdiplus::BitmapData aGdiPlusBitmapData;
- pRetval->LockBits(&aAllRect, Gdiplus::ImageLockModeWrite, PixelFormat24bppRGB, &aGdiPlusBitmapData);
-
- // copy data to Gdiplus::Bitmap; format is BGR here in both cases, so memcpy is possible
- for(sal_uInt32 y(0); y < nH; y++)
+ if ( pRetval->GetLastStatus() == Gdiplus::Ok )
{
- const sal_uInt32 nYInsert(bTopDown ? y : nH - y - 1);
- sal_uInt8* targetPixels = (sal_uInt8*)aGdiPlusBitmapData.Scan0 + (nYInsert * aGdiPlusBitmapData.Stride);
+ sal_uInt8* pSrcRGB(pRGB->mpBits);
+ const sal_uInt32 nExtraRGB(pRGB->mnScanlineSize - (nW * 3));
+ const bool bTopDown(pRGB->mnFormat & BMP_FORMAT_TOP_DOWN);
+ const Gdiplus::Rect aAllRect(0, 0, nW, nH);
+ Gdiplus::BitmapData aGdiPlusBitmapData;
+ pRetval->LockBits(&aAllRect, Gdiplus::ImageLockModeWrite, PixelFormat24bppRGB, &aGdiPlusBitmapData);
+
+ // copy data to Gdiplus::Bitmap; format is BGR here in both cases, so memcpy is possible
+ for(sal_uInt32 y(0); y < nH; y++)
+ {
+ const sal_uInt32 nYInsert(bTopDown ? y : nH - y - 1);
+ sal_uInt8* targetPixels = (sal_uInt8*)aGdiPlusBitmapData.Scan0 + (nYInsert * aGdiPlusBitmapData.Stride);
- memcpy(targetPixels, pSrcRGB, nW * 3);
- pSrcRGB += nW * 3 + nExtraRGB;
- }
+ memcpy(targetPixels, pSrcRGB, nW * 3);
+ pSrcRGB += nW * 3 + nExtraRGB;
+ }
- pRetval->UnlockBits(&aGdiPlusBitmapData);
+ pRetval->UnlockBits(&aGdiPlusBitmapData);
+ }
+ else
+ {
+ delete pRetval;
+ pRetval = NULL;
+ }
}
}