Author: jimtabor Date: Tue Nov 18 10:07:54 2008 New Revision: 37439
URL: http://svn.reactos.org/svn/reactos?rev=37439&view=rev Log: - Make our version of SetDIBits safe as SetDIBitsToDevice.
Modified: trunk/reactos/dll/win32/gdi32/objects/bitmap.c
Modified: trunk/reactos/dll/win32/gdi32/objects/bitmap.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/objects/bit... ============================================================================== --- trunk/reactos/dll/win32/gdi32/objects/bitmap.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/gdi32/objects/bitmap.c [iso-8859-1] Tue Nov 18 10:07:54 2008 @@ -585,7 +585,11 @@ CONST BITMAPINFO *lpbmi, UINT fuColorUse) { + PBITMAPINFO pConvertedInfo; + UINT ConvertedInfoSize; INT LinesCopied = 0; + UINT cjBmpScanSize = 0; + PVOID pvSafeBits = (PVOID)lpvBits;
// This needs to be almost the sames as SetDIBitsToDevice
@@ -594,15 +598,33 @@
if ( fuColorUse && fuColorUse != DIB_PAL_COLORS && fuColorUse != DIB_PAL_COLORS+1 ) return 0; + + pConvertedInfo = ConvertBitmapInfo(lpbmi, fuColorUse, + &ConvertedInfoSize, FALSE); + if (!pConvertedInfo) + return 0; + + cjBmpScanSize = DIB_BitmapMaxBitsSize((LPBITMAPINFO)lpbmi, cScanLines); + + if ( lpvBits ) + { + pvSafeBits = RtlAllocateHeap(GetProcessHeap(), 0, cjBmpScanSize); + if (pvSafeBits) + RtlCopyMemory( pvSafeBits, lpvBits, cjBmpScanSize); + }
LinesCopied = NtGdiSetDIBits( hdc, hbmp, uStartScan, cScanLines, - lpvBits, - lpbmi, + pvSafeBits, + pConvertedInfo, fuColorUse);
+ if ( lpvBits != pvSafeBits) + RtlFreeHeap(RtlGetProcessHeap(), 0, pvSafeBits); + if (lpbmi != pConvertedInfo) + RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo); return LinesCopied; }
@@ -725,7 +747,7 @@ TRUE, NULL); } - if ( Bits ) + if ( Bits != pvSafeBits) RtlFreeHeap(RtlGetProcessHeap(), 0, pvSafeBits); if (lpbmi != pConvertedInfo) RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo);