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
);
77 IN OPTIONAL PVOID pvBits
)
82 PVOID pvCompressedBits
;
87 /* Calculate bitmap format */
88 iFormat
= BitmapFormat(cBitsPixel
* cPlanes
, BI_RGB
);
91 if (iFormat
< BMF_1BPP
|| iFormat
> BMF_PNG
) return NULL
;
93 /* Allocate a surface */
94 psurf
= SURFACE_AllocSurface(STYPE_BITMAP
, nWidth
, nHeight
, iFormat
);
97 DPRINT1("SURFACE_AllocSurface failed.\n");
101 /* Get the handle for the bitmap and the surfobj */
102 hbmp
= (HBITMAP
)psurf
->SurfObj
.hsurf
;
103 pso
= &psurf
->SurfObj
;
105 /* The infamous RLE hack */
106 if (iFormat
== BMF_4RLE
)
108 sizl
.cx
= nWidth
; sizl
.cy
= nHeight
;
109 pvCompressedBits
= pvBits
;
110 pvBits
= EngAllocMem(FL_ZERO_MEMORY
, pso
->cjBits
, TAG_DIB
);
111 Decompress4bpp(sizl
, pvCompressedBits
, pvBits
, pso
->lDelta
);
114 else if (iFormat
== BMF_8RLE
)
116 sizl
.cx
= nWidth
; sizl
.cy
= nHeight
;
117 pvCompressedBits
= pvBits
;
118 pvBits
= EngAllocMem(FL_ZERO_MEMORY
, pso
->cjBits
, TAG_DIB
);
119 Decompress8bpp(sizl
, pvCompressedBits
, pvBits
, pso
->lDelta
);
123 /* Set the bitmap bits */
124 if (!SURFACE_bSetBitmapBits(psurf
, fl
, 0, pvBits
))
126 /* Bail out if that failed */
127 DPRINT1("SURFACE_bSetBitmapBits failed.\n");
128 SURFACE_FreeSurfaceByHandle(hbmp
);
132 /* Mark as API bitmap */
133 psurf
->flags
|= API_BITMAP
;
135 /* Unlock the surface and return */
136 SURFACE_UnlockSurface(psurf
);
147 IN OPTIONAL LPBYTE pUnsafeBits
)
153 ULONG cjWidthBytes
, iFormat
;
155 /* NOTE: Windows also doesn't store nr. of planes separately! */
156 cBitsPixel
= BITMAP_GetRealBitsPixel(cBitsPixel
* cPlanes
);
158 /* Calculate bitmap format */
159 iFormat
= BitmapFormat(cBitsPixel
, BI_RGB
);
161 /* Check parameters */
162 if (iFormat
== 0 || nWidth
<= 0 || nWidth
>= 0x8000000 || nHeight
<= 0)
164 DPRINT1("Width = %d, Height = %d BitsPixel = %d\n",
165 nWidth
, nHeight
, cBitsPixel
);
166 EngSetLastError(ERROR_INVALID_PARAMETER
);
170 /* Make sure that cjBits will not overflow */
171 cjWidthBytes
= DIB_GetDIBWidthBytes(nWidth
, cBitsPixel
);
172 if ((ULONGLONG
)cjWidthBytes
* nHeight
>= 0x100000000ULL
)
174 DPRINT1("Width = %d, Height = %d BitsPixel = %d\n",
175 nWidth
, nHeight
, cBitsPixel
);
176 EngSetLastError(ERROR_INVALID_PARAMETER
);
180 /* Allocate a surface */
181 psurf
= SURFACE_AllocSurface(STYPE_BITMAP
, nWidth
, nHeight
, iFormat
);
184 DPRINT1("SURFACE_AllocSurface failed.\n");
185 EngSetLastError(ERROR_OUTOFMEMORY
);
189 /* Get the handle for the bitmap and the surfobj */
190 hbmp
= (HBITMAP
)psurf
->SurfObj
.hsurf
;
191 pso
= &psurf
->SurfObj
;
193 /* Allocate the bitmap bits */
194 if (!SURFACE_bSetBitmapBits(psurf
, fl
, 0, NULL
))
196 /* Bail out if that failed */
197 DPRINT1("SURFACE_bSetBitmapBits failed.\n");
198 SURFACE_FreeSurfaceByHandle(hbmp
);
206 ProbeForRead(pUnsafeBits
, cjWidthBytes
* nHeight
, 1);
207 UnsafeSetBitmapBits(psurf
, 0, pUnsafeBits
);
209 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
211 SURFACE_FreeSurfaceByHandle(hbmp
);
212 _SEH2_YIELD(return NULL
;)
217 /* Mark as API bitmap */
218 psurf
->flags
|= API_BITMAP
;
220 /* Unlock the surface and return */
221 SURFACE_UnlockSurface(psurf
);
227 IntCreateCompatibleBitmap(
234 /* MS doc says if width or height is 0, return 1-by-1 pixel, monochrome bitmap */
235 if (0 == Width
|| 0 == Height
)
237 Bmp
= NtGdiGetStockObject(DEFAULT_BITMAP
);
241 if (Dc
->dctype
!= DC_TYPE_MEMORY
)
246 size
.cx
= abs(Width
);
247 size
.cy
= abs(Height
);
248 Bmp
= GreCreateBitmap(abs(Width
),
251 Dc
->ppdev
->gdiinfo
.cBitsPixel
,
253 psurf
= SURFACE_LockSurface(Bmp
);
256 psurf
->ppal
= PALETTE_ShareLockPalette(Dc
->ppdev
->devinfo
.hpalDefault
);
258 psurf
->flags
= API_BITMAP
;
259 psurf
->hdc
= NULL
; // Fixme
260 SURFACE_UnlockSurface(psurf
);
266 PSURFACE psurf
= Dc
->dclevel
.pSurface
;
267 Count
= BITMAP_GetObject(psurf
, sizeof(dibs
), &dibs
);
271 if (Count
== sizeof(BITMAP
))
275 size
.cx
= abs(Width
);
276 size
.cy
= abs(Height
);
277 Bmp
= GreCreateBitmap(abs(Width
),
280 dibs
.dsBm
.bmBitsPixel
,
282 psurfBmp
= SURFACE_LockSurface(Bmp
);
285 psurfBmp
->ppal
= psurf
->ppal
;
286 GDIOBJ_IncrementShareCount((POBJ
)psurf
->ppal
);
288 psurfBmp
->flags
= API_BITMAP
;
289 psurfBmp
->hdc
= NULL
; // Fixme
290 SURFACE_UnlockSurface(psurfBmp
);
294 /* A DIB section is selected in the DC */
298 /* Allocate memory for a BITMAPINFOHEADER structure and a
299 color table. The maximum number of colors in a color table
300 is 256 which corresponds to a bitmap with depth 8.
301 Bitmaps with higher depths don't have color tables. */
302 bi
= ExAllocatePoolWithTag(PagedPool
,
303 sizeof(BITMAPINFOHEADER
) +
304 256 * sizeof(RGBQUAD
),
309 bi
->bmiHeader
.biSize
= sizeof(bi
->bmiHeader
);
310 bi
->bmiHeader
.biWidth
= Width
;
311 bi
->bmiHeader
.biHeight
= Height
;
312 bi
->bmiHeader
.biPlanes
= dibs
.dsBmih
.biPlanes
;
313 bi
->bmiHeader
.biBitCount
= dibs
.dsBmih
.biBitCount
;
314 bi
->bmiHeader
.biCompression
= dibs
.dsBmih
.biCompression
;
315 bi
->bmiHeader
.biSizeImage
= 0;
316 bi
->bmiHeader
.biXPelsPerMeter
= dibs
.dsBmih
.biXPelsPerMeter
;
317 bi
->bmiHeader
.biYPelsPerMeter
= dibs
.dsBmih
.biYPelsPerMeter
;
318 bi
->bmiHeader
.biClrUsed
= dibs
.dsBmih
.biClrUsed
;
319 bi
->bmiHeader
.biClrImportant
= dibs
.dsBmih
.biClrImportant
;
321 if (bi
->bmiHeader
.biCompression
== BI_BITFIELDS
)
323 /* Copy the color masks */
324 RtlCopyMemory(bi
->bmiColors
, dibs
.dsBitfields
, 3 * sizeof(DWORD
));
326 else if (bi
->bmiHeader
.biBitCount
<= 8)
328 /* Copy the color table */
334 ExFreePoolWithTag(bi
, TAG_TEMP
);
335 SetLastWin32Error(ERROR_INVALID_HANDLE
);
339 PalGDI
= PALETTE_LockPalette(psurf
->ppal
->BaseObject
.hHmgr
);
342 Index
< 256 && Index
< PalGDI
->NumColors
;
345 bi
->bmiColors
[Index
].rgbRed
= PalGDI
->IndexedColors
[Index
].peRed
;
346 bi
->bmiColors
[Index
].rgbGreen
= PalGDI
->IndexedColors
[Index
].peGreen
;
347 bi
->bmiColors
[Index
].rgbBlue
= PalGDI
->IndexedColors
[Index
].peBlue
;
348 bi
->bmiColors
[Index
].rgbReserved
= 0;
350 PALETTE_UnlockPalette(PalGDI
);
353 Bmp
= DIB_CreateDIBSection(Dc
,
361 ExFreePoolWithTag(bi
, TAG_TEMP
);
372 NtGdiCreateCompatibleBitmap(
380 if (Width
<= 0 || Height
<= 0 || (Width
* Height
) > 0x3FFFFFFF)
382 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
387 return GreCreateBitmap(Width
, Height
, 1, 1, 0);
391 DPRINT("NtGdiCreateCompatibleBitmap(%04x,%d,%d, bpp:%d) = \n",
392 hDC
, Width
, Height
, Dc
->ppdev
->gdiinfo
.cBitsPixel
);
396 SetLastWin32Error(ERROR_INVALID_HANDLE
);
400 Bmp
= IntCreateCompatibleBitmap(Dc
, Width
, Height
);
402 DPRINT("\t\t%04x\n", Bmp
);
408 NtGdiGetBitmapDimension(
418 psurfBmp
= SURFACE_LockSurface(hBitmap
);
419 if (psurfBmp
== NULL
)
421 SetLastWin32Error(ERROR_INVALID_HANDLE
);
427 ProbeForWrite(Dimension
, sizeof(SIZE
), 1);
428 *Dimension
= psurfBmp
->sizlDim
;
430 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
436 SURFACE_UnlockSurface(psurfBmp
);
442 NtGdiGetPixel(HDC hDC
, INT XPos
, INT YPos
)
445 COLORREF Result
= (COLORREF
)CLR_INVALID
; // default to failure
446 BOOL bInRect
= FALSE
;
457 SetLastWin32Error(ERROR_INVALID_HANDLE
);
461 if (dc
->dctype
== DC_TYPE_INFO
)
467 XPos
+= dc
->ptlDCOrig
.x
;
468 YPos
+= dc
->ptlDCOrig
.y
;
469 if (RECTL_bPointInRect(&dc
->rosdc
.CombinedClip
->rclBounds
, XPos
, YPos
))
472 psurf
= dc
->dclevel
.pSurface
;
475 pso
= &psurf
->SurfObj
;
479 GDIOBJ_IncrementShareCount(&ppal
->BaseObject
);
482 ppal
= PALETTE_ShareLockPalette(dc
->ppdev
->devinfo
.hpalDefault
);
484 if (psurf
->SurfObj
.iBitmapFormat
== BMF_1BPP
&& !psurf
->hSecure
)
486 /* FIXME: palette should be gpalMono already ! */
487 EXLATEOBJ_vInitialize(&exlo
, &gpalMono
, &gpalRGB
, 0, 0xffffff, 0);
491 EXLATEOBJ_vInitialize(&exlo
, ppal
, &gpalRGB
, 0, 0xffffff, 0);
494 // check if this DC has a DIB behind it...
495 if (pso
->pvScan0
) // STYPE_BITMAP == pso->iType
498 Result
= XLATEOBJ_iXlate(&exlo
.xlo
,
499 DibFunctionsForBitmapFormat
[pso
->iBitmapFormat
].DIB_GetPixel(pso
, XPos
, YPos
));
502 EXLATEOBJ_vCleanup(&exlo
);
503 PALETTE_ShareUnlockPalette(ppal
);
508 // if Result is still CLR_INVALID, then the "quick" method above didn't work
509 if (bInRect
&& Result
== CLR_INVALID
)
511 // FIXME: create a 1x1 32BPP DIB, and blit to it
512 HDC hDCTmp
= NtGdiCreateCompatibleDC(hDC
);
515 static const BITMAPINFOHEADER bih
= { sizeof(BITMAPINFOHEADER
), 1, 1, 1, 32, BI_RGB
, 0, 0, 0, 0, 0 };
517 RtlMoveMemory(&(bi
.bmiHeader
), &bih
, sizeof(bih
));
518 hBmpTmp
= NtGdiCreateDIBitmapInternal(hDC
,
519 bi
.bmiHeader
.biWidth
,
520 bi
.bmiHeader
.biHeight
,
525 bi
.bmiHeader
.biBitCount
,
526 bi
.bmiHeader
.biSizeImage
,
530 //HBITMAP hBmpTmp = GreCreateBitmap(1, 1, 1, 32, NULL);
533 HBITMAP hBmpOld
= (HBITMAP
)NtGdiSelectBitmap(hDCTmp
, hBmpTmp
);
538 NtGdiBitBlt(hDCTmp
, 0, 0, 1, 1, hDC
, XPos
, YPos
, SRCCOPY
, 0, 0);
539 NtGdiSelectBitmap(hDCTmp
, hBmpOld
);
541 // our bitmap is no longer selected, so we can access it's stuff...
542 psurf
= SURFACE_LockSurface(hBmpTmp
);
545 // Dont you need to convert something here?
546 Result
= *(COLORREF
*)psurf
->SurfObj
.pvScan0
;
547 SURFACE_UnlockSurface(psurf
);
550 GreDeleteObject(hBmpTmp
);
552 NtGdiDeleteObjectApp(hDCTmp
);
570 /* Don't copy more bytes than the buffer has */
571 Bytes
= min(Bytes
, psurf
->SurfObj
.cjBits
);
574 /* FIXME: Call DDI CopyBits here if available */
577 DPRINT("Calling device specific BitmapBits\n");
578 if (psurf
->DDBitmap
->funcs
->pBitmapBits
)
580 ret
= psurf
->DDBitmap
->funcs
->pBitmapBits(hbitmap
,
587 ERR_(bitmap
)("BitmapBits == NULL??\n");
594 RtlCopyMemory(Bits
, psurf
->SurfObj
.pvBits
, Bytes
);
604 OUT OPTIONAL PBYTE pUnsafeBits
)
609 if (pUnsafeBits
!= NULL
&& Bytes
== 0)
614 psurf
= SURFACE_LockSurface(hBitmap
);
617 SetLastWin32Error(ERROR_INVALID_HANDLE
);
621 bmSize
= BITMAP_GetWidthBytes(psurf
->SurfObj
.sizlBitmap
.cx
,
622 BitsPerFormat(psurf
->SurfObj
.iBitmapFormat
)) *
623 abs(psurf
->SurfObj
.sizlBitmap
.cy
);
625 /* If the bits vector is null, the function should return the read size */
626 if (pUnsafeBits
== NULL
)
628 SURFACE_UnlockSurface(psurf
);
632 /* Don't copy more bytes than the buffer has */
633 Bytes
= min(Bytes
, bmSize
);
635 // FIXME: use MmSecureVirtualMemory
638 ProbeForWrite(pUnsafeBits
, Bytes
, 1);
639 ret
= IntGetBitmapBits(psurf
, Bytes
, pUnsafeBits
);
641 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
647 SURFACE_UnlockSurface(psurf
);
657 IN PBYTE pUnsafeBits
)
662 if (pUnsafeBits
== NULL
|| Bytes
== 0)
667 psurf
= SURFACE_LockSurface(hBitmap
);
670 SetLastWin32Error(ERROR_INVALID_HANDLE
);
676 ProbeForRead(pUnsafeBits
, Bytes
, 1);
677 UnsafeSetBitmapBits(psurf
, Bytes
, pUnsafeBits
);
680 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
686 SURFACE_UnlockSurface(psurf
);
692 NtGdiSetBitmapDimension(
704 psurf
= SURFACE_LockSurface(hBitmap
);
707 SetLastWin32Error(ERROR_INVALID_HANDLE
);
715 ProbeForWrite(Size
, sizeof(SIZE
), 1);
716 *Size
= psurf
->sizlDim
;
718 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
725 /* The dimension is changed even if writing the old value failed */
726 psurf
->sizlDim
.cx
= Width
;
727 psurf
->sizlDim
.cy
= Height
;
729 SURFACE_UnlockSurface(psurf
);
734 VOID
IntHandleSpecialColorType(HDC hDC
, COLORREF
* Color
)
738 PALETTEENTRY palEntry
;
741 switch (*Color
>> 24)
743 case 0x10: /* DIBINDEX */
744 if (IntGetDIBColorTable(hDC
, LOWORD(*Color
), 1, &quad
) == 1)
746 *Color
= RGB(quad
.rgbRed
, quad
.rgbGreen
, quad
.rgbBlue
);
750 /* Out of color table bounds - use black */
751 *Color
= RGB(0, 0, 0);
754 case 0x02: /* PALETTERGB */
755 pdc
= DC_LockDc(hDC
);
756 if (pdc
->dclevel
.hpal
!= NtGdiGetStockObject(DEFAULT_PALETTE
))
758 index
= NtGdiGetNearestPaletteIndex(pdc
->dclevel
.hpal
, *Color
);
759 IntGetPaletteEntries(pdc
->dclevel
.hpal
, index
, 1, &palEntry
);
760 *Color
= RGB(palEntry
.peRed
, palEntry
.peGreen
, palEntry
.peBlue
);
764 /* Use the pure color */
765 *Color
= *Color
& 0x00FFFFFF;
769 case 0x01: /* PALETTEINDEX */
770 pdc
= DC_LockDc(hDC
);
771 if (IntGetPaletteEntries(pdc
->dclevel
.hpal
, LOWORD(*Color
), 1, &palEntry
) == 1)
773 *Color
= RGB(palEntry
.peRed
, palEntry
.peGreen
, palEntry
.peBlue
);
777 /* Index does not exist, use zero index */
778 IntGetPaletteEntries(pdc
->dclevel
.hpal
, 0, 1, &palEntry
);
779 *Color
= RGB(palEntry
.peRed
, palEntry
.peGreen
, palEntry
.peBlue
);
784 DPRINT("Unsupported color type %d passed\n", *Color
>> 24);
799 if ((Color
& 0xFF000000) != 0)
801 IntHandleSpecialColorType(hDC
, &Color
);
804 hBrush
= NtGdiCreateSolidBrush(Color
, NULL
);
808 OldBrush
= NtGdiSelectBrush(hDC
, hBrush
);
809 if (OldBrush
== NULL
)
811 GreDeleteObject(hBrush
);
815 NtGdiPatBlt(hDC
, X
, Y
, 1, 1, PATCOPY
);
816 NtGdiSelectBrush(hDC
, OldBrush
);
817 GreDeleteObject(hBrush
);
829 DPRINT("0 NtGdiSetPixel X %ld Y %ld C %ld\n", X
, Y
, Color
);
831 if (GdiSetPixelV(hDC
,X
,Y
,Color
))
833 Color
= NtGdiGetPixel(hDC
,X
,Y
);
834 DPRINT("1 NtGdiSetPixel X %ld Y %ld C %ld\n", X
, Y
, Color
);
838 Color
= (COLORREF
)CLR_INVALID
;
839 DPRINT("2 NtGdiSetPixel X %ld Y %ld C %ld\n", X
, Y
, Color
);
844 /* Internal Functions */
847 BITMAP_GetRealBitsPixel(UINT nBitsPixel
)
855 if (nBitsPixel
<= 16)
857 if (nBitsPixel
<= 24)
859 if (nBitsPixel
<= 32)
866 BITMAP_GetWidthBytes(INT bmWidth
, INT bpp
)
872 return 2 * ((bmWidth
+15) >> 4);
875 bmWidth
*= 3; /* fall through */
877 return bmWidth
+ (bmWidth
& 1);
887 return 2 * ((bmWidth
+3) >> 2);
896 return ((bmWidth
* bpp
+ 15) & ~15) >> 3;
900 BITMAP_CopyBitmap(HBITMAP hBitmap
)
904 SURFACE
*Bitmap
, *resBitmap
;
912 Bitmap
= GDIOBJ_LockObj(hBitmap
, GDI_OBJECT_TYPE_BITMAP
);
918 BITMAP_GetObject(Bitmap
, sizeof(BITMAP
), (PVOID
)&bm
);
920 if (Bitmap
->SurfObj
.lDelta
>= 0)
921 bm
.bmHeight
= -bm
.bmHeight
;
923 Size
.cx
= abs(bm
.bmWidth
);
924 Size
.cy
= abs(bm
.bmHeight
);
925 res
= GreCreateBitmap(abs(bm
.bmWidth
),
935 resBitmap
= GDIOBJ_LockObj(res
, GDI_OBJECT_TYPE_BITMAP
);
938 buf
= ExAllocatePoolWithTag(PagedPool
,
939 bm
.bmWidthBytes
* abs(bm
.bmHeight
),
943 GDIOBJ_UnlockObjByPtr((POBJ
)resBitmap
);
944 GDIOBJ_UnlockObjByPtr((POBJ
)Bitmap
);
945 GreDeleteObject(res
);
948 IntGetBitmapBits(Bitmap
, bm
.bmWidthBytes
* abs(bm
.bmHeight
), buf
);
949 IntSetBitmapBits(resBitmap
, bm
.bmWidthBytes
* abs(bm
.bmHeight
), buf
);
950 ExFreePoolWithTag(buf
,TAG_BITMAP
);
951 resBitmap
->flags
= Bitmap
->flags
;
955 resBitmap
->ppal
= Bitmap
->ppal
;
956 GDIOBJ_IncrementShareCount(&Bitmap
->ppal
->BaseObject
);
958 GDIOBJ_UnlockObjByPtr((POBJ
)resBitmap
);
962 GreDeleteObject(res
);
967 GDIOBJ_UnlockObjByPtr((POBJ
)Bitmap
);
973 BITMAP_GetObject(SURFACE
*psurf
, INT Count
, LPVOID buffer
)
977 if (!buffer
) return sizeof(BITMAP
);
978 if ((UINT
)Count
< sizeof(BITMAP
)) return 0;
980 /* always fill a basic BITMAP structure */
983 pBitmap
->bmWidth
= psurf
->SurfObj
.sizlBitmap
.cx
;
984 pBitmap
->bmHeight
= psurf
->SurfObj
.sizlBitmap
.cy
;
985 pBitmap
->bmWidthBytes
= abs(psurf
->SurfObj
.lDelta
);
986 pBitmap
->bmPlanes
= 1;
987 pBitmap
->bmBitsPixel
= BitsPerFormat(psurf
->SurfObj
.iBitmapFormat
);
989 /* Check for DIB section */
992 /* Set bmBits in this case */
993 pBitmap
->bmBits
= psurf
->SurfObj
.pvBits
;
995 if (Count
>= sizeof(DIBSECTION
))
997 /* Fill rest of DIBSECTION */
998 PDIBSECTION pds
= buffer
;
1000 pds
->dsBmih
.biSize
= sizeof(BITMAPINFOHEADER
);
1001 pds
->dsBmih
.biWidth
= pds
->dsBm
.bmWidth
;
1002 pds
->dsBmih
.biHeight
= pds
->dsBm
.bmHeight
;
1003 pds
->dsBmih
.biPlanes
= pds
->dsBm
.bmPlanes
;
1004 pds
->dsBmih
.biBitCount
= pds
->dsBm
.bmBitsPixel
;
1005 switch (psurf
->SurfObj
.iBitmapFormat
)
1007 /* FIXME: What about BI_BITFIELDS? */
1014 pds
->dsBmih
.biCompression
= BI_RGB
;
1017 pds
->dsBmih
.biCompression
= BI_RLE4
;
1020 pds
->dsBmih
.biCompression
= BI_RLE8
;
1023 pds
->dsBmih
.biCompression
= BI_JPEG
;
1026 pds
->dsBmih
.biCompression
= BI_PNG
;
1029 pds
->dsBmih
.biSizeImage
= psurf
->SurfObj
.cjBits
;
1030 pds
->dsBmih
.biXPelsPerMeter
= 0;
1031 pds
->dsBmih
.biYPelsPerMeter
= 0;
1032 pds
->dsBmih
.biClrUsed
= psurf
->biClrUsed
;
1033 pds
->dsBmih
.biClrImportant
= psurf
->biClrImportant
;
1034 pds
->dsBitfields
[0] = psurf
->dsBitfields
[0];
1035 pds
->dsBitfields
[1] = psurf
->dsBitfields
[1];
1036 pds
->dsBitfields
[2] = psurf
->dsBitfields
[2];
1037 pds
->dshSection
= psurf
->hDIBSection
;
1038 pds
->dsOffset
= psurf
->dwOffset
;
1040 return sizeof(DIBSECTION
);
1045 /* not set according to wine test, confirmed in win2k */
1046 pBitmap
->bmBits
= NULL
;
1049 return sizeof(BITMAP
);
1057 NtGdiGetDCforBitmap(
1061 PSURFACE psurf
= SURFACE_LockSurface(hsurf
);
1065 SURFACE_UnlockSurface(psurf
);