From ca6fc5cff947a2c7e2b7befe73394d17b9c852f5 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 26 Jul 2007 15:20:29 +0000 Subject: [PATCH] - implement CreateBitmapIndirect, calling NtGdicreateBitmap - NtGdiCreateBitmap: directly do the job instead of calling IntCreateBitmapIndirect - remove IntCreateBitmapIndirect - remove NtGdiCreateBitmapIndirect - update ntgdibad.h svn path=/trunk/; revision=27851 --- reactos/dll/win32/gdi32/gdi32.def | 2 +- reactos/dll/win32/gdi32/objects/bitmap.c | 17 ++++ reactos/include/reactos/win32k/ntgdibad.h | 7 -- .../subsystems/win32/win32k/objects/bitmaps.c | 88 +++++-------------- reactos/tools/nci/w32ksvc.db | 1 - 5 files changed, 42 insertions(+), 73 deletions(-) diff --git a/reactos/dll/win32/gdi32/gdi32.def b/reactos/dll/win32/gdi32/gdi32.def index a86f7413399..ca88a18036f 100644 --- a/reactos/dll/win32/gdi32/gdi32.def +++ b/reactos/dll/win32/gdi32/gdi32.def @@ -48,7 +48,7 @@ CopyEnhMetaFileW@8 CopyMetaFileA@8 CopyMetaFileW@8 CreateBitmap@20=NtGdiCreateBitmap@20 -CreateBitmapIndirect@4=NtGdiCreateBitmapIndirect@4 +CreateBitmapIndirect@4 CreateBrushIndirect@4 CreateColorSpaceA@4 CreateColorSpaceW@4 diff --git a/reactos/dll/win32/gdi32/objects/bitmap.c b/reactos/dll/win32/gdi32/objects/bitmap.c index 9fd1043a237..1e3019e4d6e 100644 --- a/reactos/dll/win32/gdi32/objects/bitmap.c +++ b/reactos/dll/win32/gdi32/objects/bitmap.c @@ -84,3 +84,20 @@ StretchBlt( return NtGdiBitBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, hdcSrc, nXOriginSrc, nYOriginSrc, dwRop, 0, 0); } + +/* + * @implemented + */ +HBITMAP WINAPI +CreateBitmapIndirect(const BITMAP *pbm) +{ + if (pbm) + { + return NtGdiCreateBitmap(pbm->bmWidth, + pbm->bmHeight, + pbm->bmPlanes, + pbm->bmBitsPixel, + pbm->bmBits); + } + return NULL; +} diff --git a/reactos/include/reactos/win32k/ntgdibad.h b/reactos/include/reactos/win32k/ntgdibad.h index 7b52e731d5b..d06c8891493 100644 --- a/reactos/include/reactos/win32k/ntgdibad.h +++ b/reactos/include/reactos/win32k/ntgdibad.h @@ -194,13 +194,6 @@ NtGdiCopyMetaFile ( LPCWSTR File ); -/* Use NtGdiCreateBitmap and expand the pbm-> */ -HBITMAP -STDCALL -NtGdiCreateBitmapIndirect ( - CONST BITMAP * BM - ); - /* Use NtGdiCreateDIBitmapInternal */ HBITMAP STDCALL diff --git a/reactos/subsystems/win32/win32k/objects/bitmaps.c b/reactos/subsystems/win32/win32k/objects/bitmaps.c index bc42b6cdcd7..18189441cc6 100644 --- a/reactos/subsystems/win32/win32k/objects/bitmaps.c +++ b/reactos/subsystems/win32/win32k/objects/bitmaps.c @@ -400,36 +400,42 @@ done: return Ret; } -static HBITMAP -IntCreateBitmapIndirect(CONST BITMAP *BM) +HBITMAP STDCALL +NtGdiCreateBitmap( + INT Width, + INT Height, + UINT Planes, + UINT BitsPixel, + IN OPTIONAL LPBYTE Bits) { PBITMAPOBJ bmp; HBITMAP hBitmap; SIZEL Size; - UINT BitsPixel; + LONG WidthBytes; /* NOTE: Windows also doesn't store nr. of planes separately! */ - BitsPixel = BM->bmBitsPixel * BM->bmPlanes; + BitsPixel = BitsPixel * Planes; + WidthBytes = BITMAPOBJ_GetWidthBytes(Width, BitsPixel); /* Check parameters */ - if (0 == BM->bmHeight || 0 == BM->bmWidth) + if (0 == Height || 0 == Width) { Size.cx = Size.cy = 1; } else { - Size.cx = abs(BM->bmWidth); - Size.cy = abs(BM->bmHeight); + Size.cx = abs(Width); + Size.cy = abs(Height); } /* Create the bitmap object. */ - hBitmap = IntCreateBitmap(Size, BM->bmWidthBytes, + hBitmap = IntCreateBitmap(Size, WidthBytes, BitmapFormat(BitsPixel, BI_RGB), - (BM->bmHeight < 0 ? BMF_TOPDOWN : 0) | - (NULL == BM->bmBits ? 0 : BMF_NOZEROINIT), NULL); + (Height < 0 ? BMF_TOPDOWN : 0) | + (NULL == Bits ? 0 : BMF_NOZEROINIT), NULL); if (!hBitmap) { - DPRINT("NtGdiCreateBitmap: IntCreateBitmap returned 0\n"); + DPRINT("NtGdiCreateBitmap: returned 0\n"); return 0; } @@ -452,35 +458,14 @@ IntCreateBitmapIndirect(CONST BITMAP *BM) * to us it should be safe. */ - if (NULL != BM->bmBits) + if (NULL != Bits) { - NtGdiSetBitmapBits(hBitmap, bmp->SurfObj.cjBits, BM->bmBits); + NtGdiSetBitmapBits(hBitmap, bmp->SurfObj.cjBits, Bits); } return hBitmap; } -HBITMAP STDCALL -NtGdiCreateBitmap( - INT Width, - INT Height, - UINT Planes, - UINT BitsPixel, - IN OPTIONAL LPBYTE Bits) -{ - BITMAP BM; - - BM.bmType = 0; - BM.bmWidth = Width; - BM.bmHeight = Height; - BM.bmWidthBytes = BITMAPOBJ_GetWidthBytes(Width, Planes * BitsPixel); - BM.bmPlanes = Planes; - BM.bmBitsPixel = BitsPixel; - BM.bmBits = Bits; - - return IntCreateBitmapIndirect(&BM); -} - BOOL INTERNAL_CALL BITMAP_Cleanup(PVOID ObjectBody) { @@ -569,35 +554,6 @@ NtGdiCreateCompatibleBitmap( return Bmp; } -HBITMAP STDCALL -NtGdiCreateBitmapIndirect(CONST BITMAP *UnsafeBM) -{ - BITMAP BM; - NTSTATUS Status = STATUS_SUCCESS; - - _SEH_TRY - { - ProbeForRead(UnsafeBM, sizeof(BITMAP), 1); - BM = *UnsafeBM; - if (NULL != BM.bmBits) - { - ProbeForRead(BM.bmBits, BM.bmWidthBytes * abs(BM.bmHeight), 2); - } - } - _SEH_HANDLE - { - Status = _SEH_GetExceptionCode(); - } - _SEH_END; - if(!NT_SUCCESS(Status)) - { - SetLastNtError(Status); - return NULL; - } - - return IntCreateBitmapIndirect(&BM); -} - HBITMAP STDCALL NtGdiCreateDiscardableBitmap( HDC hDC, @@ -1546,7 +1502,11 @@ BITMAPOBJ_CopyBitmap(HBITMAP hBitmap) if (Bitmap->SurfObj.lDelta >= 0) bm.bmHeight = -bm.bmHeight; - res = IntCreateBitmapIndirect(&bm); + res = NtGdiCreateBitmap(bm.bmWidth, + bm.bmHeight, + bm.bmPlanes, + bm.bmBitsPixel, + bm.bmBits); if(res) { PBYTE buf; diff --git a/reactos/tools/nci/w32ksvc.db b/reactos/tools/nci/w32ksvc.db index 9dc116f1be8..6888e6d1104 100644 --- a/reactos/tools/nci/w32ksvc.db +++ b/reactos/tools/nci/w32ksvc.db @@ -21,7 +21,6 @@ NtGdiCombineTransform 3 NtGdiCopyEnhMetaFile 2 NtGdiCopyMetaFile 2 NtGdiCreateBitmap 5 -NtGdiCreateBitmapIndirect 1 NtGdiCreateColorSpace 1 NtGdiCreateCompatibleBitmap 3 NtGdiCreateCompatibleDC 1