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
,
85 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
);
110 fjBitmap
|= BMF_RLE_HACK
;
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
);
118 fjBitmap
|= BMF_RLE_HACK
;
121 /* Mark as API bitmap */
122 psurf
->flags
|= (flags
| API_BITMAP
);
124 /* Set the bitmap bits */
125 if (!SURFACE_bSetBitmapBits(psurf
, fjBitmap
, cjWidthBytes
, pvBits
))
127 /* Bail out if that failed */
128 DPRINT1("SURFACE_bSetBitmapBits failed.\n");
129 SURFACE_FreeSurfaceByHandle(hbmp
);
133 /* Unlock the surface and return */
134 SURFACE_UnlockSurface(psurf
);
138 /* Creates a DDB surface,
139 * as in CreateCompatibleBitmap or CreateBitmap.
148 IN OPTIONAL PVOID pvBits
)
150 /* Call the extended function */
151 return GreCreateBitmapEx(nWidth
,
154 BitmapFormat(cBitsPixel
* cPlanes
, BI_RGB
),
155 0, /* no bitmap flags */
158 DDB_SURFACE
/* DDB */);
168 IN OPTIONAL LPBYTE pUnsafeBits
)
171 ULONG cjWidthBytes
, iFormat
;
173 /* NOTE: Windows also doesn't store nr. of planes separately! */
174 cBitsPixel
= BITMAP_GetRealBitsPixel(cBitsPixel
* cPlanes
);
176 /* Calculate bitmap format */
177 iFormat
= BitmapFormat(cBitsPixel
, BI_RGB
);
179 /* Check parameters */
180 if (iFormat
== 0 || nWidth
<= 0 || nWidth
>= 0x8000000 || nHeight
<= 0)
182 DPRINT1("Width = %d, Height = %d BitsPixel = %d\n",
183 nWidth
, nHeight
, cBitsPixel
);
184 EngSetLastError(ERROR_INVALID_PARAMETER
);
188 /* Make sure that cjBits will not overflow */
189 cjWidthBytes
= BITMAP_GetWidthBytes(nWidth
, cBitsPixel
);
190 if ((ULONGLONG
)cjWidthBytes
* nHeight
>= 0x100000000ULL
)
192 DPRINT1("Width = %d, Height = %d BitsPixel = %d\n",
193 nWidth
, nHeight
, cBitsPixel
);
194 EngSetLastError(ERROR_INVALID_PARAMETER
);
198 /* cBitsPixel = cBitsPixel * cPlanes now! */
199 hbmp
= GreCreateBitmap(nWidth
, nHeight
, 1, cBitsPixel
, NULL
);
203 PSURFACE psurf
= SURFACE_LockSurface(hbmp
);
206 ProbeForRead(pUnsafeBits
, cjWidthBytes
* nHeight
, 1);
207 UnsafeSetBitmapBits(psurf
, 0, pUnsafeBits
);
209 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
211 SURFACE_UnlockSurface(psurf
);
212 SURFACE_FreeSurfaceByHandle(hbmp
);
213 _SEH2_YIELD(return NULL
;)
217 SURFACE_UnlockSurface(psurf
);
225 IntCreateCompatibleBitmap(
232 /* MS doc says if width or height is 0, return 1-by-1 pixel, monochrome bitmap */
233 if (0 == Width
|| 0 == Height
)
235 Bmp
= NtGdiGetStockObject(DEFAULT_BITMAP
);
239 if (Dc
->dctype
!= DC_TYPE_MEMORY
)
244 size
.cx
= abs(Width
);
245 size
.cy
= abs(Height
);
246 Bmp
= GreCreateBitmap(abs(Width
),
249 Dc
->ppdev
->gdiinfo
.cBitsPixel
,
251 psurf
= SURFACE_LockSurface(Bmp
);
254 psurf
->ppal
= PALETTE_ShareLockPalette(Dc
->ppdev
->devinfo
.hpalDefault
);
256 psurf
->flags
= API_BITMAP
;
257 psurf
->hdc
= NULL
; // Fixme
258 SURFACE_UnlockSurface(psurf
);
264 PSURFACE psurf
= Dc
->dclevel
.pSurface
;
265 Count
= BITMAP_GetObject(psurf
, sizeof(dibs
), &dibs
);
269 if (Count
== sizeof(BITMAP
))
273 size
.cx
= abs(Width
);
274 size
.cy
= abs(Height
);
275 Bmp
= GreCreateBitmap(abs(Width
),
278 dibs
.dsBm
.bmBitsPixel
,
280 psurfBmp
= SURFACE_LockSurface(Bmp
);
283 psurfBmp
->ppal
= psurf
->ppal
;
284 GDIOBJ_IncrementShareCount((POBJ
)psurf
->ppal
);
286 psurfBmp
->flags
= API_BITMAP
;
287 psurfBmp
->hdc
= NULL
; // Fixme
288 SURFACE_UnlockSurface(psurfBmp
);
292 /* A DIB section is selected in the DC */
293 BYTE buf
[sizeof(BITMAPINFOHEADER
) + 256*sizeof(RGBQUAD
)] = {0};
295 BITMAPINFO
* bi
= (BITMAPINFO
*)buf
;
297 bi
->bmiHeader
.biSize
= sizeof(bi
->bmiHeader
);
298 bi
->bmiHeader
.biWidth
= Width
;
299 bi
->bmiHeader
.biHeight
= Height
;
300 bi
->bmiHeader
.biPlanes
= dibs
.dsBmih
.biPlanes
;
301 bi
->bmiHeader
.biBitCount
= dibs
.dsBmih
.biBitCount
;
302 bi
->bmiHeader
.biCompression
= dibs
.dsBmih
.biCompression
;
303 bi
->bmiHeader
.biSizeImage
= 0;
304 bi
->bmiHeader
.biXPelsPerMeter
= dibs
.dsBmih
.biXPelsPerMeter
;
305 bi
->bmiHeader
.biYPelsPerMeter
= dibs
.dsBmih
.biYPelsPerMeter
;
306 bi
->bmiHeader
.biClrUsed
= dibs
.dsBmih
.biClrUsed
;
307 bi
->bmiHeader
.biClrImportant
= dibs
.dsBmih
.biClrImportant
;
309 if (bi
->bmiHeader
.biCompression
== BI_BITFIELDS
)
311 /* Copy the color masks */
312 RtlCopyMemory(bi
->bmiColors
, dibs
.dsBitfields
, 3*sizeof(RGBQUAD
));
314 else if (bi
->bmiHeader
.biBitCount
<= 8)
316 /* Copy the color table */
322 SetLastWin32Error(ERROR_INVALID_HANDLE
);
326 PalGDI
= PALETTE_LockPalette(psurf
->ppal
->BaseObject
.hHmgr
);
329 Index
< 256 && Index
< PalGDI
->NumColors
;
332 bi
->bmiColors
[Index
].rgbRed
= PalGDI
->IndexedColors
[Index
].peRed
;
333 bi
->bmiColors
[Index
].rgbGreen
= PalGDI
->IndexedColors
[Index
].peGreen
;
334 bi
->bmiColors
[Index
].rgbBlue
= PalGDI
->IndexedColors
[Index
].peBlue
;
335 bi
->bmiColors
[Index
].rgbReserved
= 0;
337 PALETTE_UnlockPalette(PalGDI
);
339 Bmp
= DIB_CreateDIBSection(Dc
,
356 NtGdiCreateCompatibleBitmap(
364 if (Width
<= 0 || Height
<= 0 || (Width
* Height
) > 0x3FFFFFFF)
366 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
371 return GreCreateBitmap(Width
, Height
, 1, 1, 0);
375 DPRINT("NtGdiCreateCompatibleBitmap(%04x,%d,%d, bpp:%d) = \n",
376 hDC
, Width
, Height
, Dc
->ppdev
->gdiinfo
.cBitsPixel
);
380 SetLastWin32Error(ERROR_INVALID_HANDLE
);
384 Bmp
= IntCreateCompatibleBitmap(Dc
, Width
, Height
);
386 DPRINT("\t\t%04x\n", Bmp
);
392 NtGdiGetBitmapDimension(
402 psurfBmp
= SURFACE_LockSurface(hBitmap
);
403 if (psurfBmp
== NULL
)
405 SetLastWin32Error(ERROR_INVALID_HANDLE
);
411 ProbeForWrite(Dimension
, sizeof(SIZE
), 1);
412 *Dimension
= psurfBmp
->sizlDim
;
414 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
420 SURFACE_UnlockSurface(psurfBmp
);
426 NtGdiGetPixel(HDC hDC
, INT XPos
, INT YPos
)
429 COLORREF Result
= (COLORREF
)CLR_INVALID
; // default to failure
430 BOOL bInRect
= FALSE
;
441 SetLastWin32Error(ERROR_INVALID_HANDLE
);
445 if (dc
->dctype
== DC_TYPE_INFO
)
451 XPos
+= dc
->ptlDCOrig
.x
;
452 YPos
+= dc
->ptlDCOrig
.y
;
453 if (RECTL_bPointInRect(&dc
->rosdc
.CombinedClip
->rclBounds
, XPos
, YPos
))
456 psurf
= dc
->dclevel
.pSurface
;
459 pso
= &psurf
->SurfObj
;
463 GDIOBJ_IncrementShareCount(&ppal
->BaseObject
);
466 ppal
= PALETTE_ShareLockPalette(dc
->ppdev
->devinfo
.hpalDefault
);
468 if (psurf
->SurfObj
.iBitmapFormat
== BMF_1BPP
&& !psurf
->hSecure
)
470 /* FIXME: palette should be gpalMono already ! */
471 EXLATEOBJ_vInitialize(&exlo
, &gpalMono
, &gpalRGB
, 0, 0xffffff, 0);
475 EXLATEOBJ_vInitialize(&exlo
, ppal
, &gpalRGB
, 0, 0xffffff, 0);
478 // check if this DC has a DIB behind it...
479 if (pso
->pvScan0
) // STYPE_BITMAP == pso->iType
482 Result
= XLATEOBJ_iXlate(&exlo
.xlo
,
483 DibFunctionsForBitmapFormat
[pso
->iBitmapFormat
].DIB_GetPixel(pso
, XPos
, YPos
));
486 EXLATEOBJ_vCleanup(&exlo
);
487 PALETTE_ShareUnlockPalette(ppal
);
492 // if Result is still CLR_INVALID, then the "quick" method above didn't work
493 if (bInRect
&& Result
== CLR_INVALID
)
495 // FIXME: create a 1x1 32BPP DIB, and blit to it
496 HDC hDCTmp
= NtGdiCreateCompatibleDC(hDC
);
499 static const BITMAPINFOHEADER bih
= { sizeof(BITMAPINFOHEADER
), 1, 1, 1, 32, BI_RGB
, 0, 0, 0, 0, 0 };
501 RtlMoveMemory(&(bi
.bmiHeader
), &bih
, sizeof(bih
));
502 hBmpTmp
= NtGdiCreateDIBitmapInternal(hDC
,
503 bi
.bmiHeader
.biWidth
,
504 bi
.bmiHeader
.biHeight
,
509 bi
.bmiHeader
.biBitCount
,
510 bi
.bmiHeader
.biSizeImage
,
514 //HBITMAP hBmpTmp = GreCreateBitmap(1, 1, 1, 32, NULL);
517 HBITMAP hBmpOld
= (HBITMAP
)NtGdiSelectBitmap(hDCTmp
, hBmpTmp
);
522 NtGdiBitBlt(hDCTmp
, 0, 0, 1, 1, hDC
, XPos
, YPos
, SRCCOPY
, 0, 0);
523 NtGdiSelectBitmap(hDCTmp
, hBmpOld
);
525 // our bitmap is no longer selected, so we can access it's stuff...
526 psurf
= SURFACE_LockSurface(hBmpTmp
);
529 // Dont you need to convert something here?
530 Result
= *(COLORREF
*)psurf
->SurfObj
.pvScan0
;
531 SURFACE_UnlockSurface(psurf
);
534 GreDeleteObject(hBmpTmp
);
536 NtGdiDeleteObjectApp(hDCTmp
);
554 /* Don't copy more bytes than the buffer has */
555 Bytes
= min(Bytes
, psurf
->SurfObj
.cjBits
);
558 /* FIXME: Call DDI CopyBits here if available */
561 DPRINT("Calling device specific BitmapBits\n");
562 if (psurf
->DDBitmap
->funcs
->pBitmapBits
)
564 ret
= psurf
->DDBitmap
->funcs
->pBitmapBits(hbitmap
,
571 ERR_(bitmap
)("BitmapBits == NULL??\n");
578 RtlCopyMemory(Bits
, psurf
->SurfObj
.pvBits
, Bytes
);
592 LONG lDeltaDst
, lDeltaSrc
;
593 ULONG nWidth
, nHeight
, cBitsPixel
;
595 nWidth
= psurf
->SurfObj
.sizlBitmap
.cx
;
596 nHeight
= psurf
->SurfObj
.sizlBitmap
.cy
;
597 cBitsPixel
= BitsPerFormat(psurf
->SurfObj
.iBitmapFormat
);
600 pjSrc
= psurf
->SurfObj
.pvScan0
;
602 lDeltaSrc
= psurf
->SurfObj
.lDelta
;
603 lDeltaDst
= BITMAP_GetWidthBytes(nWidth
, cBitsPixel
);
608 RtlCopyMemory(pjDst
, pjSrc
, lDeltaDst
);
618 OUT OPTIONAL PBYTE pUnsafeBits
)
623 if (pUnsafeBits
!= NULL
&& Bytes
== 0)
628 psurf
= SURFACE_LockSurface(hBitmap
);
631 SetLastWin32Error(ERROR_INVALID_HANDLE
);
635 bmSize
= BITMAP_GetWidthBytes(psurf
->SurfObj
.sizlBitmap
.cx
,
636 BitsPerFormat(psurf
->SurfObj
.iBitmapFormat
)) *
637 abs(psurf
->SurfObj
.sizlBitmap
.cy
);
639 /* If the bits vector is null, the function should return the read size */
640 if (pUnsafeBits
== NULL
)
642 SURFACE_UnlockSurface(psurf
);
646 /* Don't copy more bytes than the buffer has */
647 Bytes
= min(Bytes
, bmSize
);
649 // FIXME: use MmSecureVirtualMemory
652 ProbeForWrite(pUnsafeBits
, Bytes
, 1);
653 UnsafeGetBitmapBits(psurf
, Bytes
, pUnsafeBits
);
656 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
662 SURFACE_UnlockSurface(psurf
);
672 IN PBYTE pUnsafeBits
)
677 if (pUnsafeBits
== NULL
|| Bytes
== 0)
682 psurf
= SURFACE_LockSurface(hBitmap
);
685 SetLastWin32Error(ERROR_INVALID_HANDLE
);
691 ProbeForRead(pUnsafeBits
, Bytes
, 1);
692 UnsafeSetBitmapBits(psurf
, Bytes
, pUnsafeBits
);
695 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
701 SURFACE_UnlockSurface(psurf
);
707 NtGdiSetBitmapDimension(
719 psurf
= SURFACE_LockSurface(hBitmap
);
722 SetLastWin32Error(ERROR_INVALID_HANDLE
);
730 ProbeForWrite(Size
, sizeof(SIZE
), 1);
731 *Size
= psurf
->sizlDim
;
733 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
740 /* The dimension is changed even if writing the old value failed */
741 psurf
->sizlDim
.cx
= Width
;
742 psurf
->sizlDim
.cy
= Height
;
744 SURFACE_UnlockSurface(psurf
);
749 VOID
IntHandleSpecialColorType(HDC hDC
, COLORREF
* Color
)
753 PALETTEENTRY palEntry
;
756 switch (*Color
>> 24)
758 case 0x10: /* DIBINDEX */
759 if (IntGetDIBColorTable(hDC
, LOWORD(*Color
), 1, &quad
) == 1)
761 *Color
= RGB(quad
.rgbRed
, quad
.rgbGreen
, quad
.rgbBlue
);
765 /* Out of color table bounds - use black */
766 *Color
= RGB(0, 0, 0);
769 case 0x02: /* PALETTERGB */
770 pdc
= DC_LockDc(hDC
);
771 if (pdc
->dclevel
.hpal
!= NtGdiGetStockObject(DEFAULT_PALETTE
))
773 index
= NtGdiGetNearestPaletteIndex(pdc
->dclevel
.hpal
, *Color
);
774 IntGetPaletteEntries(pdc
->dclevel
.hpal
, index
, 1, &palEntry
);
775 *Color
= RGB(palEntry
.peRed
, palEntry
.peGreen
, palEntry
.peBlue
);
779 /* Use the pure color */
780 *Color
= *Color
& 0x00FFFFFF;
784 case 0x01: /* PALETTEINDEX */
785 pdc
= DC_LockDc(hDC
);
786 if (IntGetPaletteEntries(pdc
->dclevel
.hpal
, LOWORD(*Color
), 1, &palEntry
) == 1)
788 *Color
= RGB(palEntry
.peRed
, palEntry
.peGreen
, palEntry
.peBlue
);
792 /* Index does not exist, use zero index */
793 IntGetPaletteEntries(pdc
->dclevel
.hpal
, 0, 1, &palEntry
);
794 *Color
= RGB(palEntry
.peRed
, palEntry
.peGreen
, palEntry
.peBlue
);
799 DPRINT("Unsupported color type %d passed\n", *Color
>> 24);
814 if ((Color
& 0xFF000000) != 0)
816 IntHandleSpecialColorType(hDC
, &Color
);
819 hBrush
= NtGdiCreateSolidBrush(Color
, NULL
);
823 OldBrush
= NtGdiSelectBrush(hDC
, hBrush
);
824 if (OldBrush
== NULL
)
826 GreDeleteObject(hBrush
);
830 NtGdiPatBlt(hDC
, X
, Y
, 1, 1, PATCOPY
);
831 NtGdiSelectBrush(hDC
, OldBrush
);
832 GreDeleteObject(hBrush
);
844 DPRINT("0 NtGdiSetPixel X %ld Y %ld C %ld\n", X
, Y
, Color
);
846 if (GdiSetPixelV(hDC
,X
,Y
,Color
))
848 Color
= NtGdiGetPixel(hDC
,X
,Y
);
849 DPRINT("1 NtGdiSetPixel X %ld Y %ld C %ld\n", X
, Y
, Color
);
853 Color
= (COLORREF
)CLR_INVALID
;
854 DPRINT("2 NtGdiSetPixel X %ld Y %ld C %ld\n", X
, Y
, Color
);
859 /* Internal Functions */
862 BITMAP_GetRealBitsPixel(UINT nBitsPixel
)
870 if (nBitsPixel
<= 16)
872 if (nBitsPixel
<= 24)
874 if (nBitsPixel
<= 32)
881 BITMAP_GetWidthBytes(INT bmWidth
, INT bpp
)
887 return 2 * ((bmWidth
+15) >> 4);
890 bmWidth
*= 3; /* fall through */
892 return bmWidth
+ (bmWidth
& 1);
902 return 2 * ((bmWidth
+3) >> 2);
911 return ((bmWidth
* bpp
+ 15) & ~15) >> 3;
915 BITMAP_CopyBitmap(HBITMAP hBitmap
)
919 SURFACE
*Bitmap
, *resBitmap
;
927 Bitmap
= SURFACE_LockSurface(hBitmap
);
933 BITMAP_GetObject(Bitmap
, sizeof(BITMAP
), (PVOID
)&bm
);
935 if (Bitmap
->SurfObj
.lDelta
>= 0)
936 bm
.bmHeight
= -bm
.bmHeight
;
938 Size
.cx
= abs(bm
.bmWidth
);
939 Size
.cy
= abs(bm
.bmHeight
);
940 res
= GreCreateBitmapEx(Size
.cx
,
943 Bitmap
->SurfObj
.iBitmapFormat
,
944 Bitmap
->SurfObj
.fjBitmap
,
945 Bitmap
->SurfObj
.cjBits
,
952 resBitmap
= SURFACE_LockSurface(res
);
955 IntSetBitmapBits(resBitmap
, Bitmap
->SurfObj
.cjBits
, Bitmap
->SurfObj
.pvBits
);
956 SURFACE_UnlockSurface(resBitmap
);
960 GreDeleteObject(res
);
965 SURFACE_UnlockSurface(Bitmap
);
971 BITMAP_GetObject(SURFACE
*psurf
, INT Count
, LPVOID buffer
)
975 if (!buffer
) return sizeof(BITMAP
);
976 if ((UINT
)Count
< sizeof(BITMAP
)) return 0;
978 /* always fill a basic BITMAP structure */
981 pBitmap
->bmWidth
= psurf
->SurfObj
.sizlBitmap
.cx
;
982 pBitmap
->bmHeight
= psurf
->SurfObj
.sizlBitmap
.cy
;
983 pBitmap
->bmPlanes
= 1;
984 pBitmap
->bmBitsPixel
= BitsPerFormat(psurf
->SurfObj
.iBitmapFormat
);
985 pBitmap
->bmWidthBytes
= BITMAP_GetWidthBytes(pBitmap
->bmWidth
, pBitmap
->bmBitsPixel
);
987 /* Check for DIB section */
990 /* Set bmBits in this case */
991 pBitmap
->bmBits
= psurf
->SurfObj
.pvBits
;
992 /* DIBs data are 32 bits aligned */
993 pBitmap
->bmWidthBytes
= DIB_GetDIBWidthBytes(pBitmap
->bmWidth
, pBitmap
->bmBitsPixel
);
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 if(psurf
->ppal
->Mode
& PAL_BITFIELDS
)
1007 pds
->dsBmih
.biCompression
= BI_BITFIELDS
;
1011 switch (psurf
->SurfObj
.iBitmapFormat
)
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
;
1035 pds
->dsBmih
.biSizeImage
= psurf
->SurfObj
.cjBits
;
1036 pds
->dsBmih
.biXPelsPerMeter
= 0;
1037 pds
->dsBmih
.biYPelsPerMeter
= 0;
1038 pds
->dsBmih
.biClrUsed
= psurf
->ppal
->NumColors
;
1039 pds
->dsBmih
.biClrImportant
= psurf
->biClrImportant
;
1040 pds
->dsBitfields
[0] = psurf
->ppal
->RedMask
;
1041 pds
->dsBitfields
[1] = psurf
->ppal
->GreenMask
;
1042 pds
->dsBitfields
[2] = psurf
->ppal
->BlueMask
;
1043 pds
->dshSection
= psurf
->hDIBSection
;
1044 pds
->dsOffset
= psurf
->dwOffset
;
1046 return sizeof(DIBSECTION
);
1051 /* not set according to wine test, confirmed in win2k */
1052 pBitmap
->bmBits
= NULL
;
1055 return sizeof(BITMAP
);
1063 NtGdiGetDCforBitmap(
1067 PSURFACE psurf
= SURFACE_LockSurface(hsurf
);
1071 SURFACE_UnlockSurface(psurf
);