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 /* Allocate memory for a BITMAPINFOHEADER structure and a
316 color table. The maximum number of colors in a color table
317 is 256 which corresponds to a bitmap with depth 8.
318 Bitmaps with higher depths don't have color tables. */
319 bi
= ExAllocatePoolWithTag(PagedPool
,
320 sizeof(BITMAPINFOHEADER
) +
321 256 * sizeof(RGBQUAD
),
326 bi
->bmiHeader
.biSize
= sizeof(bi
->bmiHeader
);
327 bi
->bmiHeader
.biWidth
= Width
;
328 bi
->bmiHeader
.biHeight
= Height
;
329 bi
->bmiHeader
.biPlanes
= dibs
.dsBmih
.biPlanes
;
330 bi
->bmiHeader
.biBitCount
= dibs
.dsBmih
.biBitCount
;
331 bi
->bmiHeader
.biCompression
= dibs
.dsBmih
.biCompression
;
332 bi
->bmiHeader
.biSizeImage
= 0;
333 bi
->bmiHeader
.biXPelsPerMeter
= dibs
.dsBmih
.biXPelsPerMeter
;
334 bi
->bmiHeader
.biYPelsPerMeter
= dibs
.dsBmih
.biYPelsPerMeter
;
335 bi
->bmiHeader
.biClrUsed
= dibs
.dsBmih
.biClrUsed
;
336 bi
->bmiHeader
.biClrImportant
= dibs
.dsBmih
.biClrImportant
;
338 if (bi
->bmiHeader
.biCompression
== BI_BITFIELDS
)
340 /* Copy the color masks */
341 RtlCopyMemory(bi
->bmiColors
, dibs
.dsBitfields
, 3 * sizeof(DWORD
));
343 else if (bi
->bmiHeader
.biBitCount
<= 8)
345 /* Copy the color table */
351 ExFreePoolWithTag(bi
, TAG_TEMP
);
352 SetLastWin32Error(ERROR_INVALID_HANDLE
);
356 PalGDI
= PALETTE_LockPalette(psurf
->ppal
->BaseObject
.hHmgr
);
359 Index
< 256 && Index
< PalGDI
->NumColors
;
362 bi
->bmiColors
[Index
].rgbRed
= PalGDI
->IndexedColors
[Index
].peRed
;
363 bi
->bmiColors
[Index
].rgbGreen
= PalGDI
->IndexedColors
[Index
].peGreen
;
364 bi
->bmiColors
[Index
].rgbBlue
= PalGDI
->IndexedColors
[Index
].peBlue
;
365 bi
->bmiColors
[Index
].rgbReserved
= 0;
367 PALETTE_UnlockPalette(PalGDI
);
370 Bmp
= DIB_CreateDIBSection(Dc
,
378 ExFreePoolWithTag(bi
, TAG_TEMP
);
389 NtGdiCreateCompatibleBitmap(
397 if (Width
<= 0 || Height
<= 0 || (Width
* Height
) > 0x3FFFFFFF)
399 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
404 return GreCreateBitmap(Width
, Height
, 1, 1, 0);
408 DPRINT("NtGdiCreateCompatibleBitmap(%04x,%d,%d, bpp:%d) = \n",
409 hDC
, Width
, Height
, Dc
->ppdev
->gdiinfo
.cBitsPixel
);
413 SetLastWin32Error(ERROR_INVALID_HANDLE
);
417 Bmp
= IntCreateCompatibleBitmap(Dc
, Width
, Height
);
419 DPRINT("\t\t%04x\n", Bmp
);
425 NtGdiGetBitmapDimension(
435 psurfBmp
= SURFACE_LockSurface(hBitmap
);
436 if (psurfBmp
== NULL
)
438 SetLastWin32Error(ERROR_INVALID_HANDLE
);
444 ProbeForWrite(Dimension
, sizeof(SIZE
), 1);
445 *Dimension
= psurfBmp
->sizlDim
;
447 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
453 SURFACE_UnlockSurface(psurfBmp
);
459 NtGdiGetPixel(HDC hDC
, INT XPos
, INT YPos
)
462 COLORREF Result
= (COLORREF
)CLR_INVALID
; // default to failure
463 BOOL bInRect
= FALSE
;
474 SetLastWin32Error(ERROR_INVALID_HANDLE
);
478 if (dc
->dctype
== DC_TYPE_INFO
)
484 XPos
+= dc
->ptlDCOrig
.x
;
485 YPos
+= dc
->ptlDCOrig
.y
;
486 if (RECTL_bPointInRect(&dc
->rosdc
.CombinedClip
->rclBounds
, XPos
, YPos
))
489 psurf
= dc
->dclevel
.pSurface
;
492 pso
= &psurf
->SurfObj
;
496 GDIOBJ_IncrementShareCount(&ppal
->BaseObject
);
499 ppal
= PALETTE_ShareLockPalette(dc
->ppdev
->devinfo
.hpalDefault
);
501 if (psurf
->SurfObj
.iBitmapFormat
== BMF_1BPP
&& !psurf
->hSecure
)
503 /* FIXME: palette should be gpalMono already ! */
504 EXLATEOBJ_vInitialize(&exlo
, &gpalMono
, &gpalRGB
, 0, 0xffffff, 0);
508 EXLATEOBJ_vInitialize(&exlo
, ppal
, &gpalRGB
, 0, 0xffffff, 0);
511 // check if this DC has a DIB behind it...
512 if (pso
->pvScan0
) // STYPE_BITMAP == pso->iType
515 Result
= XLATEOBJ_iXlate(&exlo
.xlo
,
516 DibFunctionsForBitmapFormat
[pso
->iBitmapFormat
].DIB_GetPixel(pso
, XPos
, YPos
));
519 EXLATEOBJ_vCleanup(&exlo
);
520 PALETTE_ShareUnlockPalette(ppal
);
525 // if Result is still CLR_INVALID, then the "quick" method above didn't work
526 if (bInRect
&& Result
== CLR_INVALID
)
528 // FIXME: create a 1x1 32BPP DIB, and blit to it
529 HDC hDCTmp
= NtGdiCreateCompatibleDC(hDC
);
532 static const BITMAPINFOHEADER bih
= { sizeof(BITMAPINFOHEADER
), 1, 1, 1, 32, BI_RGB
, 0, 0, 0, 0, 0 };
534 RtlMoveMemory(&(bi
.bmiHeader
), &bih
, sizeof(bih
));
535 hBmpTmp
= NtGdiCreateDIBitmapInternal(hDC
,
536 bi
.bmiHeader
.biWidth
,
537 bi
.bmiHeader
.biHeight
,
542 bi
.bmiHeader
.biBitCount
,
543 bi
.bmiHeader
.biSizeImage
,
547 //HBITMAP hBmpTmp = GreCreateBitmap(1, 1, 1, 32, NULL);
550 HBITMAP hBmpOld
= (HBITMAP
)NtGdiSelectBitmap(hDCTmp
, hBmpTmp
);
555 NtGdiBitBlt(hDCTmp
, 0, 0, 1, 1, hDC
, XPos
, YPos
, SRCCOPY
, 0, 0);
556 NtGdiSelectBitmap(hDCTmp
, hBmpOld
);
558 // our bitmap is no longer selected, so we can access it's stuff...
559 psurf
= SURFACE_LockSurface(hBmpTmp
);
562 // Dont you need to convert something here?
563 Result
= *(COLORREF
*)psurf
->SurfObj
.pvScan0
;
564 SURFACE_UnlockSurface(psurf
);
567 GreDeleteObject(hBmpTmp
);
569 NtGdiDeleteObjectApp(hDCTmp
);
587 /* Don't copy more bytes than the buffer has */
588 Bytes
= min(Bytes
, psurf
->SurfObj
.cjBits
);
591 /* FIXME: Call DDI CopyBits here if available */
594 DPRINT("Calling device specific BitmapBits\n");
595 if (psurf
->DDBitmap
->funcs
->pBitmapBits
)
597 ret
= psurf
->DDBitmap
->funcs
->pBitmapBits(hbitmap
,
604 ERR_(bitmap
)("BitmapBits == NULL??\n");
611 RtlCopyMemory(Bits
, psurf
->SurfObj
.pvBits
, Bytes
);
621 OUT OPTIONAL PBYTE pUnsafeBits
)
626 if (pUnsafeBits
!= NULL
&& Bytes
== 0)
631 psurf
= SURFACE_LockSurface(hBitmap
);
634 SetLastWin32Error(ERROR_INVALID_HANDLE
);
638 bmSize
= BITMAP_GetWidthBytes(psurf
->SurfObj
.sizlBitmap
.cx
,
639 BitsPerFormat(psurf
->SurfObj
.iBitmapFormat
)) *
640 abs(psurf
->SurfObj
.sizlBitmap
.cy
);
642 /* If the bits vector is null, the function should return the read size */
643 if (pUnsafeBits
== NULL
)
645 SURFACE_UnlockSurface(psurf
);
649 /* Don't copy more bytes than the buffer has */
650 Bytes
= min(Bytes
, bmSize
);
652 // FIXME: use MmSecureVirtualMemory
655 ProbeForWrite(pUnsafeBits
, Bytes
, 1);
656 ret
= IntGetBitmapBits(psurf
, Bytes
, pUnsafeBits
);
658 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
664 SURFACE_UnlockSurface(psurf
);
674 IN PBYTE pUnsafeBits
)
679 if (pUnsafeBits
== NULL
|| Bytes
== 0)
684 psurf
= SURFACE_LockSurface(hBitmap
);
687 SetLastWin32Error(ERROR_INVALID_HANDLE
);
693 ProbeForRead(pUnsafeBits
, Bytes
, 1);
694 UnsafeSetBitmapBits(psurf
, Bytes
, pUnsafeBits
);
697 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
703 SURFACE_UnlockSurface(psurf
);
709 NtGdiSetBitmapDimension(
721 psurf
= SURFACE_LockSurface(hBitmap
);
724 SetLastWin32Error(ERROR_INVALID_HANDLE
);
732 ProbeForWrite(Size
, sizeof(SIZE
), 1);
733 *Size
= psurf
->sizlDim
;
735 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
742 /* The dimension is changed even if writing the old value failed */
743 psurf
->sizlDim
.cx
= Width
;
744 psurf
->sizlDim
.cy
= Height
;
746 SURFACE_UnlockSurface(psurf
);
751 VOID
IntHandleSpecialColorType(HDC hDC
, COLORREF
* Color
)
755 PALETTEENTRY palEntry
;
758 switch (*Color
>> 24)
760 case 0x10: /* DIBINDEX */
761 if (IntGetDIBColorTable(hDC
, LOWORD(*Color
), 1, &quad
) == 1)
763 *Color
= RGB(quad
.rgbRed
, quad
.rgbGreen
, quad
.rgbBlue
);
767 /* Out of color table bounds - use black */
768 *Color
= RGB(0, 0, 0);
771 case 0x02: /* PALETTERGB */
772 pdc
= DC_LockDc(hDC
);
773 if (pdc
->dclevel
.hpal
!= NtGdiGetStockObject(DEFAULT_PALETTE
))
775 index
= NtGdiGetNearestPaletteIndex(pdc
->dclevel
.hpal
, *Color
);
776 IntGetPaletteEntries(pdc
->dclevel
.hpal
, index
, 1, &palEntry
);
777 *Color
= RGB(palEntry
.peRed
, palEntry
.peGreen
, palEntry
.peBlue
);
781 /* Use the pure color */
782 *Color
= *Color
& 0x00FFFFFF;
786 case 0x01: /* PALETTEINDEX */
787 pdc
= DC_LockDc(hDC
);
788 if (IntGetPaletteEntries(pdc
->dclevel
.hpal
, LOWORD(*Color
), 1, &palEntry
) == 1)
790 *Color
= RGB(palEntry
.peRed
, palEntry
.peGreen
, palEntry
.peBlue
);
794 /* Index does not exist, use zero index */
795 IntGetPaletteEntries(pdc
->dclevel
.hpal
, 0, 1, &palEntry
);
796 *Color
= RGB(palEntry
.peRed
, palEntry
.peGreen
, palEntry
.peBlue
);
801 DPRINT("Unsupported color type %d passed\n", *Color
>> 24);
816 if ((Color
& 0xFF000000) != 0)
818 IntHandleSpecialColorType(hDC
, &Color
);
821 hBrush
= NtGdiCreateSolidBrush(Color
, NULL
);
825 OldBrush
= NtGdiSelectBrush(hDC
, hBrush
);
826 if (OldBrush
== NULL
)
828 GreDeleteObject(hBrush
);
832 NtGdiPatBlt(hDC
, X
, Y
, 1, 1, PATCOPY
);
833 NtGdiSelectBrush(hDC
, OldBrush
);
834 GreDeleteObject(hBrush
);
846 DPRINT("0 NtGdiSetPixel X %ld Y %ld C %ld\n", X
, Y
, Color
);
848 if (GdiSetPixelV(hDC
,X
,Y
,Color
))
850 Color
= NtGdiGetPixel(hDC
,X
,Y
);
851 DPRINT("1 NtGdiSetPixel X %ld Y %ld C %ld\n", X
, Y
, Color
);
855 Color
= (COLORREF
)CLR_INVALID
;
856 DPRINT("2 NtGdiSetPixel X %ld Y %ld C %ld\n", X
, Y
, Color
);
861 /* Internal Functions */
864 BITMAP_GetRealBitsPixel(UINT nBitsPixel
)
872 if (nBitsPixel
<= 16)
874 if (nBitsPixel
<= 24)
876 if (nBitsPixel
<= 32)
883 BITMAP_GetWidthBytes(INT bmWidth
, INT bpp
)
889 return 2 * ((bmWidth
+15) >> 4);
892 bmWidth
*= 3; /* fall through */
894 return bmWidth
+ (bmWidth
& 1);
904 return 2 * ((bmWidth
+3) >> 2);
913 return ((bmWidth
* bpp
+ 15) & ~15) >> 3;
917 BITMAP_CopyBitmap(HBITMAP hBitmap
)
921 SURFACE
*Bitmap
, *resBitmap
;
929 Bitmap
= GDIOBJ_LockObj(hBitmap
, GDI_OBJECT_TYPE_BITMAP
);
935 BITMAP_GetObject(Bitmap
, sizeof(BITMAP
), (PVOID
)&bm
);
937 if (Bitmap
->SurfObj
.lDelta
>= 0)
938 bm
.bmHeight
= -bm
.bmHeight
;
940 Size
.cx
= abs(bm
.bmWidth
);
941 Size
.cy
= abs(bm
.bmHeight
);
942 res
= GreCreateBitmap(abs(bm
.bmWidth
),
952 resBitmap
= GDIOBJ_LockObj(res
, GDI_OBJECT_TYPE_BITMAP
);
955 buf
= ExAllocatePoolWithTag(PagedPool
,
956 bm
.bmWidthBytes
* abs(bm
.bmHeight
),
960 GDIOBJ_UnlockObjByPtr((POBJ
)resBitmap
);
961 GDIOBJ_UnlockObjByPtr((POBJ
)Bitmap
);
962 GreDeleteObject(res
);
965 IntGetBitmapBits(Bitmap
, bm
.bmWidthBytes
* abs(bm
.bmHeight
), buf
);
966 IntSetBitmapBits(resBitmap
, bm
.bmWidthBytes
* abs(bm
.bmHeight
), buf
);
967 ExFreePoolWithTag(buf
,TAG_BITMAP
);
968 resBitmap
->flags
= Bitmap
->flags
;
972 resBitmap
->ppal
= Bitmap
->ppal
;
973 GDIOBJ_IncrementShareCount(&Bitmap
->ppal
->BaseObject
);
975 GDIOBJ_UnlockObjByPtr((POBJ
)resBitmap
);
979 GreDeleteObject(res
);
984 GDIOBJ_UnlockObjByPtr((POBJ
)Bitmap
);
990 BITMAP_GetObject(SURFACE
*psurf
, INT Count
, LPVOID buffer
)
994 if (!buffer
) return sizeof(BITMAP
);
995 if ((UINT
)Count
< sizeof(BITMAP
)) return 0;
997 /* always fill a basic BITMAP structure */
1000 pBitmap
->bmWidth
= psurf
->SurfObj
.sizlBitmap
.cx
;
1001 pBitmap
->bmHeight
= psurf
->SurfObj
.sizlBitmap
.cy
;
1002 pBitmap
->bmWidthBytes
= abs(psurf
->SurfObj
.lDelta
);
1003 pBitmap
->bmPlanes
= 1;
1004 pBitmap
->bmBitsPixel
= BitsPerFormat(psurf
->SurfObj
.iBitmapFormat
);
1006 /* Check for DIB section */
1009 /* Set bmBits in this case */
1010 pBitmap
->bmBits
= psurf
->SurfObj
.pvBits
;
1012 if (Count
>= sizeof(DIBSECTION
))
1014 /* Fill rest of DIBSECTION */
1015 PDIBSECTION pds
= buffer
;
1017 pds
->dsBmih
.biSize
= sizeof(BITMAPINFOHEADER
);
1018 pds
->dsBmih
.biWidth
= pds
->dsBm
.bmWidth
;
1019 pds
->dsBmih
.biHeight
= pds
->dsBm
.bmHeight
;
1020 pds
->dsBmih
.biPlanes
= pds
->dsBm
.bmPlanes
;
1021 pds
->dsBmih
.biBitCount
= pds
->dsBm
.bmBitsPixel
;
1022 switch (psurf
->SurfObj
.iBitmapFormat
)
1024 /* FIXME: What about BI_BITFIELDS? */
1031 pds
->dsBmih
.biCompression
= BI_RGB
;
1034 pds
->dsBmih
.biCompression
= BI_RLE4
;
1037 pds
->dsBmih
.biCompression
= BI_RLE8
;
1040 pds
->dsBmih
.biCompression
= BI_JPEG
;
1043 pds
->dsBmih
.biCompression
= BI_PNG
;
1046 pds
->dsBmih
.biSizeImage
= psurf
->SurfObj
.cjBits
;
1047 pds
->dsBmih
.biXPelsPerMeter
= 0;
1048 pds
->dsBmih
.biYPelsPerMeter
= 0;
1049 pds
->dsBmih
.biClrUsed
= psurf
->biClrUsed
;
1050 pds
->dsBmih
.biClrImportant
= psurf
->biClrImportant
;
1051 pds
->dsBitfields
[0] = psurf
->dsBitfields
[0];
1052 pds
->dsBitfields
[1] = psurf
->dsBitfields
[1];
1053 pds
->dsBitfields
[2] = psurf
->dsBitfields
[2];
1054 pds
->dshSection
= psurf
->hDIBSection
;
1055 pds
->dsOffset
= psurf
->dwOffset
;
1057 return sizeof(DIBSECTION
);
1062 /* not set according to wine test, confirmed in win2k */
1063 pBitmap
->bmBits
= NULL
;
1066 return sizeof(BITMAP
);
1074 NtGdiGetDCforBitmap(
1078 PSURFACE psurf
= SURFACE_LockSurface(hsurf
);
1082 SURFACE_UnlockSurface(psurf
);