ReactOS 0.4.15-dev-7907-g95bf896
bitmaps.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: GNU GPL, See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: Bitmap functions
5 * FILE: win32ss/gdi/ntgdi/bitmaps.c
6 * PROGRAMERS: Timo Kreuzer <timo.kreuzer@reactos.org>
7 * Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
8 */
9
10#include <win32k.h>
11
12#define NDEBUG
13#include <debug.h>
14
15BOOL
19 _In_ ULONG ulOwner)
20{
21 /* Check if we have the correct object type */
23 {
24 DPRINT1("Incorrect type for hbmp: %p\n", hbmp);
25 return FALSE;
26 }
27
30
31 /* Check if we set public or none */
32 if ((ulOwner == GDI_OBJ_HMGR_PUBLIC) ||
33 (ulOwner == GDI_OBJ_HMGR_NONE))
34 {
35 /* Only allow this for owned objects */
37 {
38 DPRINT1("Cannot change owner for non-powned hbmp\n");
39 return FALSE;
40 }
41 }
42
43 return GreSetObjectOwner(hbmp, ulOwner);
44}
45
46LONG
49 _Inout_ PSURFACE psurf,
50 _In_ ULONG cjBits,
51 _In_ const VOID *pvBits)
52{
53 PUCHAR pjDst;
54 const UCHAR *pjSrc;
55 LONG lDeltaDst, lDeltaSrc, lDeltaDstAbs;
56 ULONG Y, iSrc, iDst, cbSrc, cbDst, nWidth, nHeight, cBitsPixel;
57
58 NT_ASSERT(psurf->flags & API_BITMAP);
59 NT_ASSERT(psurf->SurfObj.iBitmapFormat <= BMF_32BPP);
60
61 nWidth = psurf->SurfObj.sizlBitmap.cx;
62 nHeight = psurf->SurfObj.sizlBitmap.cy;
63 cBitsPixel = BitsPerFormat(psurf->SurfObj.iBitmapFormat);
64
65 pjDst = psurf->SurfObj.pvScan0;
66 pjSrc = pvBits;
67 lDeltaDst = psurf->SurfObj.lDelta;
68 lDeltaDstAbs = labs(lDeltaDst);
69 lDeltaSrc = WIDTH_BYTES_ALIGN16(nWidth, cBitsPixel);
70 NT_ASSERT(lDeltaSrc <= lDeltaDstAbs);
71
72 cbDst = lDeltaDstAbs * nHeight;
73 cbSrc = lDeltaSrc * nHeight;
74 cjBits = min(cjBits, cbSrc);
75
76 iSrc = iDst = 0;
77 for (Y = 0; Y < nHeight; Y++)
78 {
79 if (iSrc + lDeltaSrc > cjBits || iDst + lDeltaDstAbs > cbDst)
80 {
81 LONG lDelta = min(cjBits - iSrc, cbDst - iDst);
82 NT_ASSERT(lDelta >= 0);
83 RtlCopyMemory(pjDst, pjSrc, lDelta);
84 iSrc += lDelta;
85 break;
86 }
87
88 /* Copy one line */
89 RtlCopyMemory(pjDst, pjSrc, lDeltaSrc);
90 pjSrc += lDeltaSrc;
91 pjDst += lDeltaDst;
92 iSrc += lDeltaSrc;
93 iDst += lDeltaDstAbs;
94 }
95
96 return iSrc;
97}
98
100NTAPI
102 _In_ ULONG nWidth,
103 _In_ ULONG nHeight,
104 _In_ ULONG cjWidthBytes,
106 _In_ USHORT fjBitmap,
107 _In_ ULONG cjSizeImage,
108 _In_opt_ PVOID pvBits,
110{
111 PSURFACE psurf;
113 PVOID pvCompressedBits = NULL;
114
115 /* Verify format */
116 if (iFormat < BMF_1BPP || iFormat > BMF_PNG) return NULL;
117
118 /* The infamous RLE hack */
119 if ((iFormat == BMF_4RLE) || (iFormat == BMF_8RLE))
120 {
121 pvCompressedBits = pvBits;
122 pvBits = NULL;
124 }
125
126 /* Allocate a surface */
128 nWidth,
129 nHeight,
130 iFormat,
131 fjBitmap,
132 cjWidthBytes,
133 pvCompressedBits ? 0 : cjSizeImage,
134 pvBits);
135 if (!psurf)
136 {
137 DPRINT1("SURFACE_AllocSurface failed.\n");
138 return NULL;
139 }
140
141 /* The infamous RLE hack */
142 if (pvCompressedBits)
143 {
144 SIZEL sizl;
145 LONG lDelta;
146
147 sizl.cx = nWidth;
148 sizl.cy = nHeight;
150
151 pvBits = psurf->SurfObj.pvBits;
152 DecompressBitmap(sizl, pvCompressedBits, pvBits, lDelta, iFormat, cjSizeImage);
153 }
154
155 /* Get the handle for the bitmap */
156 hbmp = (HBITMAP)psurf->SurfObj.hsurf;
157
158 /* Mark as API bitmap */
159 psurf->flags |= (flags | API_BITMAP);
160
161 /* Unlock the surface and return */
163 return hbmp;
164}
165
166/* Creates a DDB surface,
167 * as in CreateCompatibleBitmap or CreateBitmap.
168 * Note that each scanline must be 32bit aligned!
169 */
171NTAPI
173 _In_ ULONG nWidth,
174 _In_ ULONG nHeight,
175 _In_ ULONG cPlanes,
176 _In_ ULONG cBitsPixel,
177 _In_opt_ PVOID pvBits)
178{
179 /* Call the extended function */
180 return GreCreateBitmapEx(nWidth,
181 nHeight,
182 0, /* Auto width */
183 BitmapFormat(cBitsPixel * cPlanes, BI_RGB),
184 0, /* No bitmap flags */
185 0, /* Auto size */
186 pvBits,
187 DDB_SURFACE /* DDB */);
188}
189
193 IN INT nWidth,
194 IN INT nHeight,
195 IN UINT cPlanes,
196 IN UINT cBitsPixel,
197 IN OPTIONAL LPBYTE pUnsafeBits)
198{
200 ULONG cRealBpp, cjWidthBytes, iFormat;
202 PSURFACE psurf;
203
204 /* Calculate bitmap format and real bits per pixel. */
205 iFormat = BitmapFormat(cBitsPixel * cPlanes, BI_RGB);
206 cRealBpp = gajBitsPerFormat[iFormat];
207
208 /* Calculate width and image size in bytes */
209 cjWidthBytes = WIDTH_BYTES_ALIGN16(nWidth, cRealBpp);
210 cjSize = (ULONGLONG)cjWidthBytes * nHeight;
211
212 /* Check parameters (possible overflow of cjSize!) */
213 if ((iFormat == 0) || (nWidth <= 0) || (nWidth >= 0x8000000) || (nHeight <= 0) ||
214 (cBitsPixel > 32) || (cPlanes > 32) || (cjSize >= 0x100000000ULL))
215 {
216 DPRINT1("Invalid bitmap format! Width=%d, Height=%d, Bpp=%u, Planes=%u\n",
217 nWidth, nHeight, cBitsPixel, cPlanes);
219 return NULL;
220 }
221
222 /* Allocate the surface (but don't set the bits) */
224 nWidth,
225 nHeight,
226 iFormat,
227 0,
228 0,
229 0,
230 NULL);
231 if (!psurf)
232 {
233 DPRINT1("SURFACE_AllocSurface failed.\n");
234 return NULL;
235 }
236
237 /* Mark as API and DDB bitmap */
238 psurf->flags |= (API_BITMAP | DDB_SURFACE);
239
240 /* Check if we have bits to set */
241 if (pUnsafeBits)
242 {
243 /* Protect with SEH and copy the bits */
245 {
246 ProbeForRead(pUnsafeBits, (SIZE_T)cjSize, 1);
247 UnsafeSetBitmapBits(psurf, cjSize, pUnsafeBits);
248 }
250 {
252 _SEH2_YIELD(return NULL;)
253 }
255 }
256 else
257 {
258 /* Zero the bits */
259 RtlZeroMemory(psurf->SurfObj.pvBits, psurf->SurfObj.cjBits);
260 }
261
262 /* Get the handle for the bitmap */
263 hbmp = (HBITMAP)psurf->SurfObj.hsurf;
264
265 /* Unlock the surface */
267
268 return hbmp;
269}
270
271
274 PDC Dc,
275 INT Width,
276 INT Height,
277 UINT Planes,
278 UINT Bpp)
279{
280 HBITMAP Bmp = NULL;
281 PPALETTE ppal;
282
283 /* MS doc says if width or height is 0, return 1-by-1 pixel, monochrome bitmap */
284 if (0 == Width || 0 == Height)
285 {
287 }
288
289 if (Dc->dctype != DCTYPE_MEMORY)
290 {
291 PSURFACE psurf;
292
294 abs(Height),
295 Planes ? Planes : 1,
296 Bpp ? Bpp : Dc->ppdev->gdiinfo.cBitsPixel,
297 NULL);
298 if (Bmp == NULL)
299 {
300 DPRINT1("Failed to allocate a bitmap!\n");
301 return NULL;
302 }
303
304 psurf = SURFACE_ShareLockSurface(Bmp);
305 ASSERT(psurf);
306
307 /* Dereference old palette and set new palette */
308 ppal = PALETTE_ShareLockPalette(Dc->ppdev->devinfo.hpalDefault);
309 ASSERT(ppal);
310 SURFACE_vSetPalette(psurf, ppal);
312
313 /* Set flags */
314 psurf->flags = API_BITMAP;
315 psurf->hdc = NULL; // FIXME:
316 psurf->SurfObj.hdev = (HDEV)Dc->ppdev;
318 }
319 else
320 {
321 DIBSECTION dibs;
322 INT Count;
323 PSURFACE psurf = Dc->dclevel.pSurface;
324 if(!psurf) psurf = psurfDefaultBitmap;
325 Count = BITMAP_GetObject(psurf, sizeof(dibs), &dibs);
326
327 if (Count == sizeof(BITMAP))
328 {
329 PSURFACE psurfBmp;
330
332 abs(Height),
333 Planes ? Planes : 1,
334 Bpp ? Bpp : dibs.dsBm.bmBitsPixel,
335 NULL);
336 if (Bmp == NULL)
337 {
338 DPRINT1("Failed to allocate a bitmap!\n");
339 return NULL;
340 }
341 psurfBmp = SURFACE_ShareLockSurface(Bmp);
342 ASSERT(psurfBmp);
343
344 /* Dereference old palette and set new palette */
345 SURFACE_vSetPalette(psurfBmp, psurf->ppal);
346
347 /* Set flags */
348 psurfBmp->flags = API_BITMAP;
349 psurfBmp->hdc = NULL; // FIXME:
350 psurfBmp->SurfObj.hdev = (HDEV)Dc->ppdev;
352 }
353 else if (Count == sizeof(DIBSECTION))
354 {
355 /* A DIB section is selected in the DC */
356 BYTE buf[sizeof(BITMAPINFOHEADER) + 256*sizeof(RGBQUAD)] = {0};
357 PVOID Bits;
358 BITMAPINFO* bi = (BITMAPINFO*)buf;
359
360 bi->bmiHeader.biSize = sizeof(bi->bmiHeader);
361 bi->bmiHeader.biWidth = Width;
363 bi->bmiHeader.biPlanes = Planes ? Planes : dibs.dsBmih.biPlanes;
364 bi->bmiHeader.biBitCount = Bpp ? Bpp : dibs.dsBmih.biBitCount;
366 bi->bmiHeader.biSizeImage = 0;
371
373 {
374 /* Copy the color masks */
375 RtlCopyMemory(bi->bmiColors, dibs.dsBitfields, 3*sizeof(RGBQUAD));
376 }
377 else if (bi->bmiHeader.biBitCount <= 8)
378 {
379 /* Copy the color table */
380 UINT Index;
381 PPALETTE PalGDI;
382
383 if (!psurf->ppal)
384 {
386 return 0;
387 }
388
389 PalGDI = psurf->ppal;
390
391 for (Index = 0;
392 Index < 256 && Index < PalGDI->NumColors;
393 Index++)
394 {
398 bi->bmiColors[Index].rgbReserved = 0;
399 }
400 }
401
402 Bmp = DIB_CreateDIBSection(Dc,
403 bi,
405 &Bits,
406 NULL,
407 0,
408 0);
409 return Bmp;
410 }
411 }
412 return Bmp;
413}
414
417 HDC hDC,
418 INT Width,
419 INT Height)
420{
421 HBITMAP Bmp;
422 PDC Dc;
423
424 /* Check parameters */
425 if ((Width <= 0) || (Height <= 0) || ((Width * Height) > 0x3FFFFFFF))
426 {
428 return NULL;
429 }
430
431 if (!hDC)
432 return GreCreateBitmap(Width, Height, 1, 1, 0);
433
434 Dc = DC_LockDc(hDC);
435
436 DPRINT("NtGdiCreateCompatibleBitmap(%p,%d,%d, bpp:%u) = \n",
437 hDC, Width, Height, Dc->ppdev->gdiinfo.cBitsPixel);
438
439 if (NULL == Dc)
440 {
442 return NULL;
443 }
444
445 Bmp = IntCreateCompatibleBitmap(Dc, Width, Height, 0, 0);
446
447 DC_UnlockDc(Dc);
448 return Bmp;
449}
450
451BOOL
452NTAPI
455 _Out_ LPSIZE psizDim)
456{
457 PSURFACE psurfBmp;
458
459 if (hBitmap == NULL)
460 return FALSE;
461
462 /* Lock the bitmap */
464 if (psurfBmp == NULL)
465 {
467 return FALSE;
468 }
469
470 *psizDim = psurfBmp->sizlDim;
471
472 /* Unlock the bitmap */
474
475 return TRUE;
476}
477
478BOOL
482 LPSIZE psizDim)
483{
484 SIZE dim;
485
486 if (!GreGetBitmapDimension(hBitmap, &dim))
487 return FALSE;
488
489 /* Use SEH to copy the data to the caller */
491 {
492 ProbeForWrite(psizDim, sizeof(*psizDim), 1);
493 *psizDim = dim;
494 }
496 {
497 _SEH2_YIELD(return FALSE);
498 }
500
501 return TRUE;
502}
503
504
505LONG
508 PSURFACE psurf,
509 DWORD Bytes,
510 OUT PBYTE pvBits)
511{
512 PUCHAR pjDst, pjSrc;
513 LONG lDeltaDst, lDeltaSrc, lDeltaSrcAbs;
514 ULONG Y, iSrc, iDst, cbSrc, cbDst, nWidth, nHeight, cBitsPixel;
515
516 nWidth = psurf->SurfObj.sizlBitmap.cx;
517 nHeight = psurf->SurfObj.sizlBitmap.cy;
518 cBitsPixel = BitsPerFormat(psurf->SurfObj.iBitmapFormat);
519
520 /* Get pointers */
521 pjSrc = psurf->SurfObj.pvScan0;
522 pjDst = pvBits;
523 lDeltaSrc = psurf->SurfObj.lDelta;
524 lDeltaSrcAbs = labs(lDeltaSrc);
525 lDeltaDst = WIDTH_BYTES_ALIGN16(nWidth, cBitsPixel);
526 NT_ASSERT(lDeltaSrcAbs >= lDeltaDst);
527
528 cbSrc = nHeight * lDeltaSrcAbs;
529 cbDst = nHeight * lDeltaDst;
530 Bytes = min(Bytes, cbDst);
531
532 iSrc = iDst = 0;
533 for (Y = 0; Y < nHeight; Y++)
534 {
535 if (iSrc + lDeltaSrcAbs > cbSrc || iDst + lDeltaDst > Bytes)
536 {
537 LONG lDelta = min(cbSrc - iSrc, Bytes - iDst);
538 NT_ASSERT(lDelta >= 0);
539 RtlCopyMemory(pjDst, pjSrc, lDelta);
540 iDst += lDelta;
541 break;
542 }
543
544 /* Copy one line */
545 RtlCopyMemory(pjDst, pjSrc, lDeltaDst);
546 pjSrc += lDeltaSrc;
547 pjDst += lDeltaDst;
548 iSrc += lDeltaSrcAbs;
549 iDst += lDeltaDst;
550 }
551
552 return iDst;
553}
554
555LONG
560 OUT OPTIONAL PBYTE pUnsafeBits)
561{
562 PSURFACE psurf;
564 LONG ret;
565
566 /* Check parameters */
567 if (pUnsafeBits != NULL && cjBuffer == 0)
568 {
569 return 0;
570 }
571
572 /* Lock the bitmap */
574 if (!psurf)
575 {
577 return 0;
578 }
579
580 /* Calculate the size of the bitmap in bytes */
583 psurf->SurfObj.sizlBitmap.cy;
584
585 /* If the bits vector is null, the function should return the read size */
586 if (pUnsafeBits == NULL)
587 {
589 return cjSize;
590 }
591
592 /* Don't copy more bytes than the buffer has */
594
595 // FIXME: Use MmSecureVirtualMemory
597 {
598 ProbeForWrite(pUnsafeBits, cjBuffer, 1);
599 ret = UnsafeGetBitmapBits(psurf, cjBuffer, pUnsafeBits);
600 }
602 {
603 ret = 0;
604 }
606
608
609 return ret;
610}
611
612
616 DWORD Bytes,
617 IN PBYTE pUnsafeBits)
618{
619 LONG ret;
620 PSURFACE psurf;
621
622 if (pUnsafeBits == NULL || Bytes == 0)
623 {
624 return 0;
625 }
626
628 {
629 return 0;
630 }
631
633 if (psurf == NULL)
634 {
636 return 0;
637 }
638
639 if (((psurf->flags & API_BITMAP) == 0) ||
641 {
642 DPRINT1("Invalid bitmap: iBitmapFormat = %lu, flags = 0x%lx\n",
643 psurf->SurfObj.iBitmapFormat,
644 psurf->flags);
647 return 0;
648 }
649
651 {
652 /* NOTE: Win2k3 doesn't check WORD alignment here. */
653 ProbeForWrite(pUnsafeBits, Bytes, 1);
654 ret = UnsafeSetBitmapBits(psurf, Bytes, pUnsafeBits);
655 }
657 {
658 ret = 0;
659 }
661
663
664 return ret;
665}
666
670 INT Width,
671 INT Height,
672 LPSIZE Size)
673{
674 PSURFACE psurf;
675 BOOL Ret = TRUE;
676
677 if (hBitmap == NULL)
678 return FALSE;
679
681 if (psurf == NULL)
682 {
684 return FALSE;
685 }
686
687 if (Size)
688 {
690 {
691 ProbeForWrite(Size, sizeof(SIZE), 1);
692 *Size = psurf->sizlDim;
693 }
695 {
696 Ret = FALSE;
697 }
699 }
700
701 /* The dimension is changed even if writing the old value failed */
702 psurf->sizlDim.cx = Width;
703 psurf->sizlDim.cy = Height;
704
706
707 return Ret;
708}
709
710/* Internal Functions */
711
715{
716 HBITMAP hbmNew;
717 SURFACE *psurfSrc, *psurfNew;
718
719 /* Fail, if no source bitmap is given */
720 if (hBitmap == NULL) return 0;
721
722 /* Lock the source bitmap */
724 if (psurfSrc == NULL)
725 {
726 return 0;
727 }
728
729 /* Allocate a new bitmap with the same dimensions as the source bmp */
730 hbmNew = GreCreateBitmapEx(psurfSrc->SurfObj.sizlBitmap.cx,
731 psurfSrc->SurfObj.sizlBitmap.cy,
732 abs(psurfSrc->SurfObj.lDelta),
733 psurfSrc->SurfObj.iBitmapFormat,
734 psurfSrc->SurfObj.fjBitmap & BMF_TOPDOWN,
735 psurfSrc->SurfObj.cjBits,
736 NULL,
737 psurfSrc->flags);
738
739 if (hbmNew)
740 {
741 /* Lock the new bitmap */
742 psurfNew = SURFACE_ShareLockSurface(hbmNew);
743 if (psurfNew)
744 {
745 /* Copy the bitmap bits to the new bitmap buffer */
746 RtlCopyMemory(psurfNew->SurfObj.pvBits,
747 psurfSrc->SurfObj.pvBits,
748 psurfNew->SurfObj.cjBits);
749
750
751 /* Reference the palette of the source bitmap and use it */
752 SURFACE_vSetPalette(psurfNew, psurfSrc->ppal);
753
754 /* Unlock the new surface */
756 }
757 else
758 {
759 /* Failed to lock the bitmap, shouldn't happen */
760 GreDeleteObject(hbmNew);
761 hbmNew = NULL;
762 }
763 }
764
765 /* Unlock the source bitmap and return the handle of the new bitmap */
767 return hbmNew;
768}
769
772{
773 PBITMAP pBitmap;
774
775 if (!buffer) return sizeof(BITMAP);
776 if ((UINT)Count < sizeof(BITMAP)) return 0;
777
778 /* Always fill a basic BITMAP structure */
779 pBitmap = buffer;
780 pBitmap->bmType = 0;
781 pBitmap->bmWidth = psurf->SurfObj.sizlBitmap.cx;
782 pBitmap->bmHeight = psurf->SurfObj.sizlBitmap.cy;
783 pBitmap->bmPlanes = 1;
784 pBitmap->bmBitsPixel = BitsPerFormat(psurf->SurfObj.iBitmapFormat);
785 pBitmap->bmWidthBytes = WIDTH_BYTES_ALIGN16(pBitmap->bmWidth, pBitmap->bmBitsPixel);
786
787 /* Check for DIB section */
788 if (psurf->hSecure)
789 {
790 /* Set bmBits in this case */
791 pBitmap->bmBits = psurf->SurfObj.pvBits;
792 /* DIBs data are 32 bits aligned */
793 pBitmap->bmWidthBytes = WIDTH_BYTES_ALIGN32(pBitmap->bmWidth, pBitmap->bmBitsPixel);
794
795 if (Count >= sizeof(DIBSECTION))
796 {
797 /* Fill rest of DIBSECTION */
798 PDIBSECTION pds = buffer;
799
800 pds->dsBmih.biSize = sizeof(BITMAPINFOHEADER);
801 pds->dsBmih.biWidth = pds->dsBm.bmWidth;
802 pds->dsBmih.biHeight = pds->dsBm.bmHeight;
803 pds->dsBmih.biPlanes = pds->dsBm.bmPlanes;
804 pds->dsBmih.biBitCount = pds->dsBm.bmBitsPixel;
805
806 switch (psurf->SurfObj.iBitmapFormat)
807 {
808 case BMF_1BPP:
809 case BMF_4BPP:
810 case BMF_8BPP:
812 break;
813
814 case BMF_16BPP:
815 if (psurf->ppal->flFlags & PAL_RGB16_555)
817 else
819 break;
820
821 case BMF_24BPP:
822 case BMF_32BPP:
823 /* 24/32bpp BI_RGB is actually BGR format */
824 if (psurf->ppal->flFlags & PAL_BGR)
826 else
828 break;
829
830 case BMF_4RLE:
832 break;
833 case BMF_8RLE:
835 break;
836 case BMF_JPEG:
838 break;
839 case BMF_PNG:
841 break;
842 default:
843 ASSERT(FALSE); /* This shouldn't happen */
844 }
845
846 pds->dsBmih.biSizeImage = psurf->SurfObj.cjBits;
847 pds->dsBmih.biXPelsPerMeter = 0;
848 pds->dsBmih.biYPelsPerMeter = 0;
849 pds->dsBmih.biClrUsed = psurf->ppal->NumColors;
851 pds->dsBitfields[0] = psurf->ppal->RedMask;
852 pds->dsBitfields[1] = psurf->ppal->GreenMask;
853 pds->dsBitfields[2] = psurf->ppal->BlueMask;
854 pds->dshSection = psurf->hDIBSection;
855 pds->dsOffset = psurf->dwOffset;
856
857 return sizeof(DIBSECTION);
858 }
859 }
860 else
861 {
862 /* Not set according to wine test, confirmed in win2k */
863 pBitmap->bmBits = NULL;
864 }
865
866 return sizeof(BITMAP);
867}
868
869/*
870 * @implemented
871 */
872HDC
875 IN HBITMAP hsurf)
876{
877 HDC hdc = NULL;
878 PSURFACE psurf = SURFACE_ShareLockSurface(hsurf);
879 if (psurf)
880 {
881 hdc = psurf->hdc;
883 }
884 return hdc;
885}
886
887
888/* EOF */
static HDC hDC
Definition: 3dtext.c:33
#define DPRINT1
Definition: precomp.h:8
INT APIENTRY BITMAP_GetObject(SURFACE *psurf, INT Count, LPVOID buffer)
Definition: bitmaps.c:771
LONG APIENTRY NtGdiGetBitmapBits(HBITMAP hBitmap, ULONG cjBuffer, OUT OPTIONAL PBYTE pUnsafeBits)
Definition: bitmaps.c:557
LONG FASTCALL UnsafeGetBitmapBits(PSURFACE psurf, DWORD Bytes, OUT PBYTE pvBits)
Definition: bitmaps.c:507
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
BOOL APIENTRY NtGdiGetBitmapDimension(HBITMAP hBitmap, LPSIZE psizDim)
Definition: bitmaps.c:480
HBITMAP FASTCALL BITMAP_CopyBitmap(HBITMAP hBitmap)
Definition: bitmaps.c:714
BOOL NTAPI GreSetBitmapOwner(_In_ HBITMAP hbmp, _In_ ULONG ulOwner)
Definition: bitmaps.c:17
HDC APIENTRY NtGdiGetDCforBitmap(IN HBITMAP hsurf)
Definition: bitmaps.c:874
HBITMAP APIENTRY NtGdiCreateBitmap(IN INT nWidth, IN INT nHeight, IN UINT cPlanes, IN UINT cBitsPixel, IN OPTIONAL LPBYTE pUnsafeBits)
Definition: bitmaps.c:192
HBITMAP NTAPI GreCreateBitmap(_In_ ULONG nWidth, _In_ ULONG nHeight, _In_ ULONG cPlanes, _In_ ULONG cBitsPixel, _In_opt_ PVOID pvBits)
Definition: bitmaps.c:172
BOOL NTAPI GreGetBitmapDimension(_In_ HBITMAP hBitmap, _Out_ LPSIZE psizDim)
Definition: bitmaps.c:453
BOOL APIENTRY NtGdiSetBitmapDimension(HBITMAP hBitmap, INT Width, INT Height, LPSIZE Size)
Definition: bitmaps.c:668
LONG NTAPI UnsafeSetBitmapBits(_Inout_ PSURFACE psurf, _In_ ULONG cjBits, _In_ const VOID *pvBits)
Definition: bitmaps.c:48
LONG APIENTRY NtGdiSetBitmapBits(HBITMAP hBitmap, DWORD Bytes, IN PBYTE pUnsafeBits)
Definition: bitmaps.c:614
HBITMAP APIENTRY NtGdiCreateCompatibleBitmap(HDC hDC, INT Width, INT Height)
Definition: bitmaps.c:416
HBITMAP hbmp
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:238
_Notnull_ PSURFACE psurfDefaultBitmap
Definition: dclife.c:17
@ DCTYPE_MEMORY
Definition: dc.h:42
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:220
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static HBITMAP hBitmap
Definition: timezone.c:26
#define APIENTRY
Definition: api.h:79
#define Y(I)
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define BI_RLE4
Definition: precomp.h:57
#define BI_RGB
Definition: precomp.h:56
ULONG RGBQUAD
Definition: precomp.h:59
VOID DecompressBitmap(SIZEL Size, BYTE *CompressedBits, BYTE *UncompressedBits, LONG Delta, ULONG iFormat, ULONG cjSizeImage)
Definition: rlecomp.c:21
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
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
#define GDI_HANDLE_IS_STOCKOBJ(h)
Definition: gdi.h:37
@ GDILoObjType_LO_BITMAP_TYPE
Definition: gdi_private.h:35
GLuint buffer
Definition: glext.h:5915
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLbitfield flags
Definition: glext.h:7161
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
_Check_return_ long __cdecl labs(_In_ long x)
_In_ UINT Bytes
Definition: mmcopy.h:9
#define BI_BITFIELDS
Definition: mmreg.h:507
#define ASSERT(a)
Definition: mode.c:44
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
#define min(a, b)
Definition: monoChain.cc:55
#define _Inout_
Definition: ms_sal.h:378
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
unsigned int UINT
Definition: ndis.h:50
int Count
Definition: noreturn.cpp:7
#define FASTCALL
Definition: nt_native.h:50
unsigned long FLONG
Definition: ntbasedef.h:366
__kernel_entry W32KAPI HANDLE APIENTRY NtGdiGetStockObject(_In_ INT iObject)
_In_ ULONG cjBuffer
Definition: ntgdi.h:2860
#define GDI_OBJ_HMGR_POWNED
Definition: ntgdihdl.h:117
#define GDI_OBJ_HMGR_PUBLIC
Definition: ntgdihdl.h:116
#define GDI_OBJ_HMGR_NONE
Definition: ntgdihdl.h:118
#define DEFAULT_BITMAP
Definition: ntgdityp.h:195
BYTE * PBYTE
Definition: pedump.c:66
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
#define BITMAP
Definition: pedump.c:503
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:162
#define DPRINT
Definition: sndvol32.h:71
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
Definition: polytest.cpp:41
Definition: bl.h:1331
ULONG NumColors
Definition: palette.h:41
PALETTEENTRY * IndexedColors
Definition: palette.h:42
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
SURFOBJ SurfObj
Definition: surface.h:8
HANDLE hDIBSection
Definition: surface.h:31
SIZEL sizlDim
Definition: surface.h:21
HDC hdc
Definition: surface.h:26
HANDLE hSecure
Definition: surface.h:32
DWORD dwOffset
Definition: surface.h:33
DWORD biClrImportant
Definition: surface.h:37
struct _PALETTE *const ppal
Definition: surface.h:11
BASEOBJECT BaseObject
Definition: surface.h:6
FLONG flags
Definition: surface.h:10
USHORT fjBitmap
Definition: winddi.h:1217
SIZEL sizlBitmap
Definition: winddi.h:1209
PVOID pvBits
Definition: winddi.h:1211
ULONG iBitmapFormat
Definition: winddi.h:1215
PVOID pvScan0
Definition: winddi.h:1212
HDEV hdev
Definition: winddi.h:1208
HSURF hsurf
Definition: winddi.h:1206
LONG lDelta
Definition: winddi.h:1213
ULONG cjBits
Definition: winddi.h:1210
ULONG biClrImportant
Definition: precomp.h:52
USHORT biBitCount
Definition: precomp.h:46
LONG biYPelsPerMeter
Definition: precomp.h:50
ULONG biCompression
Definition: precomp.h:47
LONG biXPelsPerMeter
Definition: precomp.h:49
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
RGBQUAD bmiColors[1]
Definition: wingdi.h:1477
LONG bmHeight
Definition: wingdi.h:1423
LONG bmWidth
Definition: wingdi.h:1422
WORD bmPlanes
Definition: wingdi.h:1425
WORD bmBitsPixel
Definition: wingdi.h:1426
DWORD dsBitfields[3]
Definition: wingdi.h:1671
DWORD dsOffset
Definition: wingdi.h:1673
HANDLE dshSection
Definition: wingdi.h:1672
BITMAP dsBm
Definition: wingdi.h:1669
BITMAPINFOHEADER dsBmih
Definition: wingdi.h:1670
UCHAR rgbReserved
Definition: bootanim.c:106
UCHAR rgbBlue
Definition: bootanim.c:103
UCHAR rgbRed
Definition: bootanim.c:105
UCHAR rgbGreen
Definition: bootanim.c:104
#define WIDTH_BYTES_ALIGN32(cx, bpp)
Definition: swimpl.c:16
#define WIDTH_BYTES_ALIGN16(cx, bpp)
Definition: swimpl.c:17
unsigned char * LPBYTE
Definition: typedefs.h:53
#define NTAPI
Definition: typedefs.h:36
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
#define IN
Definition: typedefs.h:39
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
#define OUT
Definition: typedefs.h:40
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
int ret
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
UCHAR gajBitsPerFormat[11]
Definition: surface.c:21
ULONG FASTCALL BitmapFormat(ULONG cBits, ULONG iCompression)
Definition: surface.c:39
PSURFACE NTAPI SURFACE_AllocSurface(_In_ USHORT iType, _In_ ULONG cx, _In_ ULONG cy, _In_ ULONG iFormat, _In_ ULONG fjBitmap, _In_opt_ ULONG cjWidth, _In_opt_ ULONG cjBufSize, _In_opt_ PVOID pvBits)
Definition: surface.c:116
#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
@ DDB_SURFACE
Definition: surface.h:73
#define SURFACE_ShareLockSurface(hBMObj)
Definition: surface.h:91
#define SURFACE_UnlockSurface(pBMObj)
Definition: surface.h:100
#define BitsPerFormat(Format)
Definition: surface.h:109
HBITMAP APIENTRY DIB_CreateDIBSection(PDC dc, CONST BITMAPINFO *bmi, UINT usage, LPVOID *bits, HANDLE section, DWORD offset, DWORD ovr_pitch)
Definition: dibobj.c:1912
BOOL NTAPI GreSetObjectOwner(HGDIOBJ hobj, ULONG ulOwner)
Definition: gdiobj.c:1255
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1158
ULONG NTAPI GreGetObjectOwner(HGDIOBJ hobj)
Definition: gdiobj.c:1192
VOID NTAPI GDIOBJ_vDeleteObject(POBJ pobj)
Definition: gdiobj.c:1111
@ PAL_RGB16_555
Definition: palette.h:27
#define PALETTE_ShareLockPalette(hpal)
Definition: palette.h:57
#define PALETTE_ShareUnlockPalette(ppal)
Definition: palette.h:59
#define BMF_16BPP
Definition: winddi.h:358
#define BMF_8BPP
Definition: winddi.h:357
#define STYPE_BITMAP
Definition: winddi.h:1175
#define BMF_1BPP
Definition: winddi.h:355
#define BMF_PNG
Definition: winddi.h:364
#define BMF_24BPP
Definition: winddi.h:359
#define BMF_TOPDOWN
Definition: winddi.h:1180
#define BMF_32BPP
Definition: winddi.h:360
#define PAL_BGR
Definition: winddi.h:1564
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:22
_In_ ULONG cjSize
Definition: winddi.h:3634
#define BMF_8RLE
Definition: winddi.h:362
#define BMF_4RLE
Definition: winddi.h:361
_In_ SIZEL _In_ ULONG iFormat
Definition: winddi.h:3468
#define BMF_4BPP
Definition: winddi.h:356
_In_ SIZEL sizl
Definition: winddi.h:3467
#define BMF_JPEG
Definition: winddi.h:363
#define DIB_RGB_COLORS
Definition: wingdi.h:367
struct tagDIBSECTION DIBSECTION
#define BI_JPEG
Definition: wingdi.h:38
#define BI_PNG
Definition: wingdi.h:39
#define BI_RLE8
Definition: wingdi.h:35
#define NT_ASSERT
Definition: rtlfuncs.h:3310
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned char BYTE
Definition: xxhash.c:193