2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 /* Don't copy more bytes than the buffer has */
32 Bytes
= min(Bytes
, psurf
->SurfObj
.cjBits
);
34 RtlCopyMemory(psurf
->SurfObj
.pvBits
, Bits
, Bytes
);
47 LONG lDeltaDst
, lDeltaSrc
;
48 ULONG nWidth
, nHeight
, cBitsPixel
;
50 nWidth
= psurf
->SurfObj
.sizlBitmap
.cx
;
51 nHeight
= psurf
->SurfObj
.sizlBitmap
.cy
;
52 cBitsPixel
= BitsPerFormat(psurf
->SurfObj
.iBitmapFormat
);
55 pjDst
= psurf
->SurfObj
.pvScan0
;
57 lDeltaDst
= psurf
->SurfObj
.lDelta
;
58 lDeltaSrc
= BITMAP_GetWidthBytes(nWidth
, cBitsPixel
);
63 memcpy(pjDst
, pjSrc
, lDeltaSrc
);
75 IN ULONG cjWidthBytes
,
79 IN OPTIONAL PVOID pvBits
)
84 PVOID pvCompressedBits
;
89 if (iFormat
< BMF_1BPP
|| iFormat
> BMF_PNG
) return NULL
;
91 /* Allocate a surface */
92 psurf
= SURFACE_AllocSurface(STYPE_BITMAP
, nWidth
, nHeight
, iFormat
);
95 DPRINT1("SURFACE_AllocSurface failed.\n");
99 /* Get the handle for the bitmap and the surfobj */
100 hbmp
= (HBITMAP
)psurf
->SurfObj
.hsurf
;
101 pso
= &psurf
->SurfObj
;
103 /* The infamous RLE hack */
104 if (iFormat
== BMF_4RLE
)
106 sizl
.cx
= nWidth
; sizl
.cy
= nHeight
;
107 pvCompressedBits
= pvBits
;
108 pvBits
= EngAllocMem(FL_ZERO_MEMORY
, pso
->cjBits
, TAG_DIB
);
109 Decompress4bpp(sizl
, pvCompressedBits
, pvBits
, pso
->lDelta
);
112 else if (iFormat
== BMF_8RLE
)
114 sizl
.cx
= nWidth
; sizl
.cy
= nHeight
;
115 pvCompressedBits
= pvBits
;
116 pvBits
= EngAllocMem(FL_ZERO_MEMORY
, pso
->cjBits
, TAG_DIB
);
117 Decompress8bpp(sizl
, pvCompressedBits
, pvBits
, pso
->lDelta
);
121 /* Set the bitmap bits */
122 if (!SURFACE_bSetBitmapBits(psurf
, fjBitmap
, cjWidthBytes
, pvBits
))
124 /* Bail out if that failed */
125 DPRINT1("SURFACE_bSetBitmapBits failed.\n");
126 SURFACE_FreeSurfaceByHandle(hbmp
);
130 /* Mark as API bitmap */
131 psurf
->flags
|= API_BITMAP
;
133 /* Unlock the surface and return */
134 SURFACE_UnlockSurface(psurf
);
145 IN OPTIONAL PVOID pvBits
)
147 /* Call the extended function */
148 return GreCreateBitmapEx(nWidth
,
151 BitmapFormat(cBitsPixel
* cPlanes
, BI_RGB
),
152 0, /* no bitmap flags */
164 IN OPTIONAL LPBYTE pUnsafeBits
)
170 ULONG cjWidthBytes
, iFormat
;
172 /* NOTE: Windows also doesn't store nr. of planes separately! */
173 cBitsPixel
= BITMAP_GetRealBitsPixel(cBitsPixel
* cPlanes
);
175 /* Calculate bitmap format */
176 iFormat
= BitmapFormat(cBitsPixel
, BI_RGB
);
178 /* Check parameters */
179 if (iFormat
== 0 || nWidth
<= 0 || nWidth
>= 0x8000000 || nHeight
<= 0)
181 DPRINT1("Width = %d, Height = %d BitsPixel = %d\n",
182 nWidth
, nHeight
, cBitsPixel
);
183 EngSetLastError(ERROR_INVALID_PARAMETER
);
187 /* Make sure that cjBits will not overflow */
188 cjWidthBytes
= DIB_GetDIBWidthBytes(nWidth
, cBitsPixel
);
189 if ((ULONGLONG
)cjWidthBytes
* nHeight
>= 0x100000000ULL
)
191 DPRINT1("Width = %d, Height = %d BitsPixel = %d\n",
192 nWidth
, nHeight
, cBitsPixel
);
193 EngSetLastError(ERROR_INVALID_PARAMETER
);
197 /* Allocate a surface */
198 psurf
= SURFACE_AllocSurface(STYPE_BITMAP
, nWidth
, nHeight
, iFormat
);
201 DPRINT1("SURFACE_AllocSurface failed.\n");
202 EngSetLastError(ERROR_OUTOFMEMORY
);
206 /* Get the handle for the bitmap and the surfobj */
207 hbmp
= (HBITMAP
)psurf
->SurfObj
.hsurf
;
208 pso
= &psurf
->SurfObj
;
210 /* Allocate the bitmap bits */
211 if (!SURFACE_bSetBitmapBits(psurf
, fl
, 0, NULL
))
213 /* Bail out if that failed */
214 DPRINT1("SURFACE_bSetBitmapBits failed.\n");
215 SURFACE_FreeSurfaceByHandle(hbmp
);
223 ProbeForRead(pUnsafeBits
, cjWidthBytes
* nHeight
, 1);
224 UnsafeSetBitmapBits(psurf
, 0, pUnsafeBits
);
226 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
228 SURFACE_FreeSurfaceByHandle(hbmp
);
229 _SEH2_YIELD(return NULL
;)
234 /* Mark as API bitmap */
235 psurf
->flags
|= API_BITMAP
;
237 /* Unlock the surface and return */
238 SURFACE_UnlockSurface(psurf
);
244 IntCreateCompatibleBitmap(
251 /* MS doc says if width or height is 0, return 1-by-1 pixel, monochrome bitmap */
252 if (0 == Width
|| 0 == Height
)
254 Bmp
= NtGdiGetStockObject(DEFAULT_BITMAP
);
258 if (Dc
->dctype
!= DC_TYPE_MEMORY
)
263 size
.cx
= abs(Width
);
264 size
.cy
= abs(Height
);
265 Bmp
= GreCreateBitmap(abs(Width
),
268 Dc
->ppdev
->gdiinfo
.cBitsPixel
,
270 psurf
= SURFACE_LockSurface(Bmp
);
273 psurf
->ppal
= PALETTE_ShareLockPalette(Dc
->ppdev
->devinfo
.hpalDefault
);
275 psurf
->flags
= API_BITMAP
;
276 psurf
->hdc
= NULL
; // Fixme
277 SURFACE_UnlockSurface(psurf
);
283 PSURFACE psurf
= Dc
->dclevel
.pSurface
;
284 Count
= BITMAP_GetObject(psurf
, sizeof(dibs
), &dibs
);
288 if (Count
== sizeof(BITMAP
))
292 size
.cx
= abs(Width
);
293 size
.cy
= abs(Height
);
294 Bmp
= GreCreateBitmap(abs(Width
),
297 dibs
.dsBm
.bmBitsPixel
,
299 psurfBmp
= SURFACE_LockSurface(Bmp
);
302 psurfBmp
->ppal
= psurf
->ppal
;
303 GDIOBJ_IncrementShareCount((POBJ
)psurf
->ppal
);
305 psurfBmp
->flags
= API_BITMAP
;
306 psurfBmp
->hdc
= NULL
; // Fixme
307 SURFACE_UnlockSurface(psurfBmp
);
311 /* A DIB section is selected in the DC */
315 RtlZeroMemory(&bi
.bmiHeader
, sizeof(bi
.bmiHeader
));
316 bi
.bmiHeader
.bV5Size
= sizeof(bi
.bmiHeader
);
317 bi
.bmiHeader
.bV5Width
= Width
;
318 bi
.bmiHeader
.bV5Height
= Height
;
319 bi
.bmiHeader
.bV5Planes
= dibs
.dsBmih
.biPlanes
;
320 bi
.bmiHeader
.bV5BitCount
= dibs
.dsBmih
.biBitCount
;
321 bi
.bmiHeader
.bV5Compression
= dibs
.dsBmih
.biCompression
;
322 bi
.bmiHeader
.bV5SizeImage
= 0;
323 bi
.bmiHeader
.bV5XPelsPerMeter
= dibs
.dsBmih
.biXPelsPerMeter
;
324 bi
.bmiHeader
.bV5YPelsPerMeter
= dibs
.dsBmih
.biYPelsPerMeter
;
325 bi
.bmiHeader
.bV5ClrUsed
= dibs
.dsBmih
.biClrUsed
;
326 bi
.bmiHeader
.bV5ClrImportant
= dibs
.dsBmih
.biClrImportant
;
328 if (bi
.bmiHeader
.bV5Compression
== BI_BITFIELDS
)
330 /* Copy the color masks */
331 bi
.bmiHeader
.bV5RedMask
= dibs
.dsBitfields
[0];
332 bi
.bmiHeader
.bV5GreenMask
= dibs
.dsBitfields
[1];
333 bi
.bmiHeader
.bV5BlueMask
= dibs
.dsBitfields
[2];
335 else if (bi
.bmiHeader
.bV5BitCount
<= 8)
337 /* Copy the color table */
343 SetLastWin32Error(ERROR_INVALID_HANDLE
);
347 PalGDI
= PALETTE_LockPalette(psurf
->ppal
->BaseObject
.hHmgr
);
350 Index
< 256 && Index
< PalGDI
->NumColors
;
353 bi
.bmiColors
[Index
].rgbRed
= PalGDI
->IndexedColors
[Index
].peRed
;
354 bi
.bmiColors
[Index
].rgbGreen
= PalGDI
->IndexedColors
[Index
].peGreen
;
355 bi
.bmiColors
[Index
].rgbBlue
= PalGDI
->IndexedColors
[Index
].peBlue
;
356 bi
.bmiColors
[Index
].rgbReserved
= 0;
358 PALETTE_UnlockPalette(PalGDI
);
360 Bmp
= DIB_CreateDIBSection(Dc
,
377 NtGdiCreateCompatibleBitmap(
385 if (Width
<= 0 || Height
<= 0 || (Width
* Height
) > 0x3FFFFFFF)
387 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
392 return GreCreateBitmap(Width
, Height
, 1, 1, 0);
396 DPRINT("NtGdiCreateCompatibleBitmap(%04x,%d,%d, bpp:%d) = \n",
397 hDC
, Width
, Height
, Dc
->ppdev
->gdiinfo
.cBitsPixel
);
401 SetLastWin32Error(ERROR_INVALID_HANDLE
);
405 Bmp
= IntCreateCompatibleBitmap(Dc
, Width
, Height
);
407 DPRINT("\t\t%04x\n", Bmp
);
413 NtGdiGetBitmapDimension(
423 psurfBmp
= SURFACE_LockSurface(hBitmap
);
424 if (psurfBmp
== NULL
)
426 SetLastWin32Error(ERROR_INVALID_HANDLE
);
432 ProbeForWrite(Dimension
, sizeof(SIZE
), 1);
433 *Dimension
= psurfBmp
->sizlDim
;
435 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
441 SURFACE_UnlockSurface(psurfBmp
);
447 NtGdiGetPixel(HDC hDC
, INT XPos
, INT YPos
)
450 COLORREF Result
= (COLORREF
)CLR_INVALID
; // default to failure
451 BOOL bInRect
= FALSE
;
462 SetLastWin32Error(ERROR_INVALID_HANDLE
);
466 if (dc
->dctype
== DC_TYPE_INFO
)
472 XPos
+= dc
->ptlDCOrig
.x
;
473 YPos
+= dc
->ptlDCOrig
.y
;
474 if (RECTL_bPointInRect(&dc
->rosdc
.CombinedClip
->rclBounds
, XPos
, YPos
))
477 psurf
= dc
->dclevel
.pSurface
;
480 pso
= &psurf
->SurfObj
;
484 GDIOBJ_IncrementShareCount(&ppal
->BaseObject
);
487 ppal
= PALETTE_ShareLockPalette(dc
->ppdev
->devinfo
.hpalDefault
);
489 if (psurf
->SurfObj
.iBitmapFormat
== BMF_1BPP
&& !psurf
->hSecure
)
491 /* FIXME: palette should be gpalMono already ! */
492 EXLATEOBJ_vInitialize(&exlo
, &gpalMono
, &gpalRGB
, 0, 0xffffff, 0);
496 EXLATEOBJ_vInitialize(&exlo
, ppal
, &gpalRGB
, 0, 0xffffff, 0);
499 // check if this DC has a DIB behind it...
500 if (pso
->pvScan0
) // STYPE_BITMAP == pso->iType
503 Result
= XLATEOBJ_iXlate(&exlo
.xlo
,
504 DibFunctionsForBitmapFormat
[pso
->iBitmapFormat
].DIB_GetPixel(pso
, XPos
, YPos
));
507 EXLATEOBJ_vCleanup(&exlo
);
508 PALETTE_ShareUnlockPalette(ppal
);
513 // if Result is still CLR_INVALID, then the "quick" method above didn't work
514 if (bInRect
&& Result
== CLR_INVALID
)
516 // FIXME: create a 1x1 32BPP DIB, and blit to it
517 HDC hDCTmp
= NtGdiCreateCompatibleDC(hDC
);
520 static const BITMAPINFOHEADER bih
= { sizeof(BITMAPINFOHEADER
), 1, 1, 1, 32, BI_RGB
, 0, 0, 0, 0, 0 };
522 RtlMoveMemory(&(bi
.bmiHeader
), &bih
, sizeof(bih
));
523 hBmpTmp
= NtGdiCreateDIBitmapInternal(hDC
,
524 bi
.bmiHeader
.biWidth
,
525 bi
.bmiHeader
.biHeight
,
530 bi
.bmiHeader
.biBitCount
,
531 bi
.bmiHeader
.biSizeImage
,
535 //HBITMAP hBmpTmp = GreCreateBitmap(1, 1, 1, 32, NULL);
538 HBITMAP hBmpOld
= (HBITMAP
)NtGdiSelectBitmap(hDCTmp
, hBmpTmp
);
543 NtGdiBitBlt(hDCTmp
, 0, 0, 1, 1, hDC
, XPos
, YPos
, SRCCOPY
, 0, 0);
544 NtGdiSelectBitmap(hDCTmp
, hBmpOld
);
546 // our bitmap is no longer selected, so we can access it's stuff...
547 psurf
= SURFACE_LockSurface(hBmpTmp
);
550 // Dont you need to convert something here?
551 Result
= *(COLORREF
*)psurf
->SurfObj
.pvScan0
;
552 SURFACE_UnlockSurface(psurf
);
555 GreDeleteObject(hBmpTmp
);
557 NtGdiDeleteObjectApp(hDCTmp
);
575 /* Don't copy more bytes than the buffer has */
576 Bytes
= min(Bytes
, psurf
->SurfObj
.cjBits
);
579 /* FIXME: Call DDI CopyBits here if available */
582 DPRINT("Calling device specific BitmapBits\n");
583 if (psurf
->DDBitmap
->funcs
->pBitmapBits
)
585 ret
= psurf
->DDBitmap
->funcs
->pBitmapBits(hbitmap
,
592 ERR_(bitmap
)("BitmapBits == NULL??\n");
599 RtlCopyMemory(Bits
, psurf
->SurfObj
.pvBits
, Bytes
);
609 OUT OPTIONAL PBYTE pUnsafeBits
)
614 if (pUnsafeBits
!= NULL
&& Bytes
== 0)
619 psurf
= SURFACE_LockSurface(hBitmap
);
622 SetLastWin32Error(ERROR_INVALID_HANDLE
);
626 bmSize
= BITMAP_GetWidthBytes(psurf
->SurfObj
.sizlBitmap
.cx
,
627 BitsPerFormat(psurf
->SurfObj
.iBitmapFormat
)) *
628 abs(psurf
->SurfObj
.sizlBitmap
.cy
);
630 /* If the bits vector is null, the function should return the read size */
631 if (pUnsafeBits
== NULL
)
633 SURFACE_UnlockSurface(psurf
);
637 /* Don't copy more bytes than the buffer has */
638 Bytes
= min(Bytes
, bmSize
);
640 // FIXME: use MmSecureVirtualMemory
643 ProbeForWrite(pUnsafeBits
, Bytes
, 1);
644 ret
= IntGetBitmapBits(psurf
, Bytes
, pUnsafeBits
);
646 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
652 SURFACE_UnlockSurface(psurf
);
662 IN PBYTE pUnsafeBits
)
667 if (pUnsafeBits
== NULL
|| Bytes
== 0)
672 psurf
= SURFACE_LockSurface(hBitmap
);
675 SetLastWin32Error(ERROR_INVALID_HANDLE
);
681 ProbeForRead(pUnsafeBits
, Bytes
, 1);
682 UnsafeSetBitmapBits(psurf
, Bytes
, pUnsafeBits
);
685 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
691 SURFACE_UnlockSurface(psurf
);
697 NtGdiSetBitmapDimension(
709 psurf
= SURFACE_LockSurface(hBitmap
);
712 SetLastWin32Error(ERROR_INVALID_HANDLE
);
720 ProbeForWrite(Size
, sizeof(SIZE
), 1);
721 *Size
= psurf
->sizlDim
;
723 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
730 /* The dimension is changed even if writing the old value failed */
731 psurf
->sizlDim
.cx
= Width
;
732 psurf
->sizlDim
.cy
= Height
;
734 SURFACE_UnlockSurface(psurf
);
739 VOID
IntHandleSpecialColorType(HDC hDC
, COLORREF
* Color
)
743 PALETTEENTRY palEntry
;
746 switch (*Color
>> 24)
748 case 0x10: /* DIBINDEX */
749 if (IntGetDIBColorTable(hDC
, LOWORD(*Color
), 1, &quad
) == 1)
751 *Color
= RGB(quad
.rgbRed
, quad
.rgbGreen
, quad
.rgbBlue
);
755 /* Out of color table bounds - use black */
756 *Color
= RGB(0, 0, 0);
759 case 0x02: /* PALETTERGB */
760 pdc
= DC_LockDc(hDC
);
761 if (pdc
->dclevel
.hpal
!= NtGdiGetStockObject(DEFAULT_PALETTE
))
763 index
= NtGdiGetNearestPaletteIndex(pdc
->dclevel
.hpal
, *Color
);
764 IntGetPaletteEntries(pdc
->dclevel
.hpal
, index
, 1, &palEntry
);
765 *Color
= RGB(palEntry
.peRed
, palEntry
.peGreen
, palEntry
.peBlue
);
769 /* Use the pure color */
770 *Color
= *Color
& 0x00FFFFFF;
774 case 0x01: /* PALETTEINDEX */
775 pdc
= DC_LockDc(hDC
);
776 if (IntGetPaletteEntries(pdc
->dclevel
.hpal
, LOWORD(*Color
), 1, &palEntry
) == 1)
778 *Color
= RGB(palEntry
.peRed
, palEntry
.peGreen
, palEntry
.peBlue
);
782 /* Index does not exist, use zero index */
783 IntGetPaletteEntries(pdc
->dclevel
.hpal
, 0, 1, &palEntry
);
784 *Color
= RGB(palEntry
.peRed
, palEntry
.peGreen
, palEntry
.peBlue
);
789 DPRINT("Unsupported color type %d passed\n", *Color
>> 24);
804 if ((Color
& 0xFF000000) != 0)
806 IntHandleSpecialColorType(hDC
, &Color
);
809 hBrush
= NtGdiCreateSolidBrush(Color
, NULL
);
813 OldBrush
= NtGdiSelectBrush(hDC
, hBrush
);
814 if (OldBrush
== NULL
)
816 GreDeleteObject(hBrush
);
820 NtGdiPatBlt(hDC
, X
, Y
, 1, 1, PATCOPY
);
821 NtGdiSelectBrush(hDC
, OldBrush
);
822 GreDeleteObject(hBrush
);
834 DPRINT("0 NtGdiSetPixel X %ld Y %ld C %ld\n", X
, Y
, Color
);
836 if (GdiSetPixelV(hDC
,X
,Y
,Color
))
838 Color
= NtGdiGetPixel(hDC
,X
,Y
);
839 DPRINT("1 NtGdiSetPixel X %ld Y %ld C %ld\n", X
, Y
, Color
);
843 Color
= (COLORREF
)CLR_INVALID
;
844 DPRINT("2 NtGdiSetPixel X %ld Y %ld C %ld\n", X
, Y
, Color
);
849 /* Internal Functions */
852 BITMAP_GetRealBitsPixel(UINT nBitsPixel
)
860 if (nBitsPixel
<= 16)
862 if (nBitsPixel
<= 24)
864 if (nBitsPixel
<= 32)
871 BITMAP_GetWidthBytes(INT bmWidth
, INT bpp
)
877 return 2 * ((bmWidth
+15) >> 4);
880 bmWidth
*= 3; /* fall through */
882 return bmWidth
+ (bmWidth
& 1);
892 return 2 * ((bmWidth
+3) >> 2);
901 return ((bmWidth
* bpp
+ 15) & ~15) >> 3;
905 BITMAP_CopyBitmap(HBITMAP hBitmap
)
909 SURFACE
*Bitmap
, *resBitmap
;
917 Bitmap
= GDIOBJ_LockObj(hBitmap
, GDI_OBJECT_TYPE_BITMAP
);
923 BITMAP_GetObject(Bitmap
, sizeof(BITMAP
), (PVOID
)&bm
);
925 if (Bitmap
->SurfObj
.lDelta
>= 0)
926 bm
.bmHeight
= -bm
.bmHeight
;
928 Size
.cx
= abs(bm
.bmWidth
);
929 Size
.cy
= abs(bm
.bmHeight
);
930 res
= GreCreateBitmap(abs(bm
.bmWidth
),
940 resBitmap
= GDIOBJ_LockObj(res
, GDI_OBJECT_TYPE_BITMAP
);
943 buf
= ExAllocatePoolWithTag(PagedPool
,
944 bm
.bmWidthBytes
* abs(bm
.bmHeight
),
948 GDIOBJ_UnlockObjByPtr((POBJ
)resBitmap
);
949 GDIOBJ_UnlockObjByPtr((POBJ
)Bitmap
);
950 GreDeleteObject(res
);
953 IntGetBitmapBits(Bitmap
, bm
.bmWidthBytes
* abs(bm
.bmHeight
), buf
);
954 IntSetBitmapBits(resBitmap
, bm
.bmWidthBytes
* abs(bm
.bmHeight
), buf
);
955 ExFreePoolWithTag(buf
,TAG_BITMAP
);
956 resBitmap
->flags
= Bitmap
->flags
;
960 resBitmap
->ppal
= Bitmap
->ppal
;
961 GDIOBJ_IncrementShareCount(&Bitmap
->ppal
->BaseObject
);
963 GDIOBJ_UnlockObjByPtr((POBJ
)resBitmap
);
967 GreDeleteObject(res
);
972 GDIOBJ_UnlockObjByPtr((POBJ
)Bitmap
);
978 BITMAP_GetObject(SURFACE
*psurf
, INT Count
, LPVOID buffer
)
982 if (!buffer
) return sizeof(BITMAP
);
983 if ((UINT
)Count
< sizeof(BITMAP
)) return 0;
985 /* always fill a basic BITMAP structure */
988 pBitmap
->bmWidth
= psurf
->SurfObj
.sizlBitmap
.cx
;
989 pBitmap
->bmHeight
= psurf
->SurfObj
.sizlBitmap
.cy
;
990 pBitmap
->bmWidthBytes
= abs(psurf
->SurfObj
.lDelta
);
991 pBitmap
->bmPlanes
= 1;
992 pBitmap
->bmBitsPixel
= BitsPerFormat(psurf
->SurfObj
.iBitmapFormat
);
994 /* Check for DIB section */
997 /* Set bmBits in this case */
998 pBitmap
->bmBits
= psurf
->SurfObj
.pvBits
;
1000 if (Count
>= sizeof(DIBSECTION
))
1002 /* Fill rest of DIBSECTION */
1003 PDIBSECTION pds
= buffer
;
1005 pds
->dsBmih
.biSize
= sizeof(BITMAPINFOHEADER
);
1006 pds
->dsBmih
.biWidth
= pds
->dsBm
.bmWidth
;
1007 pds
->dsBmih
.biHeight
= pds
->dsBm
.bmHeight
;
1008 pds
->dsBmih
.biPlanes
= pds
->dsBm
.bmPlanes
;
1009 pds
->dsBmih
.biBitCount
= pds
->dsBm
.bmBitsPixel
;
1010 switch (psurf
->SurfObj
.iBitmapFormat
)
1012 /* FIXME: What about BI_BITFIELDS? */
1019 pds
->dsBmih
.biCompression
= BI_RGB
;
1022 pds
->dsBmih
.biCompression
= BI_RLE4
;
1025 pds
->dsBmih
.biCompression
= BI_RLE8
;
1028 pds
->dsBmih
.biCompression
= BI_JPEG
;
1031 pds
->dsBmih
.biCompression
= BI_PNG
;
1034 pds
->dsBmih
.biSizeImage
= psurf
->SurfObj
.cjBits
;
1035 pds
->dsBmih
.biXPelsPerMeter
= 0;
1036 pds
->dsBmih
.biYPelsPerMeter
= 0;
1037 pds
->dsBmih
.biClrUsed
= psurf
->biClrUsed
;
1038 pds
->dsBmih
.biClrImportant
= psurf
->biClrImportant
;
1039 pds
->dsBitfields
[0] = psurf
->dsBitfields
[0];
1040 pds
->dsBitfields
[1] = psurf
->dsBitfields
[1];
1041 pds
->dsBitfields
[2] = psurf
->dsBitfields
[2];
1042 pds
->dshSection
= psurf
->hDIBSection
;
1043 pds
->dsOffset
= psurf
->dwOffset
;
1045 return sizeof(DIBSECTION
);
1050 /* not set according to wine test, confirmed in win2k */
1051 pBitmap
->bmBits
= NULL
;
1054 return sizeof(BITMAP
);
1062 NtGdiGetDCforBitmap(
1066 PSURFACE psurf
= SURFACE_LockSurface(hsurf
);
1070 SURFACE_UnlockSurface(psurf
);