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