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 */
312 BYTE buf
[sizeof(BITMAPINFOHEADER
) + 256*sizeof(RGBQUAD
)] = {0};
314 BITMAPINFO
* bi
= (BITMAPINFO
*)buf
;
316 bi
->bmiHeader
.biSize
= sizeof(bi
->bmiHeader
);
317 bi
->bmiHeader
.biWidth
= Width
;
318 bi
->bmiHeader
.biHeight
= Height
;
319 bi
->bmiHeader
.biPlanes
= dibs
.dsBmih
.biPlanes
;
320 bi
->bmiHeader
.biBitCount
= dibs
.dsBmih
.biBitCount
;
321 bi
->bmiHeader
.biCompression
= dibs
.dsBmih
.biCompression
;
322 bi
->bmiHeader
.biSizeImage
= 0;
323 bi
->bmiHeader
.biXPelsPerMeter
= dibs
.dsBmih
.biXPelsPerMeter
;
324 bi
->bmiHeader
.biYPelsPerMeter
= dibs
.dsBmih
.biYPelsPerMeter
;
325 bi
->bmiHeader
.biClrUsed
= dibs
.dsBmih
.biClrUsed
;
326 bi
->bmiHeader
.biClrImportant
= dibs
.dsBmih
.biClrImportant
;
328 if (bi
->bmiHeader
.biCompression
== BI_BITFIELDS
)
330 /* Copy the color masks */
331 RtlCopyMemory(bi
->bmiColors
, dibs
.dsBitfields
, 3*sizeof(RGBQUAD
));
333 else if (bi
->bmiHeader
.biBitCount
<= 8)
335 /* Copy the color table */
341 SetLastWin32Error(ERROR_INVALID_HANDLE
);
345 PalGDI
= PALETTE_LockPalette(psurf
->ppal
->BaseObject
.hHmgr
);
348 Index
< 256 && Index
< PalGDI
->NumColors
;
351 bi
->bmiColors
[Index
].rgbRed
= PalGDI
->IndexedColors
[Index
].peRed
;
352 bi
->bmiColors
[Index
].rgbGreen
= PalGDI
->IndexedColors
[Index
].peGreen
;
353 bi
->bmiColors
[Index
].rgbBlue
= PalGDI
->IndexedColors
[Index
].peBlue
;
354 bi
->bmiColors
[Index
].rgbReserved
= 0;
356 PALETTE_UnlockPalette(PalGDI
);
358 Bmp
= DIB_CreateDIBSection(Dc
,
375 NtGdiCreateCompatibleBitmap(
383 if (Width
<= 0 || Height
<= 0 || (Width
* Height
) > 0x3FFFFFFF)
385 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
390 return GreCreateBitmap(Width
, Height
, 1, 1, 0);
394 DPRINT("NtGdiCreateCompatibleBitmap(%04x,%d,%d, bpp:%d) = \n",
395 hDC
, Width
, Height
, Dc
->ppdev
->gdiinfo
.cBitsPixel
);
399 SetLastWin32Error(ERROR_INVALID_HANDLE
);
403 Bmp
= IntCreateCompatibleBitmap(Dc
, Width
, Height
);
405 DPRINT("\t\t%04x\n", Bmp
);
411 NtGdiGetBitmapDimension(
421 psurfBmp
= SURFACE_LockSurface(hBitmap
);
422 if (psurfBmp
== NULL
)
424 SetLastWin32Error(ERROR_INVALID_HANDLE
);
430 ProbeForWrite(Dimension
, sizeof(SIZE
), 1);
431 *Dimension
= psurfBmp
->sizlDim
;
433 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
439 SURFACE_UnlockSurface(psurfBmp
);
445 NtGdiGetPixel(HDC hDC
, INT XPos
, INT YPos
)
448 COLORREF Result
= (COLORREF
)CLR_INVALID
; // default to failure
449 BOOL bInRect
= FALSE
;
460 SetLastWin32Error(ERROR_INVALID_HANDLE
);
464 if (dc
->dctype
== DC_TYPE_INFO
)
470 XPos
+= dc
->ptlDCOrig
.x
;
471 YPos
+= dc
->ptlDCOrig
.y
;
472 if (RECTL_bPointInRect(&dc
->rosdc
.CombinedClip
->rclBounds
, XPos
, YPos
))
475 psurf
= dc
->dclevel
.pSurface
;
478 pso
= &psurf
->SurfObj
;
482 GDIOBJ_IncrementShareCount(&ppal
->BaseObject
);
485 ppal
= PALETTE_ShareLockPalette(dc
->ppdev
->devinfo
.hpalDefault
);
487 if (psurf
->SurfObj
.iBitmapFormat
== BMF_1BPP
&& !psurf
->hSecure
)
489 /* FIXME: palette should be gpalMono already ! */
490 EXLATEOBJ_vInitialize(&exlo
, &gpalMono
, &gpalRGB
, 0, 0xffffff, 0);
494 EXLATEOBJ_vInitialize(&exlo
, ppal
, &gpalRGB
, 0, 0xffffff, 0);
497 // check if this DC has a DIB behind it...
498 if (pso
->pvScan0
) // STYPE_BITMAP == pso->iType
501 Result
= XLATEOBJ_iXlate(&exlo
.xlo
,
502 DibFunctionsForBitmapFormat
[pso
->iBitmapFormat
].DIB_GetPixel(pso
, XPos
, YPos
));
505 EXLATEOBJ_vCleanup(&exlo
);
506 PALETTE_ShareUnlockPalette(ppal
);
511 // if Result is still CLR_INVALID, then the "quick" method above didn't work
512 if (bInRect
&& Result
== CLR_INVALID
)
514 // FIXME: create a 1x1 32BPP DIB, and blit to it
515 HDC hDCTmp
= NtGdiCreateCompatibleDC(hDC
);
518 static const BITMAPINFOHEADER bih
= { sizeof(BITMAPINFOHEADER
), 1, 1, 1, 32, BI_RGB
, 0, 0, 0, 0, 0 };
520 RtlMoveMemory(&(bi
.bmiHeader
), &bih
, sizeof(bih
));
521 hBmpTmp
= NtGdiCreateDIBitmapInternal(hDC
,
522 bi
.bmiHeader
.biWidth
,
523 bi
.bmiHeader
.biHeight
,
528 bi
.bmiHeader
.biBitCount
,
529 bi
.bmiHeader
.biSizeImage
,
533 //HBITMAP hBmpTmp = GreCreateBitmap(1, 1, 1, 32, NULL);
536 HBITMAP hBmpOld
= (HBITMAP
)NtGdiSelectBitmap(hDCTmp
, hBmpTmp
);
541 NtGdiBitBlt(hDCTmp
, 0, 0, 1, 1, hDC
, XPos
, YPos
, SRCCOPY
, 0, 0);
542 NtGdiSelectBitmap(hDCTmp
, hBmpOld
);
544 // our bitmap is no longer selected, so we can access it's stuff...
545 psurf
= SURFACE_LockSurface(hBmpTmp
);
548 // Dont you need to convert something here?
549 Result
= *(COLORREF
*)psurf
->SurfObj
.pvScan0
;
550 SURFACE_UnlockSurface(psurf
);
553 GreDeleteObject(hBmpTmp
);
555 NtGdiDeleteObjectApp(hDCTmp
);
573 /* Don't copy more bytes than the buffer has */
574 Bytes
= min(Bytes
, psurf
->SurfObj
.cjBits
);
577 /* FIXME: Call DDI CopyBits here if available */
580 DPRINT("Calling device specific BitmapBits\n");
581 if (psurf
->DDBitmap
->funcs
->pBitmapBits
)
583 ret
= psurf
->DDBitmap
->funcs
->pBitmapBits(hbitmap
,
590 ERR_(bitmap
)("BitmapBits == NULL??\n");
597 RtlCopyMemory(Bits
, psurf
->SurfObj
.pvBits
, Bytes
);
607 OUT OPTIONAL PBYTE pUnsafeBits
)
612 if (pUnsafeBits
!= NULL
&& Bytes
== 0)
617 psurf
= SURFACE_LockSurface(hBitmap
);
620 SetLastWin32Error(ERROR_INVALID_HANDLE
);
624 bmSize
= BITMAP_GetWidthBytes(psurf
->SurfObj
.sizlBitmap
.cx
,
625 BitsPerFormat(psurf
->SurfObj
.iBitmapFormat
)) *
626 abs(psurf
->SurfObj
.sizlBitmap
.cy
);
628 /* If the bits vector is null, the function should return the read size */
629 if (pUnsafeBits
== NULL
)
631 SURFACE_UnlockSurface(psurf
);
635 /* Don't copy more bytes than the buffer has */
636 Bytes
= min(Bytes
, bmSize
);
638 // FIXME: use MmSecureVirtualMemory
641 ProbeForWrite(pUnsafeBits
, Bytes
, 1);
642 ret
= IntGetBitmapBits(psurf
, Bytes
, pUnsafeBits
);
644 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
650 SURFACE_UnlockSurface(psurf
);
660 IN PBYTE pUnsafeBits
)
665 if (pUnsafeBits
== NULL
|| Bytes
== 0)
670 psurf
= SURFACE_LockSurface(hBitmap
);
673 SetLastWin32Error(ERROR_INVALID_HANDLE
);
679 ProbeForRead(pUnsafeBits
, Bytes
, 1);
680 UnsafeSetBitmapBits(psurf
, Bytes
, pUnsafeBits
);
683 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
689 SURFACE_UnlockSurface(psurf
);
695 NtGdiSetBitmapDimension(
707 psurf
= SURFACE_LockSurface(hBitmap
);
710 SetLastWin32Error(ERROR_INVALID_HANDLE
);
718 ProbeForWrite(Size
, sizeof(SIZE
), 1);
719 *Size
= psurf
->sizlDim
;
721 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
728 /* The dimension is changed even if writing the old value failed */
729 psurf
->sizlDim
.cx
= Width
;
730 psurf
->sizlDim
.cy
= Height
;
732 SURFACE_UnlockSurface(psurf
);
737 VOID
IntHandleSpecialColorType(HDC hDC
, COLORREF
* Color
)
741 PALETTEENTRY palEntry
;
744 switch (*Color
>> 24)
746 case 0x10: /* DIBINDEX */
747 if (IntGetDIBColorTable(hDC
, LOWORD(*Color
), 1, &quad
) == 1)
749 *Color
= RGB(quad
.rgbRed
, quad
.rgbGreen
, quad
.rgbBlue
);
753 /* Out of color table bounds - use black */
754 *Color
= RGB(0, 0, 0);
757 case 0x02: /* PALETTERGB */
758 pdc
= DC_LockDc(hDC
);
759 if (pdc
->dclevel
.hpal
!= NtGdiGetStockObject(DEFAULT_PALETTE
))
761 index
= NtGdiGetNearestPaletteIndex(pdc
->dclevel
.hpal
, *Color
);
762 IntGetPaletteEntries(pdc
->dclevel
.hpal
, index
, 1, &palEntry
);
763 *Color
= RGB(palEntry
.peRed
, palEntry
.peGreen
, palEntry
.peBlue
);
767 /* Use the pure color */
768 *Color
= *Color
& 0x00FFFFFF;
772 case 0x01: /* PALETTEINDEX */
773 pdc
= DC_LockDc(hDC
);
774 if (IntGetPaletteEntries(pdc
->dclevel
.hpal
, LOWORD(*Color
), 1, &palEntry
) == 1)
776 *Color
= RGB(palEntry
.peRed
, palEntry
.peGreen
, palEntry
.peBlue
);
780 /* Index does not exist, use zero index */
781 IntGetPaletteEntries(pdc
->dclevel
.hpal
, 0, 1, &palEntry
);
782 *Color
= RGB(palEntry
.peRed
, palEntry
.peGreen
, palEntry
.peBlue
);
787 DPRINT("Unsupported color type %d passed\n", *Color
>> 24);
802 if ((Color
& 0xFF000000) != 0)
804 IntHandleSpecialColorType(hDC
, &Color
);
807 hBrush
= NtGdiCreateSolidBrush(Color
, NULL
);
811 OldBrush
= NtGdiSelectBrush(hDC
, hBrush
);
812 if (OldBrush
== NULL
)
814 GreDeleteObject(hBrush
);
818 NtGdiPatBlt(hDC
, X
, Y
, 1, 1, PATCOPY
);
819 NtGdiSelectBrush(hDC
, OldBrush
);
820 GreDeleteObject(hBrush
);
832 DPRINT("0 NtGdiSetPixel X %ld Y %ld C %ld\n", X
, Y
, Color
);
834 if (GdiSetPixelV(hDC
,X
,Y
,Color
))
836 Color
= NtGdiGetPixel(hDC
,X
,Y
);
837 DPRINT("1 NtGdiSetPixel X %ld Y %ld C %ld\n", X
, Y
, Color
);
841 Color
= (COLORREF
)CLR_INVALID
;
842 DPRINT("2 NtGdiSetPixel X %ld Y %ld C %ld\n", X
, Y
, Color
);
847 /* Internal Functions */
850 BITMAP_GetRealBitsPixel(UINT nBitsPixel
)
858 if (nBitsPixel
<= 16)
860 if (nBitsPixel
<= 24)
862 if (nBitsPixel
<= 32)
869 BITMAP_GetWidthBytes(INT bmWidth
, INT bpp
)
875 return 2 * ((bmWidth
+15) >> 4);
878 bmWidth
*= 3; /* fall through */
880 return bmWidth
+ (bmWidth
& 1);
890 return 2 * ((bmWidth
+3) >> 2);
899 return ((bmWidth
* bpp
+ 15) & ~15) >> 3;
903 BITMAP_CopyBitmap(HBITMAP hBitmap
)
907 SURFACE
*Bitmap
, *resBitmap
;
915 Bitmap
= GDIOBJ_LockObj(hBitmap
, GDI_OBJECT_TYPE_BITMAP
);
921 BITMAP_GetObject(Bitmap
, sizeof(BITMAP
), (PVOID
)&bm
);
923 if (Bitmap
->SurfObj
.lDelta
>= 0)
924 bm
.bmHeight
= -bm
.bmHeight
;
926 Size
.cx
= abs(bm
.bmWidth
);
927 Size
.cy
= abs(bm
.bmHeight
);
928 res
= GreCreateBitmap(abs(bm
.bmWidth
),
938 resBitmap
= GDIOBJ_LockObj(res
, GDI_OBJECT_TYPE_BITMAP
);
941 buf
= ExAllocatePoolWithTag(PagedPool
,
942 bm
.bmWidthBytes
* abs(bm
.bmHeight
),
946 GDIOBJ_UnlockObjByPtr((POBJ
)resBitmap
);
947 GDIOBJ_UnlockObjByPtr((POBJ
)Bitmap
);
948 GreDeleteObject(res
);
951 IntGetBitmapBits(Bitmap
, bm
.bmWidthBytes
* abs(bm
.bmHeight
), buf
);
952 IntSetBitmapBits(resBitmap
, bm
.bmWidthBytes
* abs(bm
.bmHeight
), buf
);
953 ExFreePoolWithTag(buf
,TAG_BITMAP
);
954 resBitmap
->flags
= Bitmap
->flags
;
958 resBitmap
->ppal
= Bitmap
->ppal
;
959 GDIOBJ_IncrementShareCount(&Bitmap
->ppal
->BaseObject
);
961 GDIOBJ_UnlockObjByPtr((POBJ
)resBitmap
);
965 GreDeleteObject(res
);
970 GDIOBJ_UnlockObjByPtr((POBJ
)Bitmap
);
976 BITMAP_GetObject(SURFACE
*psurf
, INT Count
, LPVOID buffer
)
980 if (!buffer
) return sizeof(BITMAP
);
981 if ((UINT
)Count
< sizeof(BITMAP
)) return 0;
983 /* always fill a basic BITMAP structure */
986 pBitmap
->bmWidth
= psurf
->SurfObj
.sizlBitmap
.cx
;
987 pBitmap
->bmHeight
= psurf
->SurfObj
.sizlBitmap
.cy
;
988 pBitmap
->bmWidthBytes
= abs(psurf
->SurfObj
.lDelta
);
989 pBitmap
->bmPlanes
= 1;
990 pBitmap
->bmBitsPixel
= BitsPerFormat(psurf
->SurfObj
.iBitmapFormat
);
992 /* Check for DIB section */
995 /* Set bmBits in this case */
996 pBitmap
->bmBits
= psurf
->SurfObj
.pvBits
;
998 if (Count
>= sizeof(DIBSECTION
))
1000 /* Fill rest of DIBSECTION */
1001 PDIBSECTION pds
= buffer
;
1003 pds
->dsBmih
.biSize
= sizeof(BITMAPINFOHEADER
);
1004 pds
->dsBmih
.biWidth
= pds
->dsBm
.bmWidth
;
1005 pds
->dsBmih
.biHeight
= pds
->dsBm
.bmHeight
;
1006 pds
->dsBmih
.biPlanes
= pds
->dsBm
.bmPlanes
;
1007 pds
->dsBmih
.biBitCount
= pds
->dsBm
.bmBitsPixel
;
1008 switch (psurf
->SurfObj
.iBitmapFormat
)
1010 /* FIXME: What about BI_BITFIELDS? */
1017 pds
->dsBmih
.biCompression
= BI_RGB
;
1020 pds
->dsBmih
.biCompression
= BI_RLE4
;
1023 pds
->dsBmih
.biCompression
= BI_RLE8
;
1026 pds
->dsBmih
.biCompression
= BI_JPEG
;
1029 pds
->dsBmih
.biCompression
= BI_PNG
;
1032 pds
->dsBmih
.biSizeImage
= psurf
->SurfObj
.cjBits
;
1033 pds
->dsBmih
.biXPelsPerMeter
= 0;
1034 pds
->dsBmih
.biYPelsPerMeter
= 0;
1035 pds
->dsBmih
.biClrUsed
= psurf
->ppal
->NumColors
;
1036 pds
->dsBmih
.biClrImportant
= psurf
->biClrImportant
;
1037 pds
->dsBitfields
[0] = psurf
->ppal
->RedMask
;
1038 pds
->dsBitfields
[1] = psurf
->ppal
->GreenMask
;
1039 pds
->dsBitfields
[2] = psurf
->ppal
->BlueMask
;
1040 pds
->dshSection
= psurf
->hDIBSection
;
1041 pds
->dsOffset
= psurf
->dwOffset
;
1043 return sizeof(DIBSECTION
);
1048 /* not set according to wine test, confirmed in win2k */
1049 pBitmap
->bmBits
= NULL
;
1052 return sizeof(BITMAP
);
1060 NtGdiGetDCforBitmap(
1064 PSURFACE psurf
= SURFACE_LockSurface(hsurf
);
1068 SURFACE_UnlockSurface(psurf
);