branch update for HEAD-2003050101
[reactos.git] / subsys / win32k / objects / dib.c
index 2e2e86e..869cad6 100644 (file)
@@ -3,11 +3,12 @@
 #include <stdlib.h>
 #include <win32k/bitmaps.h>
 #include <win32k/debug.h>
-#include <debug.h>
 #include "../eng/handle.h"
 #include <ntos/minmax.h>
+#include <include/inteng.h>
 
-VOID BitmapToSurf(HDC hdc, PSURFGDI SurfGDI, PSURFOBJ SurfObj, PBITMAPOBJ Bitmap);
+#define NDEBUG
+#include <win32k/debug1.h>
 
 UINT STDCALL W32kSetDIBColorTable(HDC  hDC,
                            UINT  StartIndex,
@@ -97,13 +98,11 @@ INT STDCALL W32kSetDIBits(HDC  hDC,
     lpRGB = &bmi->bmiColors[0];
 
   // Create a temporary surface for the destination bitmap
-  DestBitmap = (HBITMAP)CreateGDIHandle(sizeof(SURFGDI), sizeof(SURFOBJ));
+  DestBitmap = BitmapToSurf(bitmap);
 
   DestSurf   = (PSURFOBJ) AccessUserObject( DestBitmap );
   DestGDI    = (PSURFGDI) AccessInternalObject( DestBitmap );
 
-  BitmapToSurf(hDC, DestGDI, DestSurf, bitmap);
-
   // Create source surface
   SourceSize.cx = bmi->bmiHeader.biWidth;
   SourceSize.cy = abs(bmi->bmiHeader.biHeight);
@@ -134,7 +133,7 @@ INT STDCALL W32kSetDIBits(HDC  hDC,
   DIB_Palette = BuildDIBPalette(bmi, &DIB_Palette_Type);
 
   // Determine XLATEOBJ for color translation
-  XlateObj = EngCreateXlate(DDB_Palette_Type, DIB_Palette_Type, DDB_Palette, DIB_Palette);
+  XlateObj = IntEngCreateXlate(DDB_Palette_Type, DIB_Palette_Type, DDB_Palette, DIB_Palette);
 
   // Zero point
   ZeroPoint.x = 0;
@@ -155,6 +154,8 @@ INT STDCALL W32kSetDIBits(HDC  hDC,
   }
 
   // Clean up
+  EngDeleteXlate(XlateObj);
+  EngDeletePalette(DIB_Palette);
   EngDeleteSurface(SourceBitmap);
   EngDeleteSurface(DestBitmap);
 
@@ -351,7 +352,7 @@ HBITMAP STDCALL W32kCreateDIBitmap(HDC hdc, const BITMAPINFOHEADER *header,
   }
   else
   {
-      DbgPrint("(%ld): wrong size for data\n", data->bmiHeader.biSize );
+      DPRINT("(%ld): wrong size for data\n", data->bmiHeader.biSize );
       return 0;
     }
   }
@@ -426,7 +427,7 @@ HBITMAP DIB_CreateDIBSection(
   UINT Entries = 0;
   BITMAP bm;
 
-  DbgPrint("format (%ld,%ld), planes %d, bpp %d, size %ld, colors %ld (%s)\n",
+  DPRINT("format (%ld,%ld), planes %d, bpp %d, size %ld, colors %ld (%s)\n",
        bi->biWidth, bi->biHeight, bi->biPlanes, bi->biBitCount,
        bi->biSizeImage, bi->biClrUsed, usage == DIB_PAL_COLORS? "PAL" : "RGB");
 
@@ -448,7 +449,7 @@ HBITMAP DIB_CreateDIBSection(
   if (section)
 /*    bm.bmBits = MapViewOfFile(section, FILE_MAP_ALL_ACCESS,
                              0L, offset, totalSize); */
-    DbgPrint("DIB_CreateDIBSection: Cannot yet handle section DIBs\n");
+    DPRINT("DIB_CreateDIBSection: Cannot yet handle section DIBs\n");
   else if (ovr_pitch && offset)
     bm.bmBits = (LPVOID) offset;
   else {
@@ -529,7 +530,7 @@ HBITMAP DIB_CreateDIBSection(
   // Clean up in case of errors
   if (!res || !bmp || !dib || !bm.bmBits)
   {
-    DbgPrint("got an error res=%08x, bmp=%p, dib=%p, bm.bmBits=%p\n", res, bmp, dib, bm.bmBits);
+    DPRINT("got an error res=%08x, bmp=%p, dib=%p, bm.bmBits=%p\n", res, bmp, dib, bm.bmBits);
 /*      if (bm.bmBits)
       {
       if (section)
@@ -656,7 +657,7 @@ int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, DWORD *width,
     *compr  = 0;
     return 0;
   }
-  DbgPrint("(%ld): wrong size for header\n", header->biSize );
+  DPRINT("(%ld): wrong size for header\n", header->biSize );
   return -1;
 }