Author: jgardou
Date: Fri Oct 24 17:31:46 2014
New Revision: 64966
URL:
http://svn.reactos.org/svn/reactos?rev=64966&view=rev
Log:
[WIN32K]
- First implementation of CreateDIBitmap with the undocumented CBM_CREATEDIB flag.
CORE-8695
Modified:
trunk/reactos/win32ss/gdi/gdi32/objects/bitmap.c
trunk/reactos/win32ss/gdi/ntgdi/bitmaps.c
trunk/reactos/win32ss/gdi/ntgdi/dibobj.c
trunk/reactos/win32ss/gdi/ntgdi/intgdi.h
Modified: trunk/reactos/win32ss/gdi/gdi32/objects/bitmap.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/objects/…
==============================================================================
--- trunk/reactos/win32ss/gdi/gdi32/objects/bitmap.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/gdi32/objects/bitmap.c [iso-8859-1] Fri Oct 24 17:31:46
2014
@@ -480,6 +480,9 @@
GdiSetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
+
+ /* Use the header from the data */
+ Header = &Data->bmiHeader;
}
/* Header is required */
@@ -502,6 +505,13 @@
/* Only DIB_RGB_COLORS (0), DIB_PAL_COLORS (1) and 2 are valid. */
if (ColorUse > DIB_PAL_COLORS + 1)
+ {
+ GdiSetLastError(ERROR_INVALID_PARAMETER);
+ return 0;
+ }
+
+ /* If some Bits are given, only DIB_PAL_COLORS and DIB_RGB_COLORS are valid */
+ if (Bits && (ColorUse > DIB_PAL_COLORS))
{
GdiSetLastError(ERROR_INVALID_PARAMETER);
return 0;
Modified: trunk/reactos/win32ss/gdi/ntgdi/bitmaps.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/bitmaps.…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/bitmaps.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/bitmaps.c [iso-8859-1] Fri Oct 24 17:31:46 2014
@@ -217,7 +217,9 @@
IntCreateCompatibleBitmap(
PDC Dc,
INT Width,
- INT Height)
+ INT Height,
+ UINT Planes,
+ UINT Bpp)
{
HBITMAP Bmp = NULL;
PPALETTE ppal;
@@ -234,8 +236,8 @@
Bmp = GreCreateBitmap(abs(Width),
abs(Height),
- 1,
- Dc->ppdev->gdiinfo.cBitsPixel,
+ Planes ? Planes : 1,
+ Bpp ? Bpp : Dc->ppdev->gdiinfo.cBitsPixel,
NULL);
psurf = SURFACE_ShareLockSurface(Bmp);
ASSERT(psurf);
@@ -266,8 +268,8 @@
Bmp = GreCreateBitmap(abs(Width),
abs(Height),
- 1,
- dibs.dsBm.bmBitsPixel,
+ Planes ? Planes : 1,
+ Bpp ? Bpp : dibs.dsBm.bmBitsPixel,
NULL);
psurfBmp = SURFACE_ShareLockSurface(Bmp);
ASSERT(psurfBmp);
@@ -291,8 +293,8 @@
bi->bmiHeader.biSize = sizeof(bi->bmiHeader);
bi->bmiHeader.biWidth = Width;
bi->bmiHeader.biHeight = Height;
- bi->bmiHeader.biPlanes = dibs.dsBmih.biPlanes;
- bi->bmiHeader.biBitCount = dibs.dsBmih.biBitCount;
+ bi->bmiHeader.biPlanes = Planes ? Planes : dibs.dsBmih.biPlanes;
+ bi->bmiHeader.biBitCount = Bpp ? Bpp : dibs.dsBmih.biBitCount;
bi->bmiHeader.biCompression = dibs.dsBmih.biCompression;
bi->bmiHeader.biSizeImage = 0;
bi->bmiHeader.biXPelsPerMeter = dibs.dsBmih.biXPelsPerMeter;
@@ -373,7 +375,7 @@
return NULL;
}
- Bmp = IntCreateCompatibleBitmap(Dc, Width, Height);
+ Bmp = IntCreateCompatibleBitmap(Dc, Width, Height, 0, 0);
DC_UnlockDc(Dc);
return Bmp;
Modified: trunk/reactos/win32ss/gdi/ntgdi/dibobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/dibobj.c…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/dibobj.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/dibobj.c [iso-8859-1] Fri Oct 24 17:31:46 2014
@@ -1317,7 +1317,9 @@
PDC Dc,
INT width,
INT height,
+ UINT planes,
UINT bpp,
+ ULONG compression,
DWORD init,
LPBYTE bits,
PBITMAPINFO data,
@@ -1325,12 +1327,16 @@
{
HBITMAP handle;
BOOL fColor;
+ ULONG BmpFormat = 0;
+
+ if (planes && bpp)
+ BmpFormat = BitmapFormat(planes * bpp, compression);
// Check if we should create a monochrome or color bitmap. We create a monochrome
bitmap only if it has exactly 2
// colors, which are black followed by white, nothing else. In all other cases, we
create a color bitmap.
- if (bpp != 1) fColor = TRUE;
- else if ((coloruse != DIB_RGB_COLORS) || (init != CBM_INIT) || !data) fColor =
FALSE;
+ if (BmpFormat != BMF_1BPP) fColor = TRUE;
+ else if ((coloruse > DIB_RGB_COLORS) || (init != CBM_INIT) || !data) fColor =
FALSE;
else
{
const RGBQUAD *rgb = (RGBQUAD*)((PBYTE)data + data->bmiHeader.biSize);
@@ -1351,7 +1357,16 @@
// Now create the bitmap
if (fColor)
{
- handle = IntCreateCompatibleBitmap(Dc, width, height);
+ if (init & CBM_CREATDIB)
+ {
+ /* Undocumented flag which creates a DDB of the format specified by the
bitmap info. */
+ handle = IntCreateCompatibleBitmap(Dc, width, height, planes, bpp);
+ }
+ else
+ {
+ /* Create a regular compatible bitmap, in the same format as the device */
+ handle = IntCreateCompatibleBitmap(Dc, width, height, 0, 0);
+ }
}
else
{
@@ -1365,8 +1380,47 @@
if (height < 0)
height = -height;
- if (NULL != handle && CBM_INIT == init)
- {
+ if ((NULL != handle) && (CBM_INIT & init))
+ {
+ if (init & CBM_CREATDIB)
+ {
+ PSURFACE Surface;
+ PPALETTE Palette;
+ NTSTATUS Status = STATUS_SUCCESS;
+
+ Surface = SURFACE_ShareLockSurface(handle);
+ ASSERT(Surface);
+
+ Palette = CreateDIBPalette(data, Dc, coloruse);
+ ASSERT(Palette);
+ SURFACE_vSetPalette(Surface, Palette);
+ PALETTE_ShareUnlockPalette(Palette);
+
+ if (Surface->SurfObj.pvBits)
+ {
+ _SEH2_TRY
+ {
+ RtlCopyMemory(Surface->SurfObj.pvBits, bits,
+ abs(Surface->sizlDim.cy * Surface->SurfObj.lDelta));
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = _SEH2_GetExceptionCode();
+ }
+ _SEH2_END
+ }
+
+ SURFACE_ShareUnlockSurface(Surface);
+
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastNtError(Status);
+ GreDeleteObject(handle);
+ handle = NULL;
+ }
+ return handle;
+ }
+
IntSetDIBits(Dc, handle, 0, height, bits, data, coloruse);
}
@@ -1458,7 +1512,8 @@
{
PDC Dc;
HBITMAP Bmp;
- WORD bpp;
+ USHORT bpp, planes;
+ DWORD compression;
HDC hdcDest;
if (!hDc) /* 1bpp monochrome bitmap */
@@ -1484,10 +1539,18 @@
/* It's OK to set bpp=0 here, as IntCreateDIBitmap will create a compatible
Bitmap
* if bpp != 1 and ignore the real value that was passed */
if (pbmi)
+ {
bpp = pbmi->bmiHeader.biBitCount;
+ planes = pbmi->bmiHeader.biPlanes;
+ compression = pbmi->bmiHeader.biCompression;
+ }
else
+ {
bpp = 0;
- Bmp = IntCreateDIBitmap(Dc, cx, cy, bpp, fInit, pjInit, pbmi, iUsage);
+ planes = 0;
+ compression = 0;
+ }
+ Bmp = IntCreateDIBitmap(Dc, cx, cy, bpp, planes, compression, fInit, pjInit, pbmi,
iUsage);
DC_UnlockDc(Dc);
if(!hDc)
Modified: trunk/reactos/win32ss/gdi/ntgdi/intgdi.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/intgdi.h…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/intgdi.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/intgdi.h [iso-8859-1] Fri Oct 24 17:31:46 2014
@@ -87,9 +87,12 @@
HBITMAP
FASTCALL
-IntCreateCompatibleBitmap(PDC Dc,
- INT Width,
- INT Height);
+IntCreateCompatibleBitmap(
+ _In_ PDC Dc,
+ _In_ INT Width,
+ _In_ INT Height,
+ _In_ UINT Bpp,
+ _In_ UINT Planes);
WORD APIENTRY IntGdiSetHookFlags(HDC hDC, WORD Flags);