Author: jimtabor
Date: Fri Apr 18 18:51:29 2008
New Revision: 33028
URL:
http://svn.reactos.org/svn/reactos?rev=33028&view=rev
Log:
PatchPatch by Stefan Ginsberg (stefan__100__ AT hotmail DOT com): Gdi32 half only:
Implement SetDIBits, I made corrections to the patch to handle palette and proper hdc
handling.
Modified:
trunk/reactos/dll/win32/gdi32/misc/hacks.c
trunk/reactos/dll/win32/gdi32/objects/bitmap.c
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] Fri Apr 18 18:51:29 2008
@@ -9,23 +9,6 @@
* Api that are hacked but we can not do correct implemtions yetm but using own syscall
*
*/
-
-/*
- * @unimplemented
- */
-int
-STDCALL
-SetDIBits(HDC hdc,
- HBITMAP hbmp,
- UINT uStartScan,
- UINT cScanLines,
- CONST VOID *lpvBits,
- CONST BITMAPINFO *lpbmi,
- UINT fuColorUse)
-{
- /* FIXME share memory */
- return NtGdiSetDIBits(hdc, hbmp, uStartScan, cScanLines, lpvBits, lpbmi,
fuColorUse);
-}
/*
* @implemented
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] Fri Apr 18 18:51:29 2008
@@ -295,3 +295,96 @@
0);
}
+
+/*
+ * @implemented
+ */
+INT
+STDCALL
+SetDIBits(HDC hDC,
+ HBITMAP hBitmap,
+ UINT uStartScan,
+ UINT cScanLines,
+ CONST VOID *lpvBits,
+ CONST BITMAPINFO *lpbmi,
+ UINT fuColorUse)
+{
+ HDC hDCc, SavehDC, nhDC;
+ DWORD dwWidth, dwHeight;
+ HGDIOBJ hOldBitmap;
+ HPALETTE hPal = NULL;
+ INT LinesCopied = 0;
+ BOOL newDC = FALSE;
+
+ if ( !lpvBits || (GDI_HANDLE_GET_TYPE(hBitmap) != GDI_OBJECT_TYPE_BITMAP) )
+ return 0;
+
+ if ( lpbmi )
+ {
+ if ( lpbmi->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER) )
+ {
+ if ( lpbmi->bmiHeader.biCompression == BI_JPEG ||
lpbmi->bmiHeader.biCompression == BI_PNG )
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return 0;
+ }
+ }
+ }
+
+ hDCc = NtGdiGetDCforBitmap(hBitmap);
+ SavehDC = hDCc;
+ if ( !hDCc )
+ {
+ nhDC = CreateCompatibleDC(hDC);
+ if ( !nhDC ) return 0;
+ newDC = TRUE;
+ SavehDC = nhDC;
+ }
+ else if ( !SaveDC(hDCc) )
+ return 0;
+
+ hOldBitmap = SelectObject(SavehDC, hBitmap);
+
+ if ( hOldBitmap )
+ {
+ if ( hDC )
+ hPal = SelectPalette(SavehDC, (HPALETTE)GetDCObject(hDC, GDI_OBJECT_TYPE_PALETTE),
FALSE);
+
+ if ( lpbmi->bmiHeader.biSize < sizeof(BITMAPINFOHEADER))
+ {
+ PBITMAPCOREINFO pbci = (PBITMAPCOREINFO) lpbmi;
+ dwWidth = pbci->bmciHeader.bcWidth;
+ dwHeight = pbci->bmciHeader.bcHeight;
+ }
+ else
+ {
+ dwWidth = lpbmi->bmiHeader.biWidth;
+ dwHeight = abs(lpbmi->bmiHeader.biHeight);
+ }
+
+ LinesCopied = SetDIBitsToDevice(SavehDC,
+ 0,
+ 0,
+ dwWidth,
+ dwHeight,
+ 0,
+ 0,
+ uStartScan,
+ cScanLines,
+ (void *)lpvBits,
+ (LPBITMAPINFO)lpbmi,
+ fuColorUse);
+
+ if ( hDC ) SelectPalette(SavehDC, hPal, FALSE);
+
+ SelectObject(SavehDC, hOldBitmap);
+ }
+
+ if ( newDC )
+ DeleteDC((HDC)SavehDC);
+ else
+ RestoreDC((HDC)SavehDC, -1);
+
+ return LinesCopied;
+}
+