return GreSetObjectOwner(hbmp, ulOwner);
}
-static
-int
+BOOL
NTAPI
UnsafeSetBitmapBits(
- PSURFACE psurf,
- IN ULONG cjBits,
- IN PVOID pvBits)
+ _Inout_ PSURFACE psurf,
+ _In_ ULONG cjBits,
+ _In_ const VOID *pvBits)
{
- PUCHAR pjDst, pjSrc;
+ PUCHAR pjDst;
+ const UCHAR *pjSrc;
LONG lDeltaDst, lDeltaSrc;
ULONG nWidth, nHeight, cBitsPixel;
NT_ASSERT(psurf->flags & API_BITMAP);
/* Make sure the buffer is large enough*/
if (cjBits < (lDeltaSrc * nHeight))
- return 0;
+ return FALSE;
while (nHeight--)
{
pjDst += lDeltaDst;
}
- return 1;
+ return TRUE;
}
HBITMAP
EXLATEOBJ exlo;
PPALETTE ppalDIB = 0;
ULONG cjSizeImage;
+ BOOL bCompressed;
- if (!bmi) return 0;
+ if (!bmi || !Bits) return 0;
- /* Check if the header provided an image size */
- if (bmi->bmiHeader.biSizeImage != 0)
- {
- /* Use the given size */
- cjSizeImage = bmi->bmiHeader.biSizeImage;
- }
- /* Otherwise check for uncompressed formats */
- else if ((bmi->bmiHeader.biCompression == BI_RGB) ||
+ /* Check for uncompressed formats */
+ if ((bmi->bmiHeader.biCompression == BI_RGB) ||
(bmi->bmiHeader.biCompression == BI_BITFIELDS))
{
/* Calculate the image size */
cjSizeImage = DIB_GetDIBImageBytes(bmi->bmiHeader.biWidth,
ScanLines,
bmi->bmiHeader.biBitCount);
+ bCompressed = FALSE;
+ }
+ /* Check if the header provided an image size */
+ else if (bmi->bmiHeader.biSizeImage != 0)
+ {
+ /* Use the given size */
+ cjSizeImage = bmi->bmiHeader.biSizeImage;
+ bCompressed = TRUE;
}
else
{
return 0;
}
+ /* We cannot use the provided buffer for uncompressed bits, since they
+ might not be aligned correctly! */
SourceBitmap = GreCreateBitmapEx(bmi->bmiHeader.biWidth,
ScanLines,
0,
bmi->bmiHeader.biCompression),
bmi->bmiHeader.biHeight < 0 ? BMF_TOPDOWN : 0,
cjSizeImage,
- (PVOID)Bits,
+ bCompressed ? (PVOID)Bits : NULL,
0);
if (!SourceBitmap)
{
goto cleanup;
}
+ /* Check for uncompressed bits */
+ if (!bCompressed)
+ {
+ /* Copy the bitmap bits */
+ if (!UnsafeSetBitmapBits(psurfSrc, cjMaxBits, Bits))
+ {
+ DPRINT1("Error: Could not set bitmap bits\n");
+ goto cleanup;
+ }
+ }
+
/* Create a palette for the DIB */
ppalDIB = CreateDIBPalette(bmi, DC, ColorUse);
if (!ppalDIB)
ptSrc.x = 0;
ptSrc.y = 0;
- NT_ASSERT(psurfSrc->SurfObj.cjBits <= cjMaxBits);
-
result = IntEngCopyBits(&psurfDst->SurfObj,
&psurfSrc->SurfObj,
NULL,
PBYTE safeBits = NULL;
HBITMAP hbmResult = NULL;
+ if (pjInit == NULL)
+ {
+ fInit &= ~CBM_INIT;
+ }
+
if(pjInit && (fInit & CBM_INIT))
{
if (cjMaxBits == 0) return NULL;