ReactOS  0.4.15-dev-1636-gf634010
dibobj.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS win32 kernel mode subsystem
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: win32ss/gdi/ntgdi/dibobj.c
5  * PURPOSE: Dib object functions
6  * PROGRAMMER:
7  */
8 
9 #include <win32k.h>
10 
11 #define NDEBUG
12 #include <debug.h>
13 
14 static const RGBQUAD DefLogPaletteQuads[20] = /* Copy of Default Logical Palette */
15 {
16  /* rgbBlue, rgbGreen, rgbRed, rgbReserved */
17  { 0x00, 0x00, 0x00, 0x00 },
18  { 0x00, 0x00, 0x80, 0x00 },
19  { 0x00, 0x80, 0x00, 0x00 },
20  { 0x00, 0x80, 0x80, 0x00 },
21  { 0x80, 0x00, 0x00, 0x00 },
22  { 0x80, 0x00, 0x80, 0x00 },
23  { 0x80, 0x80, 0x00, 0x00 },
24  { 0xc0, 0xc0, 0xc0, 0x00 },
25  { 0xc0, 0xdc, 0xc0, 0x00 },
26  { 0xf0, 0xca, 0xa6, 0x00 },
27  { 0xf0, 0xfb, 0xff, 0x00 },
28  { 0xa4, 0xa0, 0xa0, 0x00 },
29  { 0x80, 0x80, 0x80, 0x00 },
30  { 0x00, 0x00, 0xff, 0x00 },
31  { 0x00, 0xff, 0x00, 0x00 },
32  { 0x00, 0xff, 0xff, 0x00 },
33  { 0xff, 0x00, 0x00, 0x00 },
34  { 0xff, 0x00, 0xff, 0x00 },
35  { 0xff, 0xff, 0x00, 0x00 },
36  { 0xff, 0xff, 0xff, 0x00 }
37 };
38 
40 NTAPI
42  _In_ const BITMAPINFO *pbmi,
43  _In_ PDC pdc,
45 {
46  PPALETTE ppal;
47  ULONG i, cBitsPixel, cColors;
48 
49  if (pbmi->bmiHeader.biSize < sizeof(BITMAPINFOHEADER))
50  {
52  cBitsPixel = pbci->bmciHeader.bcBitCount;
53  }
54  else
55  {
56  cBitsPixel = pbmi->bmiHeader.biBitCount;
57  }
58 
59  /* Check if the colors are indexed */
60  if (cBitsPixel <= 8)
61  {
62  /* We create a "full" palette */
63  cColors = 1 << cBitsPixel;
64 
65  /* Allocate the palette */
67  cColors,
68  NULL,
69  0,
70  0,
71  0);
72 
73  /* Check if the BITMAPINFO specifies how many colors to use */
74  if ((pbmi->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER)) &&
75  (pbmi->bmiHeader.biClrUsed != 0))
76  {
77  /* This is how many colors we can actually process */
78  cColors = min(cColors, pbmi->bmiHeader.biClrUsed);
79  }
80 
81  /* Check how to use the colors */
82  if (iUsage == DIB_PAL_COLORS)
83  {
84  COLORREF crColor;
85 
86  /* The colors are an array of WORD indices into the DC palette */
87  PWORD pwColors = (PWORD)((PCHAR)pbmi + pbmi->bmiHeader.biSize);
88 
89  /* Use the DCs palette or, if no DC is given, the default one */
90  PPALETTE ppalDC = pdc ? pdc->dclevel.ppal : gppalDefault;
91 
92  /* Loop all color indices in the DIB */
93  for (i = 0; i < cColors; i++)
94  {
95  /* Get the palette index and handle wraparound when exceeding
96  the number of colors in the DC palette */
97  WORD wIndex = pwColors[i] % ppalDC->NumColors;
98 
99  /* USe the RGB value from the DC palette */
100  crColor = PALETTE_ulGetRGBColorFromIndex(ppalDC, wIndex);
101  PALETTE_vSetRGBColorForIndex(ppal, i, crColor);
102  }
103  }
104  else if (iUsage == DIB_PAL_BRUSHHACK)
105  {
106  /* The colors are an array of WORD indices into the DC palette */
107  PWORD pwColors = (PWORD)((PCHAR)pbmi + pbmi->bmiHeader.biSize);
108 
109  /* Loop all color indices in the DIB */
110  for (i = 0; i < cColors; i++)
111  {
112  /* Set the index directly as the RGB color, the real palette
113  containing RGB values will be calculated when the brush is
114  realized */
115  PALETTE_vSetRGBColorForIndex(ppal, i, pwColors[i]);
116  }
117 
118  /* Mark the palette as a brush hack palette */
119  ppal->flFlags |= PAL_BRUSHHACK;
120  }
121 // else if (iUsage == 2)
122 // {
123  // FIXME: this one is undocumented
124 // ASSERT(FALSE);
125 // }
126  else if (pbmi->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER))
127  {
128  /* The colors are an array of RGBQUAD values */
129  RGBQUAD *prgb = (RGBQUAD*)((PCHAR)pbmi + pbmi->bmiHeader.biSize);
130 
131  // FIXME: do we need to handle PALETTEINDEX / PALETTERGB macro?
132 
133  /* Loop all color indices in the DIB */
134  for (i = 0; i < cColors; i++)
135  {
136  /* Get the color value and translate it to a COLORREF */
137  RGBQUAD rgb = prgb[i];
138  COLORREF crColor = RGB(rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue);
139 
140  /* Set the RGB value in the palette */
141  PALETTE_vSetRGBColorForIndex(ppal, i, crColor);
142  }
143  }
144  else
145  {
146  /* The colors are an array of RGBTRIPLE values */
148 
149  /* Loop all color indices in the DIB */
150  for (i = 0; i < cColors; i++)
151  {
152  /* Get the color value and translate it to a COLORREF */
153  RGBTRIPLE rgb = prgb[i];
154  COLORREF crColor = RGB(rgb.rgbtRed, rgb.rgbtGreen, rgb.rgbtBlue);
155 
156  /* Set the RGB value in the palette */
157  PALETTE_vSetRGBColorForIndex(ppal, i, crColor);
158  }
159  }
160  }
161  else
162  {
163  /* This is a bitfield / RGB palette */
164  ULONG flRedMask, flGreenMask, flBlueMask;
165 
166  /* Check if the DIB contains bitfield values */
167  if ((pbmi->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER)) &&
169  {
170  /* Check if we have a v4/v5 header */
171  if (pbmi->bmiHeader.biSize >= sizeof(BITMAPV4HEADER))
172  {
173  /* The masks are dedicated fields in the header */
175  flRedMask = pbmV4Header->bV4RedMask;
176  flGreenMask = pbmV4Header->bV4GreenMask;
177  flBlueMask = pbmV4Header->bV4BlueMask;
178  }
179  else
180  {
181  /* The masks are the first 3 values in the DIB color table */
182  PDWORD pdwColors = (PVOID)((PCHAR)pbmi + pbmi->bmiHeader.biSize);
183  flRedMask = pdwColors[0];
184  flGreenMask = pdwColors[1];
185  flBlueMask = pdwColors[2];
186  }
187  }
188  else
189  {
190  /* Check what bit depth we have. Note: optimization flags are
191  calculated in PALETTE_AllocPalette() */
192  if (cBitsPixel == 16)
193  {
194  /* This is an RGB 555 palette */
195  flRedMask = 0x7C00;
196  flGreenMask = 0x03E0;
197  flBlueMask = 0x001F;
198  }
199  else
200  {
201  /* This is an RGB 888 palette */
202  flRedMask = 0xFF0000;
203  flGreenMask = 0x00FF00;
204  flBlueMask = 0x0000FF;
205  }
206  }
207 
208  /* Allocate the bitfield palette */
210  0,
211  NULL,
212  flRedMask,
213  flGreenMask,
214  flBlueMask);
215  }
216 
217  /* We're done, return the palette */
218  return ppal;
219 }
220 
221 // Converts a DIB to a device-dependent bitmap
222 static INT
223 FASTCALL
225  PDC DC,
227  UINT StartScan,
228  UINT ScanLines,
229  CONST VOID *Bits,
231  CONST BITMAPINFO *bmi,
232  UINT ColorUse)
233 {
234  HBITMAP SourceBitmap;
235  PSURFACE psurfDst, psurfSrc;
236  INT result = 0;
237  RECT rcDst;
238  POINTL ptSrc;
239  EXLATEOBJ exlo;
240  PPALETTE ppalDIB = 0;
241  ULONG cjSizeImage;
242 
243  if (!bmi || !Bits) return 0;
244 
245  /* Check for uncompressed formats */
246  if ((bmi->bmiHeader.biCompression == BI_RGB) ||
247  (bmi->bmiHeader.biCompression == BI_BITFIELDS))
248  {
249  /* Calculate the image size */
250  cjSizeImage = DIB_GetDIBImageBytes(bmi->bmiHeader.biWidth,
251  ScanLines,
252  bmi->bmiHeader.biBitCount);
253  }
254  /* Check if the header provided an image size */
255  else if (bmi->bmiHeader.biSizeImage != 0)
256  {
257  /* Use the given size */
258  cjSizeImage = bmi->bmiHeader.biSizeImage;
259  }
260  else
261  {
262  /* Compressed format without a size. This is invalid. */
263  DPRINT1("Compressed format without a size!");
264  return 0;
265  }
266 
267  /* Check if the size that we have is ok */
268  if ((cjSizeImage > cjMaxBits) || (cjSizeImage == 0))
269  {
270  DPRINT1("Invalid bitmap size! cjSizeImage = %lu, cjMaxBits = %lu\n",
271  cjSizeImage, cjMaxBits);
272  return 0;
273  }
274 
275  SourceBitmap = GreCreateBitmapEx(bmi->bmiHeader.biWidth,
276  ScanLines,
277  0,
278  BitmapFormat(bmi->bmiHeader.biBitCount,
279  bmi->bmiHeader.biCompression),
280  bmi->bmiHeader.biHeight < 0 ? BMF_TOPDOWN : 0,
281  cjSizeImage,
282  (PVOID)Bits,
283  0);
284  if (!SourceBitmap)
285  {
286  DPRINT1("Error: Could not create a bitmap.\n");
288  return 0;
289  }
290 
291  psurfDst = SURFACE_ShareLockSurface(hBitmap);
292  psurfSrc = SURFACE_ShareLockSurface(SourceBitmap);
293 
294  if(!(psurfSrc && psurfDst))
295  {
296  DPRINT1("Error: Could not lock surfaces\n");
297  goto cleanup;
298  }
299 
300  /* Create a palette for the DIB */
301  ppalDIB = CreateDIBPalette(bmi, DC, ColorUse);
302  if (!ppalDIB)
303  {
305  goto cleanup;
306  }
307 
308  /* Initialize EXLATEOBJ */
309  EXLATEOBJ_vInitialize(&exlo,
310  ppalDIB,
311  psurfDst->ppal,
312  RGB(0xff, 0xff, 0xff),
313  RGB(0xff, 0xff, 0xff), //DC->pdcattr->crBackgroundClr,
314  0); // DC->pdcattr->crForegroundClr);
315 
316  rcDst.top = StartScan;
317  rcDst.left = 0;
318  rcDst.bottom = rcDst.top + ScanLines;
319  rcDst.right = psurfDst->SurfObj.sizlBitmap.cx;
320  ptSrc.x = 0;
321  ptSrc.y = 0;
322 
323  result = IntEngCopyBits(&psurfDst->SurfObj,
324  &psurfSrc->SurfObj,
325  NULL,
326  &exlo.xlo,
327  &rcDst,
328  &ptSrc);
329  if(result)
330  result = ScanLines;
331 
332  EXLATEOBJ_vCleanup(&exlo);
333 
334 cleanup:
335  if (ppalDIB) PALETTE_ShareUnlockPalette(ppalDIB);
336  if(psurfSrc) SURFACE_ShareUnlockSurface(psurfSrc);
337  if(psurfDst) SURFACE_ShareUnlockSurface(psurfDst);
338  GreDeleteObject(SourceBitmap);
339 
340  return result;
341 }
342 
343 static
344 HBITMAP
346  DWORD Width,
347  DWORD Height,
348  ULONG Compression,
349  const BYTE* Bits,
350  DWORD BitsSize)
351 {
352  HBITMAP Mask;
353  DWORD x, y;
354  SURFOBJ* SurfObj;
355  UINT i = 0;
356  BYTE Data, NumPixels, ToSkip;
357 
358  ASSERT((Compression == BI_RLE8) || (Compression == BI_RLE4));
359 
360  /* Create the bitmap */
361  Mask = GreCreateBitmapEx(Width, Height, 0, BMF_1BPP, 0, 0, NULL, 0);
362  if (!Mask)
363  return NULL;
364 
365  SurfObj = EngLockSurface((HSURF)Mask);
366  if (!SurfObj)
367  {
369  return NULL;
370  }
371  ASSERT(SurfObj->pvBits != NULL);
372 
373  x = y = 0;
374 
375  while (i < BitsSize)
376  {
377  NumPixels = Bits[i];
378  Data = Bits[i + 1];
379  i += 2;
380 
381  if (NumPixels != 0)
382  {
383  if ((x + NumPixels) > Width)
384  NumPixels = Width - x;
385 
386  if (NumPixels == 0)
387  continue;
388 
389  DIB_1BPP_HLine(SurfObj, x, x + NumPixels, y, 1);
390  x += NumPixels;
391  continue;
392  }
393 
394  if (Data < 3)
395  {
396  switch (Data)
397  {
398  case 0:
399  /* End of line */
400  y++;
401  if (y == Height)
402  goto done;
403  x = 0;
404  break;
405  case 1:
406  /* End of file */
407  goto done;
408  case 2:
409  /* Jump */
410  if (i >= (BitsSize - 1))
411  goto done;
412  x += Bits[i];
413  if (x > Width)
414  x = Width;
415  y += Bits[i + 1];
416  if (y >= Height)
417  goto done;
418  i += 2;
419  break;
420  }
421  /* Done for this run */
422  continue;
423  }
424 
425  /* Embedded data into the RLE */
426  NumPixels = Data;
427  if (Compression == BI_RLE8)
428  ToSkip = NumPixels;
429  else
430  ToSkip = (NumPixels / 2) + (NumPixels & 1);
431 
432  if ((i + ToSkip) > BitsSize)
433  goto done;
434  ToSkip = (ToSkip + 1) & ~1;
435 
436  if ((x + NumPixels) > Width)
437  NumPixels = Width - x;
438 
439  if (NumPixels != 0)
440  {
441  DIB_1BPP_HLine(SurfObj, x, x + NumPixels, y, 1);
442  x += NumPixels;
443  }
444  i += ToSkip;
445  }
446 
447 done:
448  EngUnlockSurface(SurfObj);
449  return Mask;
450 }
451 
452 W32KAPI
453 INT
454 APIENTRY
456  IN HDC hDC,
457  IN INT XDest,
458  IN INT YDest,
459  IN DWORD Width,
460  IN DWORD Height,
461  IN INT XSrc,
462  IN INT YSrc,
463  IN DWORD StartScan,
464  IN DWORD ScanLines,
465  IN LPBYTE Bits,
466  IN LPBITMAPINFO bmi,
467  IN DWORD ColorUse,
468  IN UINT cjMaxBits,
469  IN UINT cjMaxInfo,
470  IN BOOL bTransformCoordinates,
472 {
473  INT ret;
474  PDC pDC = NULL;
475  HBITMAP hSourceBitmap = NULL, hMaskBitmap = NULL;
476  SURFOBJ *pDestSurf, *pSourceSurf = NULL, *pMaskSurf = NULL;
477  SURFACE *pSurf;
478  RECTL rcDest;
479  POINTL ptSource;
480  //INT DIBWidth;
481  SIZEL SourceSize;
482  EXLATEOBJ exlo;
483  PPALETTE ppalDIB = NULL;
484  LPBITMAPINFO pbmiSafe;
485  BOOL bResult;
486 
487  if (!Bits) return 0;
488 
489  pbmiSafe = ExAllocatePoolWithTag(PagedPool, cjMaxInfo, 'pmTG');
490  if (!pbmiSafe) return 0;
491 
492  _SEH2_TRY
493  {
494  ProbeForRead(bmi, cjMaxInfo, 1);
495  ProbeForRead(Bits, cjMaxBits, 1);
496  RtlCopyMemory(pbmiSafe, bmi, cjMaxInfo);
497  bmi = pbmiSafe;
498  }
500  {
501  ret = 0;
502  goto Exit;
503  }
504  _SEH2_END
505 
506  ScanLines = min(ScanLines, abs(bmi->bmiHeader.biHeight) - StartScan);
507  if (ScanLines == 0)
508  {
509  DPRINT1("ScanLines == 0\n");
510  ret = 0;
511  goto Exit;
512  }
513 
514  pDC = DC_LockDc(hDC);
515  if (!pDC)
516  {
518  ret = 0;
519  goto Exit;
520  }
521 
522  if (pDC->dctype == DC_TYPE_INFO)
523  {
524  ret = 0;
525  goto Exit;
526  }
527 
528  rcDest.left = XDest;
529  rcDest.top = YDest;
530  if (bTransformCoordinates)
531  {
532  IntLPtoDP(pDC, (LPPOINT)&rcDest, 2);
533  }
534  rcDest.left += pDC->ptlDCOrig.x;
535  rcDest.top += pDC->ptlDCOrig.y;
536  rcDest.right = rcDest.left + Width;
537  rcDest.bottom = rcDest.top + Height;
538  rcDest.top += StartScan;
539 
540  if (pDC->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
541  {
542  IntUpdateBoundsRect(pDC, &rcDest);
543  }
544 
545  ptSource.x = XSrc;
546  ptSource.y = YSrc;
547 
548  SourceSize.cx = bmi->bmiHeader.biWidth;
549  SourceSize.cy = ScanLines;
550 
551  //DIBWidth = WIDTH_BYTES_ALIGN32(SourceSize.cx, bmi->bmiHeader.biBitCount);
552 
553  hSourceBitmap = GreCreateBitmapEx(bmi->bmiHeader.biWidth,
554  ScanLines,
555  0,
556  BitmapFormat(bmi->bmiHeader.biBitCount,
557  bmi->bmiHeader.biCompression),
558  bmi->bmiHeader.biHeight < 0 ? BMF_TOPDOWN : 0,
559  bmi->bmiHeader.biSizeImage,
560  Bits,
561  0);
562 
563  if (!hSourceBitmap)
564  {
566  ret = 0;
567  goto Exit;
568  }
569 
570  pSourceSurf = EngLockSurface((HSURF)hSourceBitmap);
571  if (!pSourceSurf)
572  {
573  ret = 0;
574  goto Exit;
575  }
576 
577  /* HACK: If this is a RLE bitmap, only the relevant pixels must be set. */
578  if ((bmi->bmiHeader.biCompression == BI_RLE8) || (bmi->bmiHeader.biCompression == BI_RLE4))
579  {
580  hMaskBitmap = IntGdiCreateMaskFromRLE(bmi->bmiHeader.biWidth,
581  ScanLines,
582  bmi->bmiHeader.biCompression,
583  Bits,
584  cjMaxBits);
585  if (!hMaskBitmap)
586  {
588  ret = 0;
589  goto Exit;
590  }
591  pMaskSurf = EngLockSurface((HSURF)hMaskBitmap);
592  if (!pMaskSurf)
593  {
594  ret = 0;
595  goto Exit;
596  }
597  }
598 
599  /* Create a palette for the DIB */
600  ppalDIB = CreateDIBPalette(bmi, pDC, ColorUse);
601  if (!ppalDIB)
602  {
604  ret = 0;
605  goto Exit;
606  }
607 
608  /* This is actually a blit */
609  DC_vPrepareDCsForBlit(pDC, &rcDest, NULL, NULL);
610  pSurf = pDC->dclevel.pSurface;
611  if (!pSurf)
612  {
613  DC_vFinishBlit(pDC, NULL);
614  ret = ScanLines;
615  goto Exit;
616  }
617 
618  ASSERT(pSurf->ppal);
619 
620  /* Initialize EXLATEOBJ */
621  EXLATEOBJ_vInitialize(&exlo,
622  ppalDIB,
623  pSurf->ppal,
624  RGB(0xff, 0xff, 0xff),
625  pDC->pdcattr->crBackgroundClr,
626  pDC->pdcattr->crForegroundClr);
627 
628  pDestSurf = &pSurf->SurfObj;
629 
630  /* Copy the bits */
631  DPRINT("BitsToDev with dstsurf=(%d|%d) (%d|%d), src=(%d|%d) w=%d h=%d\n",
632  rcDest.left, rcDest.top, rcDest.right, rcDest.bottom,
633  ptSource.x, ptSource.y, SourceSize.cx, SourceSize.cy);
634  bResult = IntEngBitBlt(pDestSurf,
635  pSourceSurf,
636  pMaskSurf,
637  (CLIPOBJ *)&pDC->co,
638  &exlo.xlo,
639  &rcDest,
640  &ptSource,
641  pMaskSurf ? &ptSource : NULL,
642  NULL,
643  NULL,
645 
646  /* Cleanup EXLATEOBJ */
647  EXLATEOBJ_vCleanup(&exlo);
648 
649  /* We're done */
650  DC_vFinishBlit(pDC, NULL);
651 
652  ret = bResult ? ScanLines : 0;
653 
654 Exit:
655 
656  if (ppalDIB) PALETTE_ShareUnlockPalette(ppalDIB);
657  if (pSourceSurf) EngUnlockSurface(pSourceSurf);
658  if (hSourceBitmap) EngDeleteSurface((HSURF)hSourceBitmap);
659  if (pMaskSurf) EngUnlockSurface(pMaskSurf);
660  if (hMaskBitmap) EngDeleteSurface((HSURF)hMaskBitmap);
661  if (pDC) DC_UnlockDc(pDC);
662  ExFreePoolWithTag(pbmiSafe, 'pmTG');
663 
664  return ret;
665 }
666 
667 
668 /* Converts a device-dependent bitmap to a DIB */
669 INT
670 APIENTRY
672  HDC hDC,
674  UINT StartScan,
675  UINT ScanLines,
676  LPBYTE Bits,
678  UINT Usage,
679  UINT MaxBits,
680  UINT MaxInfo)
681 {
682  BITMAPCOREINFO* pbmci = NULL;
683  PSURFACE psurf = NULL;
684  PDC pDC;
685  LONG width, height;
686  WORD planes, bpp;
687  DWORD compr, size ;
688  USHORT i;
689  int bitmap_type;
690  RGBQUAD* rgbQuads;
691  VOID* colorPtr;
692 
693  DPRINT("Entered GreGetDIBitsInternal()\n");
694 
695  if ((Usage && Usage != DIB_PAL_COLORS) || !Info || !hBitmap)
696  return 0;
697 
698  pDC = DC_LockDc(hDC);
699  if (pDC == NULL || pDC->dctype == DC_TYPE_INFO)
700  {
701  ScanLines = 0;
702  goto done;
703  }
704 
705  /* Get a pointer to the source bitmap object */
707  if (psurf == NULL)
708  {
709  ScanLines = 0;
710  goto done;
711  }
712 
713  colorPtr = (LPBYTE)Info + Info->bmiHeader.biSize;
714  rgbQuads = colorPtr;
715 
716  bitmap_type = DIB_GetBitmapInfo(&Info->bmiHeader,
717  &width,
718  &height,
719  &planes,
720  &bpp,
721  &compr,
722  &size);
723  if(bitmap_type == -1)
724  {
725  DPRINT("Wrong bitmap format\n");
727  ScanLines = 0;
728  goto done;
729  }
730  else if(bitmap_type == 0)
731  {
732  /* We need a BITMAPINFO to create a DIB, but we have to fill
733  * the BITMAPCOREINFO we're provided */
734  pbmci = (BITMAPCOREINFO*)Info;
735  /* fill in the the bit count, so we can calculate the right ColorsSize during the conversion */
738  if(Info == NULL)
739  {
740  DPRINT1("Error, could not convert the BITMAPCOREINFO!\n");
741  ScanLines = 0;
742  goto done;
743  }
744  rgbQuads = Info->bmiColors;
745  }
746 
747  /* Validate input:
748  - negative width is always an invalid value
749  - non-null Bits and zero bpp is an invalid combination
750  - only check the rest of the input params if either bpp is non-zero or Bits are set */
751  if (width < 0 || (bpp == 0 && Bits))
752  {
753  ScanLines = 0;
754  goto done;
755  }
756 
757  if (Bits || bpp)
758  {
759  if ((height == 0 || width == 0) || (compr && compr != BI_BITFIELDS && compr != BI_RGB))
760  {
761  ScanLines = 0;
762  goto done;
763  }
764  }
765 
766  Info->bmiHeader.biClrUsed = 0;
767  Info->bmiHeader.biClrImportant = 0;
768 
769  /* Fill in the structure */
770  switch(bpp)
771  {
772  case 0: /* Only info */
773  Info->bmiHeader.biWidth = psurf->SurfObj.sizlBitmap.cx;
774  Info->bmiHeader.biHeight = (psurf->SurfObj.fjBitmap & BMF_TOPDOWN) ?
775  -psurf->SurfObj.sizlBitmap.cy :
776  psurf->SurfObj.sizlBitmap.cy;
777  Info->bmiHeader.biPlanes = 1;
778  Info->bmiHeader.biBitCount = BitsPerFormat(psurf->SurfObj.iBitmapFormat);
779  Info->bmiHeader.biSizeImage = DIB_GetDIBImageBytes( Info->bmiHeader.biWidth,
780  Info->bmiHeader.biHeight,
781  Info->bmiHeader.biBitCount);
782  Info->bmiHeader.biCompression = (Info->bmiHeader.biBitCount == 16 || Info->bmiHeader.biBitCount == 32) ?
784  Info->bmiHeader.biXPelsPerMeter = 0;
785  Info->bmiHeader.biYPelsPerMeter = 0;
786 
787  if (Info->bmiHeader.biBitCount <= 8 && Info->bmiHeader.biClrUsed == 0)
788  Info->bmiHeader.biClrUsed = 1 << Info->bmiHeader.biBitCount;
789 
790  ScanLines = 1;
791  goto done;
792 
793  case 1:
794  case 4:
795  case 8:
796  Info->bmiHeader.biClrUsed = 1 << bpp;
797 
798  /* If the bitmap is a DIB section and has the same format as what
799  * is requested, go ahead! */
800  if((psurf->hSecure) &&
801  (BitsPerFormat(psurf->SurfObj.iBitmapFormat) == bpp))
802  {
803  if(Usage == DIB_RGB_COLORS)
804  {
805  ULONG colors = min(psurf->ppal->NumColors, 256);
806  if(colors != 256) Info->bmiHeader.biClrUsed = colors;
807  for(i = 0; i < colors; i++)
808  {
809  rgbQuads[i].rgbRed = psurf->ppal->IndexedColors[i].peRed;
810  rgbQuads[i].rgbGreen = psurf->ppal->IndexedColors[i].peGreen;
811  rgbQuads[i].rgbBlue = psurf->ppal->IndexedColors[i].peBlue;
812  rgbQuads[i].rgbReserved = 0;
813  }
814  }
815  else
816  {
817  for(i = 0; i < 256; i++)
818  ((WORD*)rgbQuads)[i] = i;
819  }
820  }
821  else
822  {
823  if(Usage == DIB_PAL_COLORS)
824  {
825  for(i = 0; i < 256; i++)
826  {
827  ((WORD*)rgbQuads)[i] = i;
828  }
829  }
830  else if(bpp > 1 && bpp == BitsPerFormat(psurf->SurfObj.iBitmapFormat))
831  {
832  /* For color DDBs in native depth (mono DDBs always have
833  a black/white palette):
834  Generate the color map from the selected palette */
835  PPALETTE pDcPal = PALETTE_ShareLockPalette(pDC->dclevel.hpal);
836  if(!pDcPal)
837  {
838  ScanLines = 0 ;
839  goto done ;
840  }
841  for (i = 0; i < pDcPal->NumColors; i++)
842  {
843  rgbQuads[i].rgbRed = pDcPal->IndexedColors[i].peRed;
844  rgbQuads[i].rgbGreen = pDcPal->IndexedColors[i].peGreen;
845  rgbQuads[i].rgbBlue = pDcPal->IndexedColors[i].peBlue;
846  rgbQuads[i].rgbReserved = 0;
847  }
849  }
850  else
851  {
852  switch (bpp)
853  {
854  case 1:
855  rgbQuads[0].rgbRed = rgbQuads[0].rgbGreen = rgbQuads[0].rgbBlue = 0;
856  rgbQuads[0].rgbReserved = 0;
857  rgbQuads[1].rgbRed = rgbQuads[1].rgbGreen = rgbQuads[1].rgbBlue = 0xff;
858  rgbQuads[1].rgbReserved = 0;
859  break;
860 
861  case 4:
862  /* The EGA palette is the first and last 8 colours of the default palette
863  with the innermost pair swapped */
864  RtlCopyMemory(rgbQuads, DefLogPaletteQuads, 7 * sizeof(RGBQUAD));
865  RtlCopyMemory(rgbQuads + 7, DefLogPaletteQuads + 12, 1 * sizeof(RGBQUAD));
866  RtlCopyMemory(rgbQuads + 8, DefLogPaletteQuads + 7, 1 * sizeof(RGBQUAD));
867  RtlCopyMemory(rgbQuads + 9, DefLogPaletteQuads + 13, 7 * sizeof(RGBQUAD));
868  break;
869 
870  case 8:
871  {
872  INT i;
873 
874  memcpy(rgbQuads, DefLogPaletteQuads, 10 * sizeof(RGBQUAD));
875  memcpy(rgbQuads + 246, DefLogPaletteQuads + 10, 10 * sizeof(RGBQUAD));
876 
877  for (i = 10; i < 246; i++)
878  {
879  rgbQuads[i].rgbRed = (i & 0x07) << 5;
880  rgbQuads[i].rgbGreen = (i & 0x38) << 2;
881  rgbQuads[i].rgbBlue = i & 0xc0;
882  rgbQuads[i].rgbReserved = 0;
883  }
884  }
885  }
886  }
887  }
888  break;
889 
890  case 15:
891  if (Info->bmiHeader.biCompression == BI_BITFIELDS)
892  {
893  ((PDWORD)Info->bmiColors)[0] = 0x7c00;
894  ((PDWORD)Info->bmiColors)[1] = 0x03e0;
895  ((PDWORD)Info->bmiColors)[2] = 0x001f;
896  }
897  break;
898 
899  case 16:
900  if (Info->bmiHeader.biCompression == BI_BITFIELDS)
901  {
902  if (psurf->hSecure)
903  {
904  ((PDWORD)Info->bmiColors)[0] = psurf->ppal->RedMask;
905  ((PDWORD)Info->bmiColors)[1] = psurf->ppal->GreenMask;
906  ((PDWORD)Info->bmiColors)[2] = psurf->ppal->BlueMask;
907  }
908  else
909  {
910  ((PDWORD)Info->bmiColors)[0] = 0xf800;
911  ((PDWORD)Info->bmiColors)[1] = 0x07e0;
912  ((PDWORD)Info->bmiColors)[2] = 0x001f;
913  }
914  }
915  break;
916 
917  case 24:
918  case 32:
919  if (Info->bmiHeader.biCompression == BI_BITFIELDS)
920  {
921  if (psurf->hSecure)
922  {
923  ((PDWORD)Info->bmiColors)[0] = psurf->ppal->RedMask;
924  ((PDWORD)Info->bmiColors)[1] = psurf->ppal->GreenMask;
925  ((PDWORD)Info->bmiColors)[2] = psurf->ppal->BlueMask;
926  }
927  else
928  {
929  ((PDWORD)Info->bmiColors)[0] = 0xff0000;
930  ((PDWORD)Info->bmiColors)[1] = 0x00ff00;
931  ((PDWORD)Info->bmiColors)[2] = 0x0000ff;
932  }
933  }
934  break;
935 
936  default:
937  ScanLines = 0;
938  goto done;
939  }
940 
941  Info->bmiHeader.biSizeImage = DIB_GetDIBImageBytes(width, height, bpp);
942  Info->bmiHeader.biPlanes = 1;
943 
944  if(Bits && ScanLines)
945  {
946  /* Create a DIBSECTION, blt it, profit */
947  PVOID pDIBits ;
948  HBITMAP hBmpDest;
949  PSURFACE psurfDest;
950  EXLATEOBJ exlo;
951  RECT rcDest;
952  POINTL srcPoint;
953  BOOL ret ;
954  int newLines = -1;
955 
956  if (StartScan >= abs(Info->bmiHeader.biHeight))
957  {
958  ScanLines = 1;
959  goto done;
960  }
961  else
962  {
963  ScanLines = min(ScanLines, abs(Info->bmiHeader.biHeight) - StartScan);
964  }
965 
966  if (abs(Info->bmiHeader.biHeight) < psurf->SurfObj.sizlBitmap.cy)
967  {
968  StartScan += psurf->SurfObj.sizlBitmap.cy - abs(Info->bmiHeader.biHeight);
969  }
970  /* Fixup values */
971  Info->bmiHeader.biHeight = (height < 0) ?
972  -(LONG)ScanLines : ScanLines;
973  /* Create the DIB */
974  hBmpDest = DIB_CreateDIBSection(pDC, Info, Usage, &pDIBits, NULL, 0, 0);
975  /* Restore them */
976  Info->bmiHeader.biHeight = height;
977 
978  if(!hBmpDest)
979  {
980  DPRINT1("Unable to create a DIB Section!\n");
982  ScanLines = 0;
983  goto done ;
984  }
985 
986  psurfDest = SURFACE_ShareLockSurface(hBmpDest);
987 
988  RECTL_vSetRect(&rcDest, 0, 0, Info->bmiHeader.biWidth, ScanLines);
989  Info->bmiHeader.biWidth = width;
990  srcPoint.x = 0;
991 
992  if (abs(Info->bmiHeader.biHeight) <= psurf->SurfObj.sizlBitmap.cy)
993  {
994  srcPoint.y = psurf->SurfObj.sizlBitmap.cy - StartScan - ScanLines;
995  }
996  else
997  {
998  /* Determine the actual number of lines copied from the */
999  /* original bitmap. It might be different from ScanLines. */
1000  newLines = abs(Info->bmiHeader.biHeight) - psurf->SurfObj.sizlBitmap.cy;
1001  newLines = min((int)(StartScan + ScanLines - newLines), psurf->SurfObj.sizlBitmap.cy);
1002  if (newLines > 0)
1003  {
1004  srcPoint.y = psurf->SurfObj.sizlBitmap.cy - newLines;
1005  if (StartScan > psurf->SurfObj.sizlBitmap.cy)
1006  {
1007  newLines -= (StartScan - psurf->SurfObj.sizlBitmap.cy);
1008  }
1009  }
1010  else
1011  {
1012  newLines = 0;
1013  srcPoint.y = psurf->SurfObj.sizlBitmap.cy;
1014  }
1015  }
1016 
1017  EXLATEOBJ_vInitialize(&exlo, psurf->ppal, psurfDest->ppal, 0xffffff, 0xffffff, 0);
1018 
1019  ret = IntEngCopyBits(&psurfDest->SurfObj,
1020  &psurf->SurfObj,
1021  NULL,
1022  &exlo.xlo,
1023  &rcDest,
1024  &srcPoint);
1025 
1026  SURFACE_ShareUnlockSurface(psurfDest);
1027 
1028  if(!ret)
1029  ScanLines = 0;
1030  else
1031  {
1032  RtlCopyMemory(Bits, pDIBits, DIB_GetDIBImageBytes (width, ScanLines, bpp));
1033  }
1034  /* Update if line count has changed */
1035  if (newLines != -1)
1036  {
1037  ScanLines = (UINT)newLines;
1038  }
1039  GreDeleteObject(hBmpDest);
1040  EXLATEOBJ_vCleanup(&exlo);
1041  }
1042  else
1043  {
1044  /* Signals success and not the actual number of scan lines*/
1045  ScanLines = 1;
1046  }
1047 
1048 done:
1049 
1050  if (pbmci)
1052 
1053  if (psurf)
1055 
1056  if (pDC)
1057  DC_UnlockDc(pDC);
1058 
1059  return ScanLines;
1060 }
1061 
1062 _Success_(return!=0)
1064 INT
1065 APIENTRY
1066 NtGdiGetDIBitsInternal(
1067  _In_ HDC hdc,
1068  _In_ HBITMAP hbm,
1070  _In_ UINT cScans,
1073  _In_ UINT iUsage,
1076 {
1077  PBITMAPINFO pbmiSafe;
1078  HANDLE hSecure = NULL;
1079  INT iResult = 0;
1080  UINT cjAlloc;
1081 
1082  /* Check for bad iUsage */
1083  if (iUsage > 2) return 0;
1084 
1085  /* Check if the size of the bitmap info is large enough */
1086  if (cjMaxInfo < sizeof(BITMAPCOREHEADER))
1087  {
1088  return 0;
1089  }
1090 
1091  /* Use maximum size */
1092  cjMaxInfo = min(cjMaxInfo, sizeof(BITMAPV5HEADER) + 256 * sizeof(RGBQUAD));
1093 
1094  // HACK: the underlying code sucks and doesn't care for the size, so we
1095  // give it the maximum ever needed
1096  cjAlloc = sizeof(BITMAPV5HEADER) + 256 * sizeof(RGBQUAD);
1097 
1098  /* Allocate a buffer the bitmapinfo */
1099  pbmiSafe = ExAllocatePoolWithTag(PagedPool, cjAlloc, 'imBG');
1100  if (!pbmiSafe)
1101  {
1102  /* Fail */
1103  return 0;
1104  }
1105 
1106  /* Use SEH */
1107  _SEH2_TRY
1108  {
1109  /* Probe and copy the BITMAPINFO */
1111  RtlCopyMemory(pbmiSafe, pbmi, cjMaxInfo);
1112  }
1114  {
1115  _SEH2_YIELD(goto cleanup;)
1116  }
1117  _SEH2_END;
1118 
1119  /* Check if the header size is large enough */
1120  if ((pbmiSafe->bmiHeader.biSize < sizeof(BITMAPCOREHEADER)) ||
1121  (pbmiSafe->bmiHeader.biSize > cjMaxInfo))
1122  {
1123  goto cleanup;
1124  }
1125 
1126  /* Check if the caller provided bitmap bits */
1127  if (pjBits)
1128  {
1129  /* Secure the user mode memory */
1130  hSecure = EngSecureMem(pjBits, cjMaxBits);
1131  if (!hSecure)
1132  {
1133  goto cleanup;
1134  }
1135  }
1136 
1137  /* Now call the internal function */
1138  iResult = GreGetDIBitsInternal(hdc,
1139  hbm,
1140  iStartScan,
1141  cScans,
1142  pjBits,
1143  pbmiSafe,
1144  iUsage,
1145  cjMaxBits,
1146  cjMaxInfo);
1147 
1148  /* Check for success */
1149  if (iResult)
1150  {
1151  /* Use SEH to copy back to user mode */
1152  _SEH2_TRY
1153  {
1154  /* Copy the data back */
1157  RtlCopyMemory(pbmi, pbmiSafe, cjMaxInfo);
1158  }
1160  {
1161  /* Ignore */
1162  (VOID)0;
1163  }
1164  _SEH2_END;
1165  }
1166 
1167 cleanup:
1168  if (hSecure) EngUnsecureMem(hSecure);
1169  ExFreePoolWithTag(pbmiSafe, 'imBG');
1170 
1171  return iResult;
1172 }
1173 
1174 
1175 W32KAPI
1176 INT
1177 APIENTRY
1179  IN HDC hdc,
1180  IN INT xDst,
1181  IN INT yDst,
1182  IN INT cxDst,
1183  IN INT cyDst,
1184  IN INT xSrc,
1185  IN INT ySrc,
1186  IN INT cxSrc,
1187  IN INT cySrc,
1188  IN OPTIONAL LPBYTE pjInit,
1190  IN DWORD dwUsage,
1191  IN DWORD dwRop, // MS ntgdi.h says dwRop4(?)
1192  IN UINT cjMaxInfo,
1193  IN UINT cjMaxBits,
1194  IN HANDLE hcmXform)
1195 {
1196  BOOL bResult = FALSE;
1197  SIZEL sizel;
1198  RECTL rcSrc, rcDst;
1199  PDC pdc;
1200  HBITMAP hbmTmp = 0;
1201  PSURFACE psurfTmp = 0, psurfDst = 0;
1202  PPALETTE ppalDIB = 0;
1203  EXLATEOBJ exlo;
1204  PVOID pvBits;
1205 
1206  if (!(pdc = DC_LockDc(hdc)))
1207  {
1209  return 0;
1210  }
1211 
1212  /* Check for info / mem DC without surface */
1213  if (!pdc->dclevel.pSurface)
1214  {
1215  DC_UnlockDc(pdc);
1216  // CHECKME
1217  return TRUE;
1218  }
1219 
1220  /* Transform dest size */
1221  sizel.cx = cxDst;
1222  sizel.cy = cyDst;
1223  IntLPtoDP(pdc, (POINTL*)&sizel, 1);
1224  DC_UnlockDc(pdc);
1225 
1226  /* Check if we can use NtGdiSetDIBitsToDeviceInternal */
1227  if ((sizel.cx == cxSrc) && (sizel.cy == cySrc) && (dwRop == SRCCOPY))
1228  {
1229  /* Yes, we can! */
1231  xDst,
1232  yDst,
1233  cxDst,
1234  cyDst,
1235  xSrc,
1236  ySrc,
1237  0,
1238  cySrc,
1239  pjInit,
1240  pbmi,
1241  dwUsage,
1242  cjMaxBits,
1243  cjMaxInfo,
1244  TRUE,
1245  hcmXform);
1246  }
1247 
1248  if (pjInit && (cjMaxBits > 0))
1249  {
1250  pvBits = ExAllocatePoolWithTag(PagedPool, cjMaxBits, 'pmeT');
1251  if (!pvBits)
1252  {
1253  return 0;
1254  }
1255 
1256  _SEH2_TRY
1257  {
1258  ProbeForRead(pjInit, cjMaxBits, 1);
1259  RtlCopyMemory(pvBits, pjInit, cjMaxBits);
1260  }
1262  {
1263  ExFreePoolWithTag(pvBits, 'pmeT');
1264  _SEH2_YIELD(return 0);
1265  }
1266  _SEH2_END
1267  }
1268  else
1269  {
1270  pvBits = NULL;
1271  }
1272 
1273  /* FIXME: Locking twice is cheesy, coord tranlation in UM will fix it */
1274  if (!(pdc = DC_LockDc(hdc)))
1275  {
1276  DPRINT1("Could not lock dc\n");
1278  goto cleanup;
1279  }
1280 
1281  /* Calculate source and destination rect */
1282  rcSrc.left = xSrc;
1283  rcSrc.top = ySrc;
1284  rcSrc.right = xSrc + abs(cxSrc);
1285  rcSrc.bottom = ySrc + abs(cySrc);
1286  rcDst.left = xDst;
1287  rcDst.top = yDst;
1288  rcDst.right = rcDst.left + cxDst;
1289  rcDst.bottom = rcDst.top + cyDst;
1290  IntLPtoDP(pdc, (POINTL*)&rcDst, 2);
1291  RECTL_vOffsetRect(&rcDst, pdc->ptlDCOrig.x, pdc->ptlDCOrig.y);
1292 
1293  if (pdc->fs & (DC_ACCUM_APP|DC_ACCUM_WMGR))
1294  {
1295  IntUpdateBoundsRect(pdc, &rcDst);
1296  }
1297 
1300  0,
1303  pbmi->bmiHeader.biHeight < 0 ? BMF_TOPDOWN : 0,
1304  cjMaxBits,
1305  pvBits,
1306  0);
1307 
1308  if (!hbmTmp)
1309  {
1310  bResult = FALSE;
1311  goto cleanup;
1312  }
1313 
1314  psurfTmp = SURFACE_ShareLockSurface(hbmTmp);
1315  if (!psurfTmp)
1316  {
1317  bResult = FALSE;
1318  goto cleanup;
1319  }
1320 
1321  /* Create a palette for the DIB */
1322  ppalDIB = CreateDIBPalette(pbmi, pdc, dwUsage);
1323  if (!ppalDIB)
1324  {
1325  bResult = FALSE;
1326  goto cleanup;
1327  }
1328 
1329  /* Prepare DC for blit */
1330  DC_vPrepareDCsForBlit(pdc, &rcDst, NULL, NULL);
1331 
1332  psurfDst = pdc->dclevel.pSurface;
1333 
1334  /* Initialize XLATEOBJ */
1335  EXLATEOBJ_vInitialize(&exlo,
1336  ppalDIB,
1337  psurfDst->ppal,
1338  RGB(0xff, 0xff, 0xff),
1339  pdc->pdcattr->crBackgroundClr,
1340  pdc->pdcattr->crForegroundClr);
1341 
1342  /* Perform the stretch operation */
1343  bResult = IntEngStretchBlt(&psurfDst->SurfObj,
1344  &psurfTmp->SurfObj,
1345  NULL,
1346  (CLIPOBJ *)&pdc->co,
1347  &exlo.xlo,
1348  &pdc->dclevel.ca,
1349  &rcDst,
1350  &rcSrc,
1351  NULL,
1352  &pdc->eboFill.BrushObject,
1353  NULL,
1354  WIN32_ROP3_TO_ENG_ROP4(dwRop));
1355 
1356  /* Cleanup */
1357  DC_vFinishBlit(pdc, NULL);
1358  EXLATEOBJ_vCleanup(&exlo);
1359 cleanup:
1360  if (ppalDIB) PALETTE_ShareUnlockPalette(ppalDIB);
1361  if (psurfTmp) SURFACE_ShareUnlockSurface(psurfTmp);
1362  if (hbmTmp) GreDeleteObject(hbmTmp);
1363  if (pdc) DC_UnlockDc(pdc);
1364  if (pvBits) ExFreePoolWithTag(pvBits, 'pmeT');
1365 
1366  return bResult;
1367 }
1368 
1369 
1370 HBITMAP
1371 FASTCALL
1373  PDC Dc,
1374  INT width,
1375  INT height,
1376  UINT planes,
1377  UINT bpp,
1379  DWORD init,
1380  LPBYTE bits,
1381  ULONG cjMaxBits,
1382  PBITMAPINFO data,
1383  DWORD coloruse)
1384 {
1385  HBITMAP handle;
1386  BOOL fColor;
1387  ULONG BmpFormat = 0;
1388 
1389  if (planes && bpp)
1390  BmpFormat = BitmapFormat(planes * bpp, compression);
1391 
1392  // Check if we should create a monochrome or color bitmap. We create a monochrome bitmap only if it has exactly 2
1393  // colors, which are black followed by white, nothing else. In all other cases, we create a color bitmap.
1394 
1395  if (BmpFormat != BMF_1BPP) fColor = TRUE;
1396  else if ((coloruse > DIB_RGB_COLORS) || ((init & CBM_INIT) == 0) || !data) fColor = FALSE;
1397  else
1398  {
1399  const RGBQUAD *rgb = (RGBQUAD*)((PBYTE)data + data->bmiHeader.biSize);
1400  DWORD col = RGB(rgb->rgbRed, rgb->rgbGreen, rgb->rgbBlue);
1401 
1402  // Check if the first color of the colormap is black
1403  if (col == RGB(0, 0, 0))
1404  {
1405  rgb++;
1406  col = RGB(rgb->rgbRed, rgb->rgbGreen, rgb->rgbBlue);
1407 
1408  // If the second color is white, create a monochrome bitmap
1409  fColor = (col != RGB(0xff,0xff,0xff));
1410  }
1411  else fColor = TRUE;
1412  }
1413 
1414  // Now create the bitmap
1415  if (fColor)
1416  {
1417  if (init & CBM_CREATDIB)
1418  {
1419  PSURFACE Surface;
1420  PPALETTE Palette;
1421 
1422  /* Undocumented flag which creates a DDB of the format specified by the bitmap info. */
1423  handle = IntCreateCompatibleBitmap(Dc, width, height, planes, bpp);
1424  if (!handle)
1425  {
1426  DPRINT1("IntCreateCompatibleBitmap() failed!\n");
1427  return NULL;
1428  }
1429 
1430  /* The palette must also match the given data */
1431  Surface = SURFACE_ShareLockSurface(handle);
1432  ASSERT(Surface);
1433  Palette = CreateDIBPalette(data, Dc, coloruse);
1434  ASSERT(Palette);
1435  SURFACE_vSetPalette(Surface, Palette);
1436 
1437  PALETTE_ShareUnlockPalette(Palette);
1438  SURFACE_ShareUnlockSurface(Surface);
1439  }
1440  else
1441  {
1442  /* Create a regular compatible bitmap, in the same format as the device */
1444  }
1445  }
1446  else
1447  {
1449  abs(height),
1450  1,
1451  1,
1452  NULL);
1453  }
1454 
1455  if (height < 0)
1456  height = -height;
1457 
1458  if ((NULL != handle) && (CBM_INIT & init))
1459  {
1460  IntSetDIBits(Dc, handle, 0, height, bits, cjMaxBits, data, coloruse);
1461  }
1462 
1463  return handle;
1464 }
1465 
1466 // The CreateDIBitmap function creates a device-dependent bitmap (DDB) from a DIB and, optionally, sets the bitmap bits
1467 // The DDB that is created will be whatever bit depth your reference DC is
1468 HBITMAP
1469 APIENTRY
1471  IN HDC hDc,
1472  IN INT cx,
1473  IN INT cy,
1474  IN DWORD fInit,
1475  IN OPTIONAL LPBYTE pjInit,
1477  IN DWORD iUsage,
1478  IN UINT cjMaxInitInfo,
1479  IN UINT cjMaxBits,
1480  IN FLONG fl,
1481  IN HANDLE hcmXform)
1482 {
1484  PBYTE safeBits = NULL;
1485  HBITMAP hbmResult = NULL;
1486 
1487  if (pjInit == NULL)
1488  {
1489  fInit &= ~CBM_INIT;
1490  }
1491 
1492  if(pjInit && (fInit & CBM_INIT))
1493  {
1494  if (cjMaxBits == 0) return NULL;
1496  if(!safeBits)
1497  {
1498  DPRINT1("Failed to allocate %lu bytes\n", cjMaxBits);
1500  return NULL;
1501  }
1502  }
1503 
1504  _SEH2_TRY
1505  {
1506  if(pbmi) ProbeForRead(pbmi, cjMaxInitInfo, 1);
1507  if(pjInit && (fInit & CBM_INIT))
1508  {
1509  ProbeForRead(pjInit, cjMaxBits, 1);
1510  RtlCopyMemory(safeBits, pjInit, cjMaxBits);
1511  }
1512  }
1514  {
1516  }
1517  _SEH2_END
1518 
1519  if(!NT_SUCCESS(Status))
1520  {
1521  DPRINT1("Got an exception! pjInit = %p\n", pjInit);
1523  goto cleanup;
1524  }
1525 
1526  hbmResult = GreCreateDIBitmapInternal(hDc,
1527  cx,
1528  cy,
1529  fInit,
1530  safeBits,
1531  pbmi,
1532  iUsage,
1533  fl,
1534  cjMaxBits,
1535  hcmXform);
1536 
1537 cleanup:
1538  if (safeBits) ExFreePoolWithTag(safeBits, TAG_DIB);
1539  return hbmResult;
1540 }
1541 
1542 HBITMAP
1543 NTAPI
1545  IN HDC hDc,
1546  IN INT cx,
1547  IN INT cy,
1548  IN DWORD fInit,
1549  IN OPTIONAL LPBYTE pjInit,
1551  IN DWORD iUsage,
1552  IN FLONG fl,
1553  IN UINT cjMaxBits,
1554  IN HANDLE hcmXform)
1555 {
1556  PDC Dc;
1557  HBITMAP Bmp;
1558  USHORT bpp, planes;
1560  HDC hdcDest;
1561 
1562  if (!hDc) /* 1bpp monochrome bitmap */
1563  {
1564  // Should use System Bitmap DC hSystemBM, with CreateCompatibleDC for this.
1565  hdcDest = NtGdiCreateCompatibleDC(0);
1566  if(!hdcDest)
1567  {
1568  DPRINT1("NtGdiCreateCompatibleDC failed\n");
1569  return NULL;
1570  }
1571  }
1572  else
1573  {
1574  hdcDest = hDc;
1575  }
1576 
1577  Dc = DC_LockDc(hdcDest);
1578  if (!Dc)
1579  {
1580  DPRINT1("Failed to lock hdcDest %p\n", hdcDest);
1582  return NULL;
1583  }
1584  /* It's OK to set bpp=0 here, as IntCreateDIBitmap will create a compatible Bitmap
1585  * if bpp != 1 and ignore the real value that was passed */
1586  if (pbmi)
1587  {
1588  if (pbmi->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
1589  {
1590  BITMAPCOREHEADER* CoreHeader = (BITMAPCOREHEADER*)&pbmi->bmiHeader;
1591  bpp = CoreHeader->bcBitCount;
1592  planes = CoreHeader->bcPlanes ? CoreHeader->bcPlanes : 1;
1593  compression = BI_RGB;
1594  }
1595  else
1596  {
1598  planes = pbmi->bmiHeader.biPlanes ? pbmi->bmiHeader.biPlanes : 1;
1600  }
1601  }
1602  else
1603  {
1604  bpp = 0;
1605  planes = 0;
1606  compression = 0;
1607  }
1608  Bmp = IntCreateDIBitmap(Dc, cx, cy, planes, bpp, compression, fInit, pjInit, cjMaxBits, pbmi, iUsage);
1609  DC_UnlockDc(Dc);
1610 
1611  if(!hDc)
1612  {
1613  NtGdiDeleteObjectApp(hdcDest);
1614  }
1615  return Bmp;
1616 }
1617 
1618 HBITMAP
1619 NTAPI
1621  _In_reads_(cjPackedDIB )PVOID pvPackedDIB,
1622  _In_ UINT cjPackedDIB,
1623  _In_ ULONG uUsage)
1624 {
1625  PBITMAPINFO pbmi;
1626  PBYTE pjBits;
1627  UINT cjInfo, cjBits;
1628  HBITMAP hbm;
1629 
1630  /* We only support BITMAPINFOHEADER, make sure the size is ok */
1631  if (cjPackedDIB < sizeof(BITMAPINFOHEADER))
1632  {
1633  return NULL;
1634  }
1635 
1636  /* The packed DIB starts with the BITMAPINFOHEADER */
1637  pbmi = pvPackedDIB;
1638 
1639  if (cjPackedDIB < pbmi->bmiHeader.biSize)
1640  {
1641  return NULL;
1642  }
1643 
1644  /* Calculate the info size and make sure the packed DIB is large enough */
1645  cjInfo = DIB_BitmapInfoSize(pbmi, uUsage);
1646  if (cjPackedDIB <= cjInfo)
1647  {
1648  return NULL;
1649  }
1650 
1651  /* The bitmap bits start after the header */
1652  pjBits = (PBYTE)pvPackedDIB + cjInfo;
1653  cjBits = cjPackedDIB - cjInfo;
1654 
1659  pjBits,
1660  pbmi,
1661  uUsage,
1662  0,
1663  cjBits,
1664  NULL);
1665 
1666  return hbm;
1667 }
1668 
1669 HBITMAP
1670 APIENTRY
1672  IN HDC hDC,
1674  IN DWORD dwOffset,
1675  IN BITMAPINFO* bmi,
1676  IN DWORD Usage,
1677  IN UINT cjHeader,
1678  IN FLONG fl,
1679  IN ULONG_PTR dwColorSpace,
1680  OUT PVOID *Bits)
1681 {
1682  HBITMAP hbitmap = 0;
1683  DC *dc;
1684  BOOL bDesktopDC = FALSE;
1686 
1687  if (!bmi) return hbitmap; // Make sure.
1688 
1689  _SEH2_TRY
1690  {
1691  ProbeForRead(&bmi->bmiHeader.biSize, sizeof(DWORD), 1);
1692  ProbeForRead(bmi, bmi->bmiHeader.biSize, 1);
1693  ProbeForRead(bmi, DIB_BitmapInfoSize(bmi, (WORD)Usage), 1);
1694  }
1696  {
1698  }
1699  _SEH2_END
1700 
1701  if(!NT_SUCCESS(Status))
1702  {
1704  return NULL;
1705  }
1706 
1707  // If the reference hdc is null, take the desktop dc
1708  if (hDC == 0)
1709  {
1711  bDesktopDC = TRUE;
1712  }
1713 
1714  if ((dc = DC_LockDc(hDC)))
1715  {
1717  bmi,
1718  Usage,
1719  Bits,
1720  hSection,
1721  dwOffset,
1722  0);
1723  DC_UnlockDc(dc);
1724  }
1725  else
1726  {
1728  }
1729 
1730  if (bDesktopDC)
1732 
1733  return hbitmap;
1734 }
1735 
1736 HBITMAP
1737 APIENTRY
1739  PDC dc,
1740  CONST BITMAPINFO *bmi,
1741  UINT usage,
1742  LPVOID *bits,
1743  HANDLE section,
1744  DWORD offset,
1745  DWORD ovr_pitch)
1746 {
1747  HBITMAP res = 0;
1748  SURFACE *bmp = NULL;
1749  void *mapBits = NULL;
1750  PPALETTE ppalDIB = NULL;
1751 
1752  // Fill BITMAP32 structure with DIB data
1753  CONST BITMAPINFOHEADER *bi = &bmi->bmiHeader;
1754  INT effHeight;
1755  ULONG totalSize;
1756  BITMAP bm;
1757  //SIZEL Size;
1758  HANDLE hSecure;
1759 
1760  DPRINT("format (%ld,%ld), planes %u, bpp %u, size %lu, colors %lu (%s)\n",
1761  bi->biWidth, bi->biHeight, bi->biPlanes, bi->biBitCount,
1762  bi->biSizeImage, bi->biClrUsed, usage == DIB_PAL_COLORS? "PAL" : "RGB");
1763 
1764  /* CreateDIBSection should fail for compressed formats */
1765  if (bi->biCompression == BI_RLE4 || bi->biCompression == BI_RLE8)
1766  {
1767  DPRINT1("no compressed format allowed\n");
1768  return (HBITMAP)NULL;
1769  }
1770 
1771  effHeight = bi->biHeight >= 0 ? bi->biHeight : -bi->biHeight;
1772  bm.bmType = 0;
1773  bm.bmWidth = bi->biWidth;
1774  bm.bmHeight = effHeight;
1775  bm.bmWidthBytes = ovr_pitch ? ovr_pitch : WIDTH_BYTES_ALIGN32(bm.bmWidth, bi->biBitCount);
1776 
1777  bm.bmPlanes = bi->biPlanes;
1778  bm.bmBitsPixel = bi->biBitCount;
1779  bm.bmBits = NULL;
1780 
1781  // Get storage location for DIB bits. Only use biSizeImage if it's valid and
1782  // we're dealing with a compressed bitmap. Otherwise, use width * height.
1783  totalSize = (bi->biSizeImage && (bi->biCompression != BI_RGB) && (bi->biCompression != BI_BITFIELDS))
1784  ? bi->biSizeImage : (ULONG)(bm.bmWidthBytes * effHeight);
1785 
1786  if (section)
1787  {
1789  NTSTATUS Status;
1790  DWORD mapOffset;
1792  SIZE_T mapSize;
1793 
1795  &Sbi,
1796  sizeof Sbi,
1797  0);
1798  if (!NT_SUCCESS(Status))
1799  {
1800  DPRINT1("ZwQuerySystemInformation failed (0x%lx)\n", Status);
1801  return NULL;
1802  }
1803 
1804  mapOffset = offset - (offset % Sbi.AllocationGranularity);
1805  mapSize = totalSize + (offset - mapOffset);
1806 
1807  SectionOffset.LowPart = mapOffset;
1808  SectionOffset.HighPart = 0;
1809 
1810  Status = ZwMapViewOfSection(section,
1811  NtCurrentProcess(),
1812  &mapBits,
1813  0,
1814  0,
1815  &SectionOffset,
1816  &mapSize,
1817  ViewShare,
1818  0,
1819  PAGE_READWRITE);
1820  if (!NT_SUCCESS(Status))
1821  {
1822  DPRINT1("ZwMapViewOfSection failed (0x%lx)\n", Status);
1824  return NULL;
1825  }
1826 
1827  if (mapBits) bm.bmBits = (char *)mapBits + (offset - mapOffset);
1828  }
1829  else if (ovr_pitch && offset)
1830  bm.bmBits = UlongToPtr(offset);
1831  else
1832  {
1833  offset = 0;
1834  bm.bmBits = EngAllocUserMem(totalSize, 0);
1835  if(!bm.bmBits)
1836  {
1837  DPRINT1("Failed to allocate memory\n");
1838  goto cleanup;
1839  }
1840  }
1841 
1842 // hSecure = MmSecureVirtualMemory(bm.bmBits, totalSize, PAGE_READWRITE);
1843  hSecure = (HANDLE)0x1; // HACK OF UNIMPLEMENTED KERNEL STUFF !!!!
1844 
1845 
1846  // Create Device Dependent Bitmap and add DIB pointer
1847  //Size.cx = bm.bmWidth;
1848  //Size.cy = abs(bm.bmHeight);
1849  res = GreCreateBitmapEx(bm.bmWidth,
1850  abs(bm.bmHeight),
1851  bm.bmWidthBytes,
1852  BitmapFormat(bi->biBitCount * bi->biPlanes, bi->biCompression),
1854  ((bi->biHeight < 0) ? BMF_TOPDOWN : 0),
1855  totalSize,
1856  bm.bmBits,
1857  0);
1858  if (!res)
1859  {
1860  DPRINT1("GreCreateBitmapEx failed\n");
1862  goto cleanup;
1863  }
1864  bmp = SURFACE_ShareLockSurface(res); // HACK
1865  if (NULL == bmp)
1866  {
1867  DPRINT1("SURFACE_LockSurface failed\n");
1869  goto cleanup;
1870  }
1871 
1872  /* WINE NOTE: WINE makes use of a colormap, which is a color translation
1873  table between the DIB and the X physical device. Obviously,
1874  this is left out of the ReactOS implementation. Instead,
1875  we call NtGdiSetDIBColorTable. */
1876  bmp->hDIBSection = section;
1877  bmp->hSecure = hSecure;
1878  bmp->dwOffset = offset;
1879  bmp->flags = API_BITMAP;
1880  bmp->biClrImportant = bi->biClrImportant;
1881 
1882  /* Create a palette for the DIB */
1883  ppalDIB = CreateDIBPalette(bmi, dc, usage);
1884 
1885  // Clean up in case of errors
1886 cleanup:
1887  if (!res || !bmp || !bm.bmBits || !ppalDIB)
1888  {
1889  DPRINT("Got an error res=%p, bmp=%p, bm.bmBits=%p\n", res, bmp, bm.bmBits);
1890  if (bm.bmBits)
1891  {
1892  // MmUnsecureVirtualMemory(hSecure); // FIXME: Implement this!
1893  if (section)
1894  {
1895  ZwUnmapViewOfSection(NtCurrentProcess(), mapBits);
1896  bm.bmBits = NULL;
1897  }
1898  else if (!offset)
1899  EngFreeUserMem(bm.bmBits), bm.bmBits = NULL;
1900  }
1901 
1902  if (bmp)
1903  {
1905  bmp = NULL;
1906  }
1907 
1908  if (res)
1909  {
1911  res = 0;
1912  }
1913 
1914  if(ppalDIB)
1915  {
1916  PALETTE_ShareUnlockPalette(ppalDIB);
1917  }
1918  }
1919 
1920  if (bmp)
1921  {
1922  /* If we're here, everything went fine */
1923  SURFACE_vSetPalette(bmp, ppalDIB);
1924  PALETTE_ShareUnlockPalette(ppalDIB);
1926  }
1927 
1928  // Return BITMAP handle and storage location
1929  if (NULL != bm.bmBits && NULL != bits)
1930  {
1931  *bits = bm.bmBits;
1932  }
1933 
1934  return res;
1935 }
1936 
1937 /***********************************************************************
1938  * DIB_GetBitmapInfo
1939  *
1940  * Get the info from a bitmap header.
1941  * Return 0 for COREHEADER, 1 for INFOHEADER, -1 for error.
1942  */
1943 int
1944 FASTCALL
1946  LONG *height, WORD *planes, WORD *bpp, DWORD *compr, DWORD *size )
1947 {
1948  if (header->biSize == sizeof(BITMAPCOREHEADER))
1949  {
1950  const BITMAPCOREHEADER *core = (const BITMAPCOREHEADER *)header;
1951  *width = core->bcWidth;
1952  *height = core->bcHeight;
1953  *planes = core->bcPlanes;
1954  *bpp = core->bcBitCount;
1955  *compr = BI_RGB;
1956  *size = 0;
1957  return 0;
1958  }
1959  if (header->biSize >= sizeof(BITMAPINFOHEADER)) /* Assume BITMAPINFOHEADER */
1960  {
1961  *width = header->biWidth;
1962  *height = header->biHeight;
1963  *planes = header->biPlanes;
1964  *bpp = header->biBitCount;
1965  *compr = header->biCompression;
1966  *size = header->biSizeImage;
1967  return 1;
1968  }
1969  DPRINT1("(%u): unknown/wrong size for header\n", header->biSize );
1970  return -1;
1971 }
1972 
1973 /***********************************************************************
1974  * DIB_GetDIBImageBytes
1975  *
1976  * Return the number of bytes used to hold the image in a DIB bitmap.
1977  * 11/16/1999 (RJJ) lifted from wine
1978  */
1979 
1981 {
1982  return WIDTH_BYTES_ALIGN32(width, depth) * (height < 0 ? -height : height);
1983 }
1984 
1985 /***********************************************************************
1986  * DIB_BitmapInfoSize
1987  *
1988  * Return the size of the bitmap info structure including color table.
1989  * 11/16/1999 (RJJ) lifted from wine
1990  */
1991 
1993 {
1994  unsigned int colors, size, masks = 0;
1995  unsigned int colorsize;
1996 
1997  colorsize = (coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) :
1998  (coloruse == DIB_PAL_INDICES) ? 0 :
1999  sizeof(WORD);
2000 
2001  if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
2002  {
2003  const BITMAPCOREHEADER *core = (const BITMAPCOREHEADER *)info;
2004  colors = (core->bcBitCount <= 8) ? 1 << core->bcBitCount : 0;
2005  return sizeof(BITMAPCOREHEADER) + colors * colorsize;
2006  }
2007  else /* Assume BITMAPINFOHEADER */
2008  {
2009  colors = info->bmiHeader.biClrUsed;
2010  if (colors > 256) colors = 256;
2011  if (!colors && (info->bmiHeader.biBitCount <= 8))
2012  colors = 1 << info->bmiHeader.biBitCount;
2013  if (info->bmiHeader.biCompression == BI_BITFIELDS) masks = 3;
2014  size = max( info->bmiHeader.biSize, sizeof(BITMAPINFOHEADER) + masks * sizeof(DWORD) );
2015  return size + colors * colorsize;
2016  }
2017 }
2018 
2019 HPALETTE
2020 FASTCALL
2022 {
2023  PPALETTE ppalNew;
2024  ULONG nNumColors,i;
2025  USHORT *lpIndex;
2026  HPALETTE hpal;
2027 
2028  if (!(ppalDc->flFlags & PAL_INDEXED))
2029  {
2030  return NULL;
2031  }
2032 
2033  nNumColors = 1 << lpbmi->bmiHeader.biBitCount;
2034  if (lpbmi->bmiHeader.biClrUsed)
2035  {
2036  nNumColors = min(nNumColors, lpbmi->bmiHeader.biClrUsed);
2037  }
2038 
2039  ppalNew = PALETTE_AllocPalWithHandle(PAL_INDEXED, nNumColors, NULL, 0, 0, 0);
2040  if (ppalNew == NULL)
2041  {
2042  DPRINT1("Could not allocate palette\n");
2043  return NULL;
2044  }
2045 
2046  lpIndex = (USHORT *)((PBYTE)lpbmi + lpbmi->bmiHeader.biSize);
2047 
2048  for (i = 0; i < nNumColors; i++)
2049  {
2050  ULONG iColorIndex = *lpIndex % ppalDc->NumColors;
2051  ppalNew->IndexedColors[i] = ppalDc->IndexedColors[iColorIndex];
2052  lpIndex++;
2053  }
2054 
2055  hpal = ppalNew->BaseObject.hHmgr;
2056  PALETTE_UnlockPalette(ppalNew);
2057 
2058  return hpal;
2059 }
2060 
2061 /* Converts a BITMAPCOREINFO to a BITMAPINFO structure,
2062  * or does nothing if it's already a BITMAPINFO (or V4 or V5) */
2063 BITMAPINFO*
2064 FASTCALL
2066 {
2068  BITMAPINFO* pNewBmi ;
2069  UINT numColors = 0, ColorsSize = 0;
2070 
2071  if(pbmi->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER)) return (BITMAPINFO*)pbmi;
2072  if(pbmi->bmiHeader.biSize != sizeof(BITMAPCOREHEADER)) return NULL;
2073 
2074  if(pbmci->bmciHeader.bcBitCount <= 8)
2075  {
2076  numColors = 1 << pbmci->bmciHeader.bcBitCount;
2077  if(Usage == DIB_PAL_COLORS)
2078  {
2079  ColorsSize = numColors * sizeof(WORD);
2080  }
2081  else
2082  {
2083  ColorsSize = numColors * sizeof(RGBQUAD);
2084  }
2085  }
2086  else if (Usage == DIB_PAL_COLORS)
2087  {
2088  /* Invalid at high-res */
2089  return NULL;
2090  }
2091 
2092  pNewBmi = ExAllocatePoolWithTag(PagedPool, sizeof(BITMAPINFOHEADER) + ColorsSize, TAG_DIB);
2093  if(!pNewBmi) return NULL;
2094 
2095  RtlZeroMemory(pNewBmi, sizeof(BITMAPINFOHEADER) + ColorsSize);
2096 
2097  pNewBmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
2098  pNewBmi->bmiHeader.biBitCount = pbmci->bmciHeader.bcBitCount;
2099  pNewBmi->bmiHeader.biWidth = pbmci->bmciHeader.bcWidth;
2100  pNewBmi->bmiHeader.biHeight = pbmci->bmciHeader.bcHeight;
2101  pNewBmi->bmiHeader.biPlanes = pbmci->bmciHeader.bcPlanes;
2102  pNewBmi->bmiHeader.biCompression = BI_RGB ;
2104  pNewBmi->bmiHeader.biHeight,
2105  pNewBmi->bmiHeader.biBitCount);
2106  pNewBmi->bmiHeader.biClrUsed = numColors;
2107 
2108  if(Usage == DIB_PAL_COLORS)
2109  {
2110  RtlCopyMemory(pNewBmi->bmiColors, pbmci->bmciColors, ColorsSize);
2111  }
2112  else
2113  {
2114  UINT i;
2115  for(i=0; i<numColors; i++)
2116  {
2117  pNewBmi->bmiColors[i].rgbRed = pbmci->bmciColors[i].rgbtRed;
2118  pNewBmi->bmiColors[i].rgbGreen = pbmci->bmciColors[i].rgbtGreen;
2119  pNewBmi->bmiColors[i].rgbBlue = pbmci->bmciColors[i].rgbtBlue;
2120  }
2121  }
2122 
2123  return pNewBmi ;
2124 }
2125 
2126 /* Frees a BITMAPINFO created with DIB_ConvertBitmapInfo */
2127 VOID
2128 FASTCALL
2130 {
2131  BITMAPCOREINFO* pbmci;
2132  if(converted == orig)
2133  return;
2134 
2135  if(usage == -1)
2136  {
2137  /* Caller don't want any conversion */
2138  ExFreePoolWithTag(converted, TAG_DIB);
2139  return;
2140  }
2141 
2142  /* Perform inverse conversion */
2143  pbmci = (BITMAPCOREINFO*)orig;
2144 
2145  ASSERT(pbmci->bmciHeader.bcSize == sizeof(BITMAPCOREHEADER));
2146  pbmci->bmciHeader.bcBitCount = converted->bmiHeader.biBitCount;
2147  pbmci->bmciHeader.bcWidth = converted->bmiHeader.biWidth;
2148  pbmci->bmciHeader.bcHeight = converted->bmiHeader.biHeight;
2149  pbmci->bmciHeader.bcPlanes = converted->bmiHeader.biPlanes;
2150 
2151  if(pbmci->bmciHeader.bcBitCount <= 8)
2152  {
2153  UINT numColors = converted->bmiHeader.biClrUsed;
2154  if(!numColors) numColors = 1 << pbmci->bmciHeader.bcBitCount;
2155  if(usage == DIB_PAL_COLORS)
2156  {
2157  RtlZeroMemory(pbmci->bmciColors, (1 << pbmci->bmciHeader.bcBitCount) * sizeof(WORD));
2158  RtlCopyMemory(pbmci->bmciColors, converted->bmiColors, numColors * sizeof(WORD));
2159  }
2160  else
2161  {
2162  UINT i;
2163  RtlZeroMemory(pbmci->bmciColors, (1 << pbmci->bmciHeader.bcBitCount) * sizeof(RGBTRIPLE));
2164  for(i=0; i<numColors; i++)
2165  {
2166  pbmci->bmciColors[i].rgbtRed = converted->bmiColors[i].rgbRed;
2167  pbmci->bmciColors[i].rgbtGreen = converted->bmiColors[i].rgbGreen;
2168  pbmci->bmciColors[i].rgbtBlue = converted->bmiColors[i].rgbBlue;
2169  }
2170  }
2171  }
2172  /* Now free it, it's not needed anymore */
2173  ExFreePoolWithTag(converted, TAG_DIB);
2174 }
2175 
2176 /* EOF */
W32KAPI INT APIENTRY NtGdiStretchDIBitsInternal(IN HDC hdc, IN INT xDst, IN INT yDst, IN INT cxDst, IN INT cyDst, IN INT xSrc, IN INT ySrc, IN INT cxSrc, IN INT cySrc, IN OPTIONAL LPBYTE pjInit, IN LPBITMAPINFO pbmi, IN DWORD dwUsage, IN DWORD dwRop, IN UINT cjMaxInfo, IN UINT cjMaxBits, IN HANDLE hcmXform)
Definition: dibobj.c:1178
signed char * PCHAR
Definition: retypes.h:7
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define abs(i)
Definition: fconv.c:206
BYTE rgbtBlue
Definition: wingdi.h:1437
#define IN
Definition: typedefs.h:39
GLint GLint GLsizei width
Definition: gl.h:1546
HBITMAP NTAPI GreCreateDIBitmapInternal(IN HDC hDc, IN INT cx, IN INT cy, IN DWORD fInit, IN OPTIONAL LPBYTE pjInit, IN OPTIONAL PBITMAPINFO pbmi, IN DWORD iUsage, IN FLONG fl, IN UINT cjMaxBits, IN HANDLE hcmXform)
Definition: dibobj.c:1544
#define max(a, b)
Definition: svc.c:63
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1158
SIZEL sizlBitmap
Definition: winddi.h:1209
DWORD bV4RedMask
Definition: wingdi.h:1502
HBITMAP APIENTRY NtGdiCreateDIBSection(IN HDC hDC, IN OPTIONAL HANDLE hSection, IN DWORD dwOffset, IN BITMAPINFO *bmi, IN DWORD Usage, IN UINT cjHeader, IN FLONG fl, IN ULONG_PTR dwColorSpace, OUT PVOID *Bits)
Definition: dibobj.c:1671
ENGAPI BOOL APIENTRY EngDeleteSurface(_In_ _Post_ptr_invalid_ HSURF hsurf)
Definition: surface.c:564
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1475
#define WIDTH_BYTES_ALIGN32(cx, bpp)
Definition: swimpl.c:16
GLuint64EXT * result
Definition: glext.h:11304
DWORD bV4GreenMask
Definition: wingdi.h:1503
#define RGB(r, g, b)
Definition: precomp.h:62
#define SURFACE_ShareUnlockSurface(pBMObj)
Definition: surface.h:102
#define DIB_PAL_COLORS
Definition: wingdi.h:365
HBITMAP NTAPI GreCreateDIBitmapFromPackedDIB(_In_reads_(cjPackedDIB) PVOID pvPackedDIB, _In_ UINT cjPackedDIB, _In_ ULONG uUsage)
Definition: dibobj.c:1620
#define DIB_PAL_BRUSHHACK
Definition: dib.h:36
HBITMAP APIENTRY DIB_CreateDIBSection(PDC dc, CONST BITMAPINFO *bmi, UINT usage, LPVOID *bits, HANDLE section, DWORD offset, DWORD ovr_pitch)
Definition: dibobj.c:1738
#define TRUE
Definition: types.h:120
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO pbmi
Definition: ntgdi.h:2780
#define BitsPerFormat(Format)
Definition: surface.h:109
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:382
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO _In_ UINT _In_ UINT _In_ UINT cjMaxInfo
Definition: ntgdi.h:2780
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG _In_opt_ PVOID Data
Definition: wdfdevice.h:4527
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
LONG NTSTATUS
Definition: precomp.h:26
W32KAPI INT APIENTRY NtGdiSetDIBitsToDeviceInternal(IN HDC hDC, IN INT XDest, IN INT YDest, IN DWORD Width, IN DWORD Height, IN INT XSrc, IN INT YSrc, IN DWORD StartScan, IN DWORD ScanLines, IN LPBYTE Bits, IN LPBITMAPINFO bmi, IN DWORD ColorUse, IN UINT cjMaxBits, IN UINT cjMaxInfo, IN BOOL bTransformCoordinates, IN OPTIONAL HANDLE hcmXform)
Definition: dibobj.c:455
struct _BITMAPCOREINFO * PBITMAPCOREINFO
static const RGBQUAD DefLogPaletteQuads[20]
Definition: dibobj.c:14
static HDC
Definition: imagelist.c:92
PALETTEENTRY * IndexedColors
Definition: palette.h:42
struct _PALETTE *const ppal
Definition: surface.h:11
#define BMF_TOPDOWN
Definition: winddi.h:1180
LONG top
Definition: windef.h:307
long bottom
Definition: polytest.cpp:53
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ROP4_MASK
Definition: inteng.h:55
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
HPALETTE FASTCALL DIB_MapPaletteColors(PPALETTE ppalDc, CONST BITMAPINFO *lpbmi)
Definition: dibobj.c:2021
HBITMAP FASTCALL IntCreateCompatibleBitmap(PDC Dc, INT Width, INT Height, UINT Planes, UINT Bpp)
Definition: bitmaps.c:273
_In_ HBITMAP _In_ UINT iStartScan
Definition: ntgdi.h:2776
LONG left
Definition: windef.h:306
ULONG iBitmapFormat
Definition: winddi.h:1215
#define SURFACE_ShareLockSurface(hBMObj)
Definition: surface.h:91
Definition: parser.c:55
PPALETTE NTAPI CreateDIBPalette(_In_ const BITMAPINFO *pbmi, _In_ PDC pdc, _In_ ULONG iUsage)
Definition: dibobj.c:41
LONG right
Definition: windef.h:308
#define FASTCALL
Definition: nt_native.h:50
INT FASTCALL DIB_BitmapInfoSize(const BITMAPINFO *info, WORD coloruse)
Definition: dibobj.c:1992
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
int32_t INT
Definition: typedefs.h:58
#define BI_BITFIELDS
Definition: mmreg.h:507
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
PALETTE * gppalDefault
Definition: palette.c:20
static int init
Definition: wintirpc.c:33
#define ERROR_NO_SYSTEM_RESOURCES
Definition: winerror.h:931
struct BITMAPV4HEADER * PBITMAPV4HEADER
static IMAGE_SECTION_HEADER section
Definition: loader.c:152
LONG y
Definition: windef.h:330
_SEH2_TRY
Definition: create.c:4226
FORCEINLINE VOID PALETTE_vSetRGBColorForIndex(PPALETTE ppal, ULONG ulIndex, COLORREF crColor)
Definition: palette.h:151
_In_ DWORD _In_ DWORD dwOffset
Definition: ntgdi.h:2032
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
#define CBM_INIT
Definition: wingdi.h:364
BITMAPCOREHEADER bmciHeader
Definition: wingdi.h:1452
XLATEOBJ xlo
Definition: xlateobj.h:21
long right
Definition: polytest.cpp:53
BITMAPINFO *FASTCALL DIB_ConvertBitmapInfo(CONST BITMAPINFO *pbmi, DWORD Usage)
Definition: dibobj.c:2065
PPALETTE NTAPI PALETTE_AllocPalette(_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
Definition: palette.c:135
VOID NTAPI EXLATEOBJ_vInitialize(_Out_ PEXLATEOBJ pexlo, _In_opt_ PALETTE *ppalSrc, _In_opt_ PALETTE *ppalDst, _In_ COLORREF crSrcBackColor, _In_ COLORREF crDstBackColor, _In_ COLORREF crDstForeColor)
Definition: xlateobj.c:358
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
unsigned char * LPBYTE
Definition: typedefs.h:53
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
_In_ FLONG fl
Definition: winddi.h:1279
#define FALSE
Definition: types.h:117
#define PALETTE_UnlockPalette(pPalette)
Definition: palette.h:56
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
int FASTCALL DIB_GetBitmapInfo(const BITMAPINFOHEADER *header, LONG *width, LONG *height, WORD *planes, WORD *bpp, DWORD *compr, DWORD *size)
Definition: dibobj.c:1945
long top
Definition: polytest.cpp:53
SURFOBJ SurfObj
Definition: surface.h:8
DWORD biCompression
Definition: amvideo.idl:35
#define WIN32_ROP3_TO_ENG_ROP4(dwRop4)
Definition: intgdi.h:4
static int __cdecl compr(const void *a, const void *b)
Definition: bidi.c:641
INT APIENTRY GreGetDIBitsInternal(HDC hDC, HBITMAP hBitmap, UINT StartScan, UINT ScanLines, LPBYTE Bits, LPBITMAPINFO Info, UINT Usage, UINT MaxBits, UINT MaxInfo)
Definition: dibobj.c:671
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
NTSYSAPI NTSTATUS NTAPI ZwQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
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)
Definition: dibobj.c:1470
#define BMF_DONTCACHE
Definition: winddi.h:1182
_In_ HANDLE hcmXform
Definition: winddi.h:3687
ENGAPI VOID APIENTRY EngFreeUserMem(_Pre_notnull_ __drv_freesMem(UserMem) PVOID pv)
LONG cx
Definition: windef.h:334
RGBTRIPLE bmciColors[1]
Definition: wingdi.h:1453
void DPRINT(...)
Definition: polytest.cpp:61
void * PVOID
Definition: retypes.h:9
BOOL APIENTRY IntEngCopyBits(SURFOBJ *psoTrg, SURFOBJ *psoSrc, CLIPOBJ *pco, XLATEOBJ *pxlo, RECTL *prclTrg, POINTL *pptlSrc)
Definition: bitblt_new.c:678
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO _In_ UINT _In_ UINT cjMaxBits
Definition: ntgdi.h:2780
VOID NTAPI EXLATEOBJ_vCleanup(_Inout_ PEXLATEOBJ pexlo)
Definition: xlateobj.c:649
long left
Definition: polytest.cpp:53
unsigned long FLONG
Definition: ntbasedef.h:366
ULONG FASTCALL BitmapFormat(ULONG cBits, ULONG iCompression)
Definition: surface.c:39
#define UlongToPtr(u)
Definition: config.h:106
#define PALETTE_ShareLockPalette(hpal)
Definition: palette.h:57
typedef HSURF(APIENTRY FN_DrvEnableSurface)(_In_ DHPDEV dhpdev)
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER SectionOffset
Definition: mmfuncs.h:404
#define NtCurrentProcess()
Definition: nt_native.h:1657
#define BMF_USERMEM
Definition: winddi.h:1183
WORD * PWORD
Definition: pedump.c:67
Status
Definition: gdiplustypes.h:24
BOOL APIENTRY IntEngStretchBlt(SURFOBJ *DestObj, SURFOBJ *SourceObj, SURFOBJ *Mask, CLIPOBJ *ClipRegion, XLATEOBJ *ColorTranslation, COLORADJUSTMENT *pca, RECTL *DestRect, RECTL *SourceRect, POINTL *pMaskOrigin, BRUSHOBJ *Brush, POINTL *BrushOrigin, ULONG Mode)
Definition: polytest.cpp:40
GLsizeiptr size
Definition: glext.h:5919
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
#define __kernel_entry
Definition: specstrings.h:355
ULONG RGBQUAD
Definition: precomp.h:50
#define ASSERT(a)
Definition: mode.c:45
RGBQUAD bmiColors[1]
Definition: wingdi.h:1476
if(!(yy_init))
Definition: macro.lex.yy.c:714
FORCEINLINE ULONG PALETTE_ulGetRGBColorFromIndex(PPALETTE ppal, ULONG ulIndex)
Definition: palette.h:141
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
HBITMAP FASTCALL IntCreateDIBitmap(PDC Dc, INT width, INT height, UINT planes, UINT bpp, ULONG compression, DWORD init, LPBYTE bits, ULONG cjMaxBits, PBITMAPINFO data, DWORD coloruse)
Definition: dibobj.c:1372
GLintptr offset
Definition: glext.h:5920
DWORD COLORREF
Definition: windef.h:300
static void Exit(void)
Definition: sock.c:1331
unsigned short WORD
Definition: ntddk_ex.h:93
PVOID HANDLE
Definition: typedefs.h:73
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG x
Definition: windef.h:329
DWORD biSizeImage
Definition: amvideo.idl:36
PPALETTE NTAPI PALETTE_AllocPalWithHandle(_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
Definition: palette.c:209
ENGAPI SURFOBJ *APIENTRY EngLockSurface(_In_ HSURF hsurf)
Definition: surface.c:604
#define _Inout_
Definition: no_sal2.h:162
INT APIENTRY DIB_GetDIBImageBytes(INT width, INT height, INT depth)
Definition: dibobj.c:1980
#define BMF_NOZEROINIT
Definition: winddi.h:1181
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
BITMAP bmp
Definition: alphablend.c:62
FORCEINLINE VOID SURFACE_vSetPalette(_Inout_ PSURFACE psurf, _In_ PPALETTE ppal)
Definition: surface.h:136
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
#define IntLPtoDP(pdc, ppt, count)
Definition: coord.h:7
int ret
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
HANDLE hSecure
Definition: surface.h:32
VOID FASTCALL DIB_FreeConvertedBitmapInfo(BITMAPINFO *converted, BITMAPINFO *orig, DWORD usage)
Definition: dibobj.c:2129
HDC hdc
Definition: main.c:9
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY _In_ uint8_t compression
Definition: btrfs_drv.h:1357
#define VOID
Definition: acefi.h:82
BASEOBJECT BaseObject
Definition: palette.h:36
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
ULONG NumColors
Definition: palette.h:41
FLONG flFlags
Definition: palette.h:40
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
processorSet Mask
unsigned char BYTE
Definition: xxhash.c:193
__kernel_entry W32KAPI HDC APIENTRY NtGdiCreateCompatibleDC(_In_opt_ HDC hdc)
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define _In_
Definition: no_sal2.h:158
FORCEINLINE VOID RECTL_vOffsetRect(_Inout_ RECTL *prcl, _In_ INT cx, _In_ INT cy)
Definition: rect.h:31
USHORT fjBitmap
Definition: winddi.h:1217
_Success_(return!=0)
Definition: dibobj.c:1062
static HDC hDC
Definition: 3dtext.c:33
ULONG_PTR SIZE_T
Definition: typedefs.h:80
FORCEINLINE VOID RECTL_vSetRect(_Out_ RECTL *prcl, _In_ LONG left, _In_ LONG top, _In_ LONG right, _In_ LONG bottom)
Definition: rect.h:5
VOID DIB_1BPP_HLine(SURFOBJ *, LONG, LONG, LONG, ULONG)
Definition: dib1bpp.c:34
_SEH2_END
Definition: create.c:4400
__kernel_entry W32KAPI BOOL APIENTRY NtGdiDeleteObjectApp(_In_ HANDLE hobj)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
#define DC_TYPE_INFO
Definition: ntgdihdl.h:125
_In_ ULONG _In_ ULONG rgb
Definition: winddi.h:3520
unsigned short USHORT
Definition: pedump.c:61
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
Definition: bl.h:1331
ENGAPI VOID APIENTRY EngUnsecureMem(_In_ HANDLE hSecure)
#define PALETTE_ShareUnlockPalette(ppal)
Definition: palette.h:59
ENGAPI VOID APIENTRY EngUnlockSurface(_In_ _Post_ptr_invalid_ SURFOBJ *pso)
Definition: surface.c:625
HBITMAP NTAPI GreCreateBitmapEx(_In_ ULONG nWidth, _In_ ULONG nHeight, _In_ ULONG cjWidthBytes, _In_ ULONG iFormat, _In_ USHORT fjBitmap, _In_ ULONG cjSizeImage, _In_opt_ PVOID pvBits, _In_ FLONG flags)
Definition: bitmaps.c:101
#define min(a, b)
Definition: monoChain.cc:55
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO _In_ UINT iUsage
Definition: ntgdi.h:2780
BYTE rgbtRed
Definition: wingdi.h:1439
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
VOID FASTCALL DC_vPrepareDCsForBlit(PDC pdcDest, const RECT *rcDest, PDC pdcSrc, const RECT *rcSrc)
Definition: dclife.c:505
#define DIB_PAL_INDICES
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define BI_RLE4
Definition: precomp.h:48
DWORD * PDWORD
Definition: pedump.c:68
static HBITMAP IntGdiCreateMaskFromRLE(DWORD Width, DWORD Height, ULONG Compression, const BYTE *Bits, DWORD BitsSize)
Definition: dibobj.c:345
#define DPRINT1
Definition: precomp.h:8
VOID FASTCALL DC_vFinishBlit(PDC pdc1, PDC pdc2)
Definition: dclife.c:614
_Out_opt_ int * cx
Definition: commctrl.h:581
#define CBM_CREATDIB
#define OUT
Definition: typedefs.h:40
GLuint res
Definition: glext.h:9613
VOID FASTCALL IntUpdateBoundsRect(PDC, PRECTL)
Definition: dcutil.c:694
PVOID pvBits
Definition: winddi.h:1211
#define _Out_writes_bytes_opt_(s)
Definition: no_sal2.h:228
unsigned int ULONG
Definition: retypes.h:1
#define W32KAPI
Definition: ntgdi.h:9
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
LONG bottom
Definition: windef.h:309
char * cleanup(char *str)
Definition: wpickclick.c:99
static const WCHAR dc[]
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
ENGAPI HANDLE APIENTRY EngSecureMem(_In_reads_bytes_(cjLength) PVOID Address, _In_ ULONG cjLength)
_In_ HBITMAP _In_ UINT _In_ UINT cScans
Definition: ntgdi.h:2776
DWORD bpp
Definition: surface.c:182
static HBITMAP hbitmap
static HBITMAP
Definition: button.c:44
BYTE rgbtGreen
Definition: wingdi.h:1438
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define STATUS_SUCCESS
Definition: shellext.h:65
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
DWORD bV4BlueMask
Definition: wingdi.h:1504
#define _In_reads_(s)
Definition: no_sal2.h:168
#define DIB_RGB_COLORS
Definition: wingdi.h:366
static INT FASTCALL IntSetDIBits(PDC DC, HBITMAP hBitmap, UINT StartScan, UINT ScanLines, CONST VOID *Bits, ULONG cjMaxBits, CONST BITMAPINFO *bmi, UINT ColorUse)
Definition: dibobj.c:224
#define BI_RLE8
Definition: wingdi.h:35
_In_ const BITMAPINFO _In_ UINT _In_opt_ HANDLE hSection
Definition: wingdi.h:3238
LONG cy
Definition: windef.h:335
BYTE * PBYTE
Definition: pedump.c:66
#define BI_RGB
Definition: precomp.h:47
static HBITMAP hBitmap
Definition: timezone.c:26
#define ROP4_FROM_INDEX(index)
Definition: inteng.h:42
#define CONST
Definition: pedump.c:81
#define SRCCOPY
Definition: wingdi.h:332
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
#define APIENTRY
Definition: api.h:79
BOOL APIENTRY IntEngBitBlt(SURFOBJ *psoTrg, SURFOBJ *psoSrc, SURFOBJ *psoMask, CLIPOBJ *pco, XLATEOBJ *pxlo, RECTL *prclTrg, POINTL *pptlSrc, POINTL *pptlMask, BRUSHOBJ *pbo, POINTL *pptlBrush, ROP4 Rop4)
Definition: bitblt.c:604
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define TAG_DIB
Definition: tags.h:17
HBITMAP NTAPI GreCreateBitmap(_In_ ULONG nWidth, _In_ ULONG nHeight, _In_ ULONG cPlanes, _In_ ULONG cBitsPixel, _In_opt_ PVOID pvBits)
Definition: bitmaps.c:172
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
Definition: xlate.c:8
static const BYTE masks[8]
Definition: dib.c:2760