Author: jgardou
Date: Thu Jun 10 14:32:05 2010
New Revision: 47735
URL:
http://svn.reactos.org/svn/reactos?rev=47735&view=rev
Log:
[GDI32]
- DIB data is not mandatory in CreateDIBitmap
[WIN32K]
- Simplify GreCreateDIBitmap
- Surface data should be 16 bits aligned
Modified:
branches/reactos-yarotows/dll/win32/gdi32/objects/bitmap.c
branches/reactos-yarotows/subsystems/win32/win32k/eng/surface.c
branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c
Modified: branches/reactos-yarotows/dll/win32/gdi32/objects/bitmap.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/dll/win32/gdi3…
==============================================================================
--- branches/reactos-yarotows/dll/win32/gdi32/objects/bitmap.c [iso-8859-1] (original)
+++ branches/reactos-yarotows/dll/win32/gdi32/objects/bitmap.c [iso-8859-1] Thu Jun 10
14:32:05 2010
@@ -461,8 +461,8 @@
LONG width, height, compr, dibsize;
WORD planes, bpp;
// PDC_ATTR pDc_Attr;
- UINT InfoSize;
- UINT cjBmpScanSize;
+ UINT InfoSize = 0;
+ UINT cjBmpScanSize = 0;
HBITMAP hBmp;
NTSTATUS Status = STATUS_SUCCESS;
@@ -477,17 +477,20 @@
// For Icm support.
// GdiGetHandleUserData(hdc, GDI_OBJECT_TYPE_DC, (PVOID)&pDc_Attr))
- _SEH2_TRY
- {
- cjBmpScanSize = DIB_BitmapBitsSize(Data);
- CalculateColorTableSize(&Data->bmiHeader, &ColorUse, &InfoSize);
- InfoSize += Data->bmiHeader.biSize;
- }
- _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
- {
- Status = _SEH2_GetExceptionCode();
- }
- _SEH2_END
+ if(Data)
+ {
+ _SEH2_TRY
+ {
+ cjBmpScanSize = DIB_BitmapBitsSize(Data);
+ CalculateColorTableSize(&Data->bmiHeader, &ColorUse,
&InfoSize);
+ InfoSize += Data->bmiHeader.biSize;
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = _SEH2_GetExceptionCode();
+ }
+ _SEH2_END
+ }
if(!NT_SUCCESS(Status))
{
Modified: branches/reactos-yarotows/subsystems/win32/win32k/eng/surface.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/eng/surface.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/eng/surface.c [iso-8859-1] Thu Jun
10 14:32:05 2010
@@ -203,12 +203,12 @@
if (ulWidth)
{
/* Align the width (Windows compatibility) */
- ulWidth = ((((ulWidth << 3) / cBitsPixel) * cBitsPixel + 31) & ~31)
>> 3;
+ ulWidth = ((((ulWidth << 3) / cBitsPixel) * cBitsPixel + 15) & ~15)
>> 3;
}
else
{
/* Calculate width from the bitmap width in pixels */
- ulWidth = ((pso->sizlBitmap.cx * cBitsPixel + 31) & ~31) >> 3;
+ ulWidth = ((pso->sizlBitmap.cx * cBitsPixel + 15) & ~15) >> 3;
}
/* Calculate the bitmap size in bytes */
@@ -236,7 +236,7 @@
(fjBitmap & BMF_NOZEROINIT) ?
0 : FL_ZERO_MEMORY,
pso->cjBits, TAG_DIB);
-
+
/* Free the section already, but keep the mapping */
if (pvBits) EngFreeSectionMem(pvSection, NULL);
}
Modified: branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] Thu
Jun 10 14:32:05 2010
@@ -1177,68 +1177,39 @@
PDC Dc;
HBITMAP Bmp;
WORD bpp;
-
- if (!hDc) // CreateBitmap
+ HDC hdcDest;
+
+ if (!hDc) /* 1bpp monochrome bitmap */
{ // Should use System Bitmap DC hSystemBM, with CreateCompatibleDC for this.
- hDc = IntGdiCreateDC(NULL, NULL, NULL, NULL,FALSE);
- if (!hDc)
- {
- SetLastWin32Error(ERROR_INVALID_HANDLE);
+ hdcDest = IntGdiCreateDC(NULL, NULL, NULL, NULL,FALSE);
+ if(!hdcDest)
+ {
return NULL;
}
-
- Dc = DC_LockDc(hDc);
- if (!Dc)
- {
- NtGdiDeleteObjectApp(hDc);
- SetLastWin32Error(ERROR_INVALID_HANDLE);
- return NULL;
- }
- bpp = 1;
- Bmp = IntCreateDIBitmap(Dc, cx, cy, bpp, fInit, pjInit, pbmi, iUsage);
-
- DC_UnlockDc(Dc);
- NtGdiDeleteObjectApp(hDc);
- }
- else // CreateCompatibleBitmap
- {
- Dc = DC_LockDc(hDc);
- if (!Dc)
- {
- SetLastWin32Error(ERROR_INVALID_HANDLE);
- return NULL;
- }
- /* pbmi == null
- First create an un-initialised bitmap. The depth of the bitmap
- should match that of the hdc and not that supplied in bmih.
- */
- if (pbmi)
- bpp = pbmi->bmiHeader.bV5BitCount;
- else
- {
- if (Dc->dctype != DC_TYPE_MEMORY)
- bpp = Dc->ppdev->gdiinfo.cBitsPixel;
- else
- {
- DIBSECTION dibs;
- INT Count;
- SURFACE *psurf = Dc->dclevel.pSurface;
- Count = BITMAP_GetObject(psurf, sizeof(dibs), &dibs);
- if (!Count)
- bpp = 1;
- else
- {
- if (Count == sizeof(BITMAP))
- /* A device-dependent bitmap is selected in the DC */
- bpp = dibs.dsBm.bmBitsPixel;
- else
- /* A DIB section is selected in the DC */
- bpp = dibs.dsBmih.biBitCount;
- }
- }
- }
- Bmp = IntCreateDIBitmap(Dc, cx, cy, bpp, fInit, pjInit, pbmi, iUsage);
- DC_UnlockDc(Dc);
+ }
+ else
+ {
+ hdcDest = hDc;
+ }
+
+ Dc = DC_LockDc(hdcDest);
+ if (!Dc)
+ {
+ SetLastWin32Error(ERROR_INVALID_HANDLE);
+ return NULL;
+ }
+ /* 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.bV5BitCount;
+ else
+ bpp = 0;
+ Bmp = IntCreateDIBitmap(Dc, cx, cy, bpp, fInit, pjInit, pbmi, iUsage);
+ DC_UnlockDc(Dc);
+
+ if(!hDc)
+ {
+ NtGdiDeleteObjectApp(hdcDest);
}
return Bmp;
}