mirror of
https://github.com/reactos/reactos.git
synced 2024-08-02 17:40:58 +00:00
- Make our version of SetDIBits safe as SetDIBitsToDevice.
svn path=/trunk/; revision=37439
This commit is contained in:
parent
3192a32d97
commit
f558f29e5c
|
@ -585,7 +585,11 @@ SetDIBits(HDC hdc,
|
||||||
CONST BITMAPINFO *lpbmi,
|
CONST BITMAPINFO *lpbmi,
|
||||||
UINT fuColorUse)
|
UINT fuColorUse)
|
||||||
{
|
{
|
||||||
|
PBITMAPINFO pConvertedInfo;
|
||||||
|
UINT ConvertedInfoSize;
|
||||||
INT LinesCopied = 0;
|
INT LinesCopied = 0;
|
||||||
|
UINT cjBmpScanSize = 0;
|
||||||
|
PVOID pvSafeBits = (PVOID)lpvBits;
|
||||||
|
|
||||||
// This needs to be almost the sames as SetDIBitsToDevice
|
// This needs to be almost the sames as SetDIBitsToDevice
|
||||||
|
|
||||||
|
@ -595,14 +599,32 @@ SetDIBits(HDC hdc,
|
||||||
if ( fuColorUse && fuColorUse != DIB_PAL_COLORS && fuColorUse != DIB_PAL_COLORS+1 )
|
if ( fuColorUse && fuColorUse != DIB_PAL_COLORS && fuColorUse != DIB_PAL_COLORS+1 )
|
||||||
return 0;
|
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,
|
LinesCopied = NtGdiSetDIBits( hdc,
|
||||||
hbmp,
|
hbmp,
|
||||||
uStartScan,
|
uStartScan,
|
||||||
cScanLines,
|
cScanLines,
|
||||||
lpvBits,
|
pvSafeBits,
|
||||||
lpbmi,
|
pConvertedInfo,
|
||||||
fuColorUse);
|
fuColorUse);
|
||||||
|
|
||||||
|
if ( lpvBits != pvSafeBits)
|
||||||
|
RtlFreeHeap(RtlGetProcessHeap(), 0, pvSafeBits);
|
||||||
|
if (lpbmi != pConvertedInfo)
|
||||||
|
RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo);
|
||||||
return LinesCopied;
|
return LinesCopied;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -725,7 +747,7 @@ SetDIBitsToDevice(
|
||||||
TRUE,
|
TRUE,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
if ( Bits )
|
if ( Bits != pvSafeBits)
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, pvSafeBits);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, pvSafeBits);
|
||||||
if (lpbmi != pConvertedInfo)
|
if (lpbmi != pConvertedInfo)
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo);
|
||||||
|
|
Loading…
Reference in a new issue