From d82ce80d6c3e52b00340e5b79e54027dafab1b32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Sat, 3 May 2003 14:38:11 +0000 Subject: [PATCH] (Partial) implementation of W32kGetDIBits() svn path=/trunk/; revision=4641 --- reactos/subsys/win32k/objects/dib.c | 74 ++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/reactos/subsys/win32k/objects/dib.c b/reactos/subsys/win32k/objects/dib.c index 0b196b79206..b58dd5b4d63 100644 --- a/reactos/subsys/win32k/objects/dib.c +++ b/reactos/subsys/win32k/objects/dib.c @@ -5,7 +5,9 @@ #include #include "../eng/handle.h" #include +#include #include +#include #define NDEBUG #include @@ -199,10 +201,78 @@ INT STDCALL W32kGetDIBits(HDC hDC, UINT StartScan, UINT ScanLines, LPVOID Bits, - LPBITMAPINFO bi, + LPBITMAPINFO UnsafeInfo, UINT Usage) { - UNIMPLEMENTED; + BITMAPINFO Info; + PBITMAPOBJ BitmapObj; + INT Result; + NTSTATUS Status; + + BitmapObj = (PBITMAPOBJ) GDIOBJ_LockObj(hBitmap, GO_BITMAP_MAGIC); + if (NULL == BitmapObj) + { + SetLastWin32Error(ERROR_INVALID_HANDLE); + return 0; + } + + RtlZeroMemory(&Info, sizeof(BITMAPINFO)); + Status = MmCopyFromCaller(&(Info.bmiHeader.biSize), + &(UnsafeInfo->bmiHeader.biSize), + sizeof(DWORD)); + if (! NT_SUCCESS(Status)) + { + SetLastNtError(Status); + GDIOBJ_UnlockObj(hBitmap, GO_BITMAP_MAGIC); + return 0; + } + if (sizeof(BITMAPCOREHEADER) != Info.bmiHeader.biSize && + sizeof(BITMAPINFOHEADER) != Info.bmiHeader.biSize) + { + SetLastWin32Error(ERROR_INVALID_PARAMETER); + GDIOBJ_UnlockObj(hBitmap, GO_BITMAP_MAGIC); + return 0; + } + Status = MmCopyFromCaller(&(Info.bmiHeader), + &(UnsafeInfo->bmiHeader), + Info.bmiHeader.biSize); + if (! NT_SUCCESS(Status)) + { + SetLastNtError(Status); + GDIOBJ_UnlockObj(hBitmap, GO_BITMAP_MAGIC); + return 0; + } + + if (NULL == Bits) + { + if (0 != Info.bmiHeader.biCompression) + { + UNIMPLEMENTED; + } + + Info.bmiHeader.biWidth = BitmapObj->bitmap.bmWidth; + Info.bmiHeader.biHeight = BitmapObj->bitmap.bmHeight; + Info.bmiHeader.biPlanes = BitmapObj->bitmap.bmPlanes; + Info.bmiHeader.biBitCount = BitmapObj->bitmap.bmBitsPixel; + Info.bmiHeader.biCompression = BI_RGB; + Info.bmiHeader.biSizeImage = BitmapObj->bitmap.bmHeight * BitmapObj->bitmap.bmWidthBytes; + Status = MmCopyToCaller(UnsafeInfo, &Info, UnsafeInfo->bmiHeader.biSize); + if (! NT_SUCCESS(Status)) + { + SetLastNtError(Status); + GDIOBJ_UnlockObj(hBitmap, GO_BITMAP_MAGIC); + return 0; + } + Result = 1; + } + else + { + UNIMPLEMENTED; + } + + GDIOBJ_UnlockObj(hBitmap, GO_BITMAP_MAGIC); + + return Result; } INT STDCALL W32kStretchDIBits(HDC hDC,