Author: jimtabor
Date: Sun Mar 30 17:37:42 2008
New Revision: 32786
URL:
http://svn.reactos.org/svn/reactos?rev=32786&view=rev
Log:
Patch by Stefan Ginsberg (stefan__100__ AT hotmail DOT com):
- Remove NtGdiCreateDIBitmap, update all related files.
- Rewrite CreateDIBitmap.
- Tested with Qemu.
Modified:
trunk/reactos/dll/win32/gdi32/misc/hacks.c
trunk/reactos/dll/win32/gdi32/objects/bitmap.c
trunk/reactos/include/reactos/win32k/ntgdibad.h
trunk/reactos/subsystems/win32/win32k/ntuser/clipboard.c
trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c
trunk/reactos/subsystems/win32/win32k/objects/dibobj.c
trunk/reactos/subsystems/win32/win32k/stubs/stubs.c
trunk/reactos/subsystems/win32/win32k/w32ksvc.db
Modified: trunk/reactos/dll/win32/gdi32/misc/hacks.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/misc/hacks…
==============================================================================
--- trunk/reactos/dll/win32/gdi32/misc/hacks.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/gdi32/misc/hacks.c [iso-8859-1] Sun Mar 30 17:37:42 2008
@@ -25,17 +25,6 @@
{
/* FIXME share memory */
return NtGdiSetDIBits(hdc, hbmp, uStartScan, cScanLines, lpvBits, lpbmi,
fuColorUse);
-}
-
-HBITMAP
-STDCALL
-CreateDIBitmap(HDC hDc,
- const BITMAPINFOHEADER *Header,
- DWORD Init, LPCVOID Bits, const BITMAPINFO *Data,
- UINT ColorUse)
-{
- /* FIMXE we need do more thing in user mode */
- return NtGdiCreateDIBitmap(hDc, Header, Init, Bits, Data, ColorUse);
}
/*
Modified: trunk/reactos/dll/win32/gdi32/objects/bitmap.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/objects/bi…
==============================================================================
--- trunk/reactos/dll/win32/gdi32/objects/bitmap.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/gdi32/objects/bitmap.c [iso-8859-1] Sun Mar 30 17:37:42 2008
@@ -1,7 +1,7 @@
#include "precomp.h"
-//#define NDEBUG
-//#include <debug.h>
+#define NDEBUG
+#include <debug.h>
/*
* Return the full scan size for a bitmap.
@@ -28,6 +28,72 @@
}
MaxBits = ((MaxBits + 31) & ~31 ) / 8; // From Yuan, ScanLineSize = (Width *
bitcount + 31)/32
return (MaxBits * ScanLines); // ret the full Size.
+}
+
+/*
+ * DIB_GetBitmapInfo is complete copy of wine cvs 2/9-2006
+ * from file dib.c from gdi32.dll or orginal version
+ * did not calc the info right for some headers.
+ */
+INT
+STDCALL
+DIB_GetBitmapInfo(const BITMAPINFOHEADER *header,
+ PLONG width,
+ PLONG height,
+ PWORD planes,
+ PWORD bpp,
+ PLONG compr,
+ PLONG size )
+{
+
+ if (header->biSize == sizeof(BITMAPCOREHEADER))
+ {
+ BITMAPCOREHEADER *core = (BITMAPCOREHEADER *)header;
+ *width = core->bcWidth;
+ *height = core->bcHeight;
+ *planes = core->bcPlanes;
+ *bpp = core->bcBitCount;
+ *compr = 0;
+ *size = 0;
+ return 0;
+ }
+
+ if (header->biSize == sizeof(BITMAPINFOHEADER))
+ {
+ *width = header->biWidth;
+ *height = header->biHeight;
+ *planes = header->biPlanes;
+ *bpp = header->biBitCount;
+ *compr = header->biCompression;
+ *size = header->biSizeImage;
+ return 1;
+ }
+
+ if (header->biSize == sizeof(BITMAPV4HEADER))
+ {
+ BITMAPV4HEADER *v4hdr = (BITMAPV4HEADER *)header;
+ *width = v4hdr->bV4Width;
+ *height = v4hdr->bV4Height;
+ *planes = v4hdr->bV4Planes;
+ *bpp = v4hdr->bV4BitCount;
+ *compr = v4hdr->bV4V4Compression;
+ *size = v4hdr->bV4SizeImage;
+ return 4;
+ }
+
+ if (header->biSize == sizeof(BITMAPV5HEADER))
+ {
+ BITMAPV5HEADER *v5hdr = (BITMAPV5HEADER *)header;
+ *width = v5hdr->bV5Width;
+ *height = v5hdr->bV5Height;
+ *planes = v5hdr->bV5Planes;
+ *bpp = v5hdr->bV5BitCount;
+ *compr = v5hdr->bV5Compression;
+ *size = v5hdr->bV5SizeImage;
+ return 5;
+ }
+ DPRINT("(%ld): wrong size for header\n", header->biSize );
+ return -1;
}
/*
@@ -194,3 +260,38 @@
return ret;
}
+
+/*
+ * @implemented
+ */
+HBITMAP
+STDCALL
+CreateDIBitmap( HDC hDC,
+ const BITMAPINFOHEADER *Header,
+ DWORD Init,
+ LPCVOID Bits,
+ const BITMAPINFO *Data,
+ UINT ColorUse)
+{
+ LONG width, height, compr, dibsize;
+ WORD planes, bpp;
+
+ if (DIB_GetBitmapInfo(Header, &width, &height, &planes, &bpp,
&compr, &dibsize) == -1)
+ {
+ GdiSetLastError(ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ return NtGdiCreateDIBitmapInternal(hDC,
+ width,
+ height,
+ Init,
+ (LPBYTE)Bits,
+ (PBITMAPINFO)Data,
+ ColorUse,
+ bpp,
+ dibsize,
+ 0,
+ 0);
+}
+
Modified: trunk/reactos/include/reactos/win32k/ntgdibad.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntg…
==============================================================================
--- trunk/reactos/include/reactos/win32k/ntgdibad.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/win32k/ntgdibad.h [iso-8859-1] Sun Mar 30 17:37:42 2008
@@ -58,18 +58,6 @@
PFONTFAMILYINFO Info,
DWORD Size
);
-
-/* Use NtGdiCreateDIBitmapInternal */
-HBITMAP
-STDCALL
-NtGdiCreateDIBitmap (
- HDC hDC,
- CONST BITMAPINFOHEADER * bmih,
- DWORD Init,
- CONST VOID * bInit,
- CONST BITMAPINFO * bmi,
- UINT Usage
- );
/* Use NtGdiGetDCPoint with GdiGetViewPortExt */
BOOL STDCALL NtGdiGetViewportExtEx(HDC hDC, LPSIZE viewportExt);
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/clipboard.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/clipboard.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/clipboard.c [iso-8859-1] Sun Mar 30
17:37:42 2008
@@ -273,8 +273,17 @@
offset = sizeof(BITMAPINFOHEADER) + ((ih->biBitCount <= 8) ? (sizeof(RGBQUAD) *
(1 << ih->biBitCount)) : 0);
- hbitmap = NtGdiCreateDIBitmap(hdc, ih, CBM_INIT, (LPBYTE)ih + offset,
(LPBITMAPINFO)ih, DIB_RGB_COLORS);
-
+ hbitmap = NtGdiCreateDIBitmapInternal(hdc,
+ ih->biWidth,
+ ih->biHeight,
+ CBM_INIT,
+ (LPBYTE)ih+offset,
+ (LPBITMAPINFO)ih,
+ DIB_RGB_COLORS,
+ ih->biBitCount,
+ ih->biSizeImage,
+ 0,
+ 0);
//UserReleaseDC(NULL, hdc, FALSE);
UserReleaseDC(ClipboardWindow, hdc, FALSE);
Modified: trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] Sun Mar 30
17:37:42 2008
@@ -300,7 +300,18 @@
static const BITMAPINFOHEADER bih = { sizeof(BITMAPINFOHEADER), 1, 1, 1, 32, BI_RGB,
0, 0, 0, 0, 0 };
BITMAPINFO bi;
RtlMoveMemory ( &(bi.bmiHeader), &bih, sizeof(bih) );
- hBmpTmp = NtGdiCreateDIBitmap ( hDC, &bi.bmiHeader, 0, NULL, &bi,
DIB_RGB_COLORS );
+ hBmpTmp = NtGdiCreateDIBitmapInternal(hDC,
+ bi.bmiHeader.biWidth,
+ bi.bmiHeader.biHeight,
+ 0,
+ NULL,
+ &bi,
+ DIB_RGB_COLORS,
+ bi.bmiHeader.biBitCount,
+ bi.bmiHeader.biSizeImage,
+ 0,
+ 0);
+
//HBITMAP hBmpTmp = IntGdiCreateBitmap ( 1, 1, 1, 32, NULL);
if ( hBmpTmp )
{
Modified: trunk/reactos/subsystems/win32/win32k/objects/dibobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] Sun Mar 30
17:37:42 2008
@@ -801,29 +801,25 @@
}
-HBITMAP FASTCALL
-IntCreateDIBitmap(PDC Dc, const BITMAPINFOHEADER *header,
- DWORD init, LPCVOID bits, const BITMAPINFO *data,
- UINT coloruse)
+HBITMAP
+FASTCALL
+IntCreateDIBitmap(PDC Dc,
+ INT width,
+ INT height,
+ UINT bpp,
+ DWORD init,
+ LPBYTE bits,
+ PBITMAPINFO data,
+ DWORD coloruse)
{
HBITMAP handle;
-
- LONG width;
- LONG height;
- WORD planes;
- WORD bpp;
- LONG compr;
- LONG dibsize;
BOOL fColor;
-
- if (DIB_GetBitmapInfo( header, &width, &height, &planes, &bpp,
&compr, &dibsize ) == -1) return 0;
// 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;
+ else if ((coloruse != DIB_RGB_COLORS) || (init != CBM_INIT) || !data) fColor = FALSE;
else
{
if (data->bmiHeader.biSize == sizeof(BITMAPINFOHEADER))
@@ -845,7 +841,7 @@
else if (data->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
{
RGBTRIPLE *rgb = ((BITMAPCOREINFO *)data)->bmciColors;
- DWORD col = RGB( rgb->rgbtRed, rgb->rgbtGreen, rgb->rgbtBlue);
+ DWORD col = RGB( rgb->rgbtRed, rgb->rgbtGreen, rgb->rgbtBlue);
if ((col == RGB(0,0,0)))
{
@@ -875,7 +871,7 @@
1,
NULL);
}
-
+
if (height < 0)
height = -height;
@@ -889,63 +885,61 @@
// The CreateDIBitmap function creates a device-dependent bitmap (DDB) from a DIB and,
optionally, sets the bitmap bits
// The DDB that is created will be whatever bit depth your reference DC is
-HBITMAP STDCALL NtGdiCreateDIBitmap(HDC hDc, const BITMAPINFOHEADER *Header,
- DWORD Init, LPCVOID Bits, const BITMAPINFO *Data,
- UINT ColorUse)
+HBITMAP
+APIENTRY
+NtGdiCreateDIBitmapInternal(IN HDC hDc,
+ IN INT cx,
+ IN INT cy,
+ IN DWORD fInit,
+ IN OPTIONAL LPBYTE pjInit,
+ IN OPTIONAL LPBITMAPINFO pbmi,
+ IN DWORD iUsage,
+ IN UINT cjMaxInitInfo,
+ IN UINT cjMaxBits,
+ IN FLONG fl,
+ IN HANDLE hcmXform)
{
PDC Dc;
HBITMAP Bmp;
- if (Header == NULL)
- {
- return NULL;
- }
-
- if (Header->biSize == 0)
- {
- return NULL;
- }
-
- if (NULL == hDc)
- {
- BITMAPINFOHEADER *change_Header = (BITMAPINFOHEADER *)Header;
- hDc = IntGdiCreateDC(NULL, NULL, NULL, NULL,FALSE);
- if (hDc == NULL)
- {
- SetLastWin32Error(ERROR_INVALID_HANDLE);
- return NULL;
- }
- Dc = DC_LockDc(hDc);
- if (Dc == NULL)
- {
- NtGdiDeleteObjectApp(hDc);
- SetLastWin32Error(ERROR_INVALID_HANDLE);
- return NULL;
- }
-
- change_Header->biBitCount = 1;
- change_Header->biPlanes = 1;
-
- Bmp = IntCreateDIBitmap(Dc, Header, Init, Bits, Data, ColorUse);
- DC_UnlockDc(Dc);
- NtGdiDeleteObjectApp(hDc);
- }
- else
- {
- Dc = DC_LockDc(hDc);
- if (Dc == NULL)
- {
- SetLastWin32Error(ERROR_INVALID_HANDLE);
- return NULL;
- }
- Bmp = IntCreateDIBitmap(Dc, Header, Init, Bits, Data, ColorUse);
- DC_UnlockDc(Dc);
- }
-
-
-
+ if (!hDc)
+ {
+ hDc = IntGdiCreateDC(NULL, NULL, NULL, NULL,FALSE);
+ if (!hDc)
+ {
+ SetLastWin32Error(ERROR_INVALID_HANDLE);
+ return NULL;
+ }
+
+ Dc = DC_LockDc(hDc);
+ if (!Dc)
+ {
+ NtGdiDeleteObjectApp(hDc);
+ SetLastWin32Error(ERROR_INVALID_HANDLE);
+ return NULL;
+ }
+
+ cjMaxInitInfo = 1;
+ Bmp = IntCreateDIBitmap(Dc, cx, cy, cjMaxInitInfo, fInit, pjInit, pbmi, iUsage);
+
+ DC_UnlockDc(Dc);
+ NtGdiDeleteObjectApp(hDc);
+ }
+ else
+ {
+ Dc = DC_LockDc(hDc);
+ if (!Dc)
+ {
+ SetLastWin32Error(ERROR_INVALID_HANDLE);
+ return NULL;
+ }
+
+ Bmp = IntCreateDIBitmap(Dc, cx, cy, cjMaxInitInfo, fInit, pjInit, pbmi, iUsage);
+ DC_UnlockDc(Dc);
+ }
return Bmp;
}
+
HBITMAP STDCALL NtGdiCreateDIBSection(HDC hDC,
IN OPTIONAL HANDLE hSection,
@@ -1218,100 +1212,6 @@
}
}
-/*
- * DIB_GetBitmapInfo is complete copy of wine cvs 2/9-2006
- * from file dib.c from gdi32.dll or orginal version
- * did not calc the info right for some headers.
- */
-
-INT STDCALL
-DIB_GetBitmapInfo( const BITMAPINFOHEADER *header,
- PLONG width,
- PLONG height,
- PWORD planes,
- PWORD bpp,
- PLONG compr,
- PLONG size )
-{
-
- if (header->biSize == sizeof(BITMAPCOREHEADER))
- {
- BITMAPCOREHEADER *core = (BITMAPCOREHEADER *)header;
- *width = core->bcWidth;
- *height = core->bcHeight;
- *planes = core->bcPlanes;
- *bpp = core->bcBitCount;
- *compr = 0;
- *size = 0;
- return 0;
- }
-
- if (header->biSize == sizeof(BITMAPINFOHEADER))
- {
- *width = header->biWidth;
- *height = header->biHeight;
- *planes = header->biPlanes;
- *bpp = header->biBitCount;
- *compr = header->biCompression;
- *size = header->biSizeImage;
- return 1;
- }
-
- if (header->biSize == sizeof(BITMAPV4HEADER))
- {
- BITMAPV4HEADER *v4hdr = (BITMAPV4HEADER *)header;
- *width = v4hdr->bV4Width;
- *height = v4hdr->bV4Height;
- *planes = v4hdr->bV4Planes;
- *bpp = v4hdr->bV4BitCount;
- *compr = v4hdr->bV4V4Compression;
- *size = v4hdr->bV4SizeImage;
- return 4;
- }
-
- if (header->biSize == sizeof(BITMAPV5HEADER))
- {
- BITMAPV5HEADER *v5hdr = (BITMAPV5HEADER *)header;
- *width = v5hdr->bV5Width;
- *height = v5hdr->bV5Height;
- *planes = v5hdr->bV5Planes;
- *bpp = v5hdr->bV5BitCount;
- *compr = v5hdr->bV5Compression;
- *size = v5hdr->bV5SizeImage;
- return 5;
- }
- DPRINT("(%ld): wrong size for header\n", header->biSize );
- return -1;
-}
-
-// Converts a Device Independent Bitmap (DIB) to a Device Dependant Bitmap (DDB)
-// The specified Device Context (DC) defines what the DIB should be converted to
-PBITMAPOBJ FASTCALL DIBtoDDB(HGLOBAL hPackedDIB, HDC hdc) // FIXME: This should be
removed. All references to this function should
- // change to NtGdiSetDIBits
-{
- HBITMAP hBmp = 0;
- PBITMAPOBJ pBmp = NULL;
- DIBSECTION *dib;
- LPBYTE pbits = NULL;
-
- // Get a pointer to the packed DIB's data
- // pPackedDIB = (LPBYTE)GlobalLock(hPackedDIB);
- dib = hPackedDIB;
-
- pbits = (LPBYTE)(dib + DIB_BitmapInfoSize((BITMAPINFO*)&dib->dsBmih,
DIB_RGB_COLORS));
-
- // Create a DDB from the DIB
- hBmp = NtGdiCreateDIBitmap ( hdc, &dib->dsBmih, CBM_INIT,
- (LPVOID)pbits, (BITMAPINFO*)&dib->dsBmih, DIB_RGB_COLORS);
-
- // GlobalUnlock(hPackedDIB);
-
- // Retrieve the internal Pixmap from the DDB
- pBmp = BITMAPOBJ_LockBitmap(hBmp);
-
- return pBmp;
-}
-
RGBQUAD * FASTCALL
DIB_MapPaletteColors(PDC dc, CONST BITMAPINFO* lpbmi)
{
Modified: trunk/reactos/subsystems/win32/win32k/stubs/stubs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/st…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/stubs/stubs.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/stubs/stubs.c [iso-8859-1] Sun Mar 30 17:37:42
2008
@@ -1682,30 +1682,6 @@
/*
* @unimplemented
*/
-
-HBITMAP
-APIENTRY
-NtGdiCreateDIBitmapInternal(
- IN HDC hdc,
- IN INT cx,
- IN INT cy,
- IN DWORD fInit,
- IN OPTIONAL LPBYTE pjInit,
- IN OPTIONAL LPBITMAPINFO pbmi,
- IN DWORD iUsage,
- IN UINT cjMaxInitInfo,
- IN UINT cjMaxBits,
- IN FLONG f,
- IN HANDLE hcmXform)
-{
- UNIMPLEMENTED;
- return NULL;
-}
-
-
- /*
- * @unimplemented
- */
HBITMAP
APIENTRY
NtGdiClearBitmapAttributes(
Modified: trunk/reactos/subsystems/win32/win32k/w32ksvc.db
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/w3…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/w32ksvc.db [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/w32ksvc.db [iso-8859-1] Sun Mar 30 17:37:42
2008
@@ -716,7 +716,6 @@
NtUserSendMessageTimeout 8
NtUserSendNotifyMessage 4
NtUserSetScrollBarInfo 3
-NtGdiCreateDIBitmap 6
NtGdiGetFontFamilyInfo 4
NtGdiOffsetViewportOrgEx 4
NtGdiOffsetWindowOrgEx 4