ReactOS  0.4.9-dev-717-g6d91262
bitmap.c File Reference
#include <precomp.h>
#include <debug.h>
Include dependency graph for bitmap.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define WIDTH_BYTES_ALIGN32(cx, bpp)   ((((cx) * (bpp) + 31) & ~31) >> 3)
 

Functions

INT FASTCALL DIB_BitmapInfoSize (const BITMAPINFO *info, WORD coloruse, BOOL max)
 
UINT FASTCALL DIB_BitmapMaxBitsSize (PBITMAPINFO Info, UINT ScanLines)
 
INT WINAPI DIB_GetBitmapInfo (const BITMAPINFOHEADER *header, PLONG width, PLONG height, PWORD planes, PWORD bpp, PLONG compr, PLONG size)
 
int WINAPI GdiGetBitmapBitsSize (BITMAPINFO *lpbmi)
 
HBITMAP WINAPI CreateDIBSection (HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
 
HBITMAP WINAPI CreateBitmap (INT Width, INT Height, UINT Planes, UINT BitsPixel, CONST VOID *pUnsafeBits)
 
HBITMAP WINAPI CreateBitmapIndirect (const BITMAP *pbm)
 
HBITMAP WINAPI CreateDiscardableBitmap (HDC hDC, INT Width, INT Height)
 
HBITMAP WINAPI CreateCompatibleBitmap (HDC hDC, INT Width, INT Height)
 
INT WINAPI GetDIBits (HDC hDC, HBITMAP hbmp, UINT uStartScan, UINT cScanLines, LPVOID lpvBits, LPBITMAPINFO lpbmi, UINT uUsage)
 
HBITMAP WINAPI CreateDIBitmap (HDC hDC, const BITMAPINFOHEADER *Header, DWORD Init, LPCVOID Bits, const BITMAPINFO *Data, UINT ColorUse)
 
INT WINAPI SetDIBits (HDC hDC, HBITMAP hBitmap, UINT uStartScan, UINT cScanLines, CONST VOID *lpvBits, CONST BITMAPINFO *lpbmi, UINT fuColorUse)
 
INT WINAPI SetDIBitsToDevice (HDC hdc, int XDest, int YDest, DWORD Width, DWORD Height, int XSrc, int YSrc, UINT StartScan, UINT ScanLines, CONST VOID *Bits, CONST BITMAPINFO *lpbmi, UINT ColorUse)
 
int WINAPI StretchDIBits (HDC hdc, int XDest, int YDest, int nDestWidth, int nDestHeight, int XSrc, int YSrc, int nSrcWidth, int nSrcHeight, CONST VOID *lpBits, CONST BITMAPINFO *lpBitsInfo, UINT iUsage, DWORD dwRop)
 
DWORD WINAPI GetBitmapAttributes (HBITMAP hbm)
 
HBITMAP WINAPI SetBitmapAttributes (HBITMAP hbm, DWORD dwFlags)
 
HBITMAP WINAPI ClearBitmapAttributes (HBITMAP hbm, DWORD dwFlags)
 
HBITMAP WINAPI GdiConvertBitmapV5 (HBITMAP in_format_BitMap, HBITMAP src_BitMap, INT bpp, INT unuse)
 

Macro Definition Documentation

#define NDEBUG

Definition at line 3 of file bitmap.c.

#define WIDTH_BYTES_ALIGN32 (   cx,
  bpp 
)    ((((cx) * (bpp) + 31) & ~31) >> 3)

Definition at line 7 of file bitmap.c.

Referenced by DIB_BitmapMaxBitsSize(), and GdiGetBitmapBitsSize().

Function Documentation

HBITMAP WINAPI ClearBitmapAttributes ( HBITMAP  hbm,
DWORD  dwFlags 
)

Definition at line 918 of file bitmap.c.

919 {
922  return 0;
923 }
#define SetLastError(x)
Definition: compat.h:409
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define UNIMPLEMENTED
Definition: debug.h:114
HBITMAP WINAPI CreateBitmap ( INT  Width,
INT  Height,
UINT  Planes,
UINT  BitsPixel,
CONST VOID pUnsafeBits 
)

Definition at line 252 of file bitmap.c.

Referenced by CreateBitmapIndirect(), test_32bit_ddb(), test_bitmap(), test_bitmap_colors(), test_bmBits(), test_CreateBitmap(), test_CreateBitmapFromHICON(), test_GdiAlphaBlend(), test_get16dibits(), test_GetDIBits(), test_GetDIBits_selected_DDB(), test_mono_bitmap(), test_select_object(), and test_StretchBlt().

258 {
259  if (Width && Height)
260  {
261  return NtGdiCreateBitmap(Width, Height, Planes, BitsPixel, (LPBYTE) pUnsafeBits);
262  }
263  else
264  {
265  /* Return 1x1 bitmap */
267  }
268 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
__kernel_entry W32KAPI HBITMAP APIENTRY NtGdiCreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBPP, _In_opt_ LPBYTE pjInit)
unsigned char * LPBYTE
Definition: typedefs.h:52
#define DEFAULT_BITMAP
Definition: ntgdityp.h:192
HBITMAP WINAPI CreateBitmapIndirect ( const BITMAP pbm)

Definition at line 275 of file bitmap.c.

Referenced by test_CreateBitmap().

277 {
278  HBITMAP bitmap = NULL;
279 
280  /* Note windows xp/2003 does not check if pbm is NULL or not */
281  if ((pbm->bmWidthBytes != 0) && (!(pbm->bmWidthBytes & 1)))
282 
283  {
284  bitmap = CreateBitmap(pbm->bmWidth, pbm->bmHeight, pbm->bmPlanes, pbm->bmBitsPixel,
285  pbm->bmBits);
286  }
287  else
288  {
290  }
291 
292  return bitmap;
293 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define HBITMAP
Definition: msvc.h:28
HBITMAP WINAPI CreateBitmap(INT Width, INT Height, UINT Planes, UINT BitsPixel, CONST VOID *pUnsafeBits)
Definition: bitmap.c:252
smooth NULL
Definition: ftsmooth.c:416
Definition: uimain.c:88
#define SetLastError(x)
Definition: compat.h:409
static HBITMAP bitmap
Definition: clipboard.c:1344
HBITMAP WINAPI CreateCompatibleBitmap ( HDC  hDC,
INT  Width,
INT  Height 
)

Definition at line 307 of file bitmap.c.

Referenced by CreateDiscardableBitmap(), test_CreateBitmap(), test_createdibitmap(), test_D3DKMTCreateDCFromMemory(), test_dib_formats(), test_GdiAlphaBlend(), test_GetDIBits(), test_GetDIBits_BI_BITFIELDS(), test_GetDIBits_selected_DDB(), test_GetSetDIBits_rtl(), and test_select_object().

311 {
312  PDC_ATTR pDc_Attr;
313 
314  if (!GdiGetHandleUserData(hDC, GDI_OBJECT_TYPE_DC, (PVOID) & pDc_Attr))
315  return NULL;
316 
317  if (!Width || !Height)
319 
320  if (!(pDc_Attr->ulDirty_ & DC_DIBSECTION))
321  {
322  return NtGdiCreateCompatibleBitmap(hDC, Width, Height);
323  }
324  else
325  {
326  HBITMAP hBmp = NULL;
327  struct
328  {
329  BITMAP bitmap;
330  BITMAPINFOHEADER bmih;
331  RGBQUAD rgbquad[256];
332  } buffer;
333  DIBSECTION* pDIBs = (DIBSECTION*) &buffer;
334  BITMAPINFO* pbmi = (BITMAPINFO*) &buffer.bmih;
335 
337 
338  if (GetObjectA(hBmp, sizeof(DIBSECTION), pDIBs) != sizeof(DIBSECTION))
339  return NULL;
340 
341  if (pDIBs->dsBm.bmBitsPixel <= 8)
342  GetDIBColorTable(hDC, 0, 256, buffer.rgbquad);
343 
344  pDIBs->dsBmih.biWidth = Width;
345  pDIBs->dsBmih.biHeight = Height;
346 
347  return CreateDIBSection(hDC, pbmi, DIB_RGB_COLORS, NULL, NULL, 0);
348  }
349  return NULL;
350 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
DWORD *typedef PVOID
Definition: winlogon.h:52
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
BITMAPINFOHEADER dsBmih
Definition: wingdi.h:1647
#define HBITMAP
Definition: msvc.h:28
__kernel_entry W32KAPI HBITMAP APIENTRY NtGdiCreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO pbmi
Definition: ntgdi.h:2780
#define DC_DIBSECTION
Definition: ntgdihdl.h:159
GLuint buffer
Definition: glext.h:5915
smooth NULL
Definition: ftsmooth.c:416
#define DEFAULT_BITMAP
Definition: ntgdityp.h:192
UINT WINAPI GetDIBColorTable(HDC hDC, UINT iStartIndex, UINT cEntries, RGBQUAD *pColors)
Definition: palette.c:123
__kernel_entry W32KAPI HANDLE APIENTRY NtGdiGetDCObject(_In_ HDC hdc, _In_ INT itype)
HDC hDC
Definition: wglext.h:521
#define GDI_OBJECT_TYPE_DC
Definition: gdi.h:46
#define GDI_OBJECT_TYPE_BITMAP
Definition: gdi.h:48
PVOID GdiGetHandleUserData(_In_ HGDIOBJ hobj)
Definition: gditools.c:68
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:197
Definition: bl.h:1331
BITMAP dsBm
Definition: wingdi.h:1646
static HBITMAP bitmap
Definition: clipboard.c:1344
#define DIB_RGB_COLORS
Definition: wingdi.h:365
HBITMAP WINAPI CreateDIBitmap ( HDC  hDC,
const BITMAPINFOHEADER Header,
DWORD  Init,
LPCVOID  Bits,
const BITMAPINFO Data,
UINT  ColorUse 
)

Definition at line 398 of file bitmap.c.

Referenced by test_createdibitmap(), and test_dib_formats().

405 {
406  LONG Width, Height, Compression, DibSize;
407  WORD Planes, BitsPerPixel;
408 // PDC_ATTR pDc_Attr;
409  UINT cjBmpScanSize = 0;
410  HBITMAP hBitmap = NULL;
411  PBITMAPINFO pbmiConverted;
412  UINT cjInfoSize;
413 
414  /* Convert the BITMAPINFO if it is a COREINFO */
415  pbmiConverted = ConvertBitmapInfo(Data, ColorUse, &cjInfoSize, FALSE);
416 
417  /* Check for CBM_CREATDIB */
418  if (Init & CBM_CREATDIB)
419  {
420  if (cjInfoSize == 0)
421  {
422  goto Exit;
423  }
424  else if (Init & CBM_INIT)
425  {
426  if (Bits == NULL)
427  {
428  goto Exit;
429  }
430  }
431  else
432  {
433  Bits = NULL;
434  }
435 
436  /* CBM_CREATDIB needs Data. */
437  if (pbmiConverted == NULL)
438  {
439  DPRINT1("CBM_CREATDIB needs a BITMAPINFO!\n");
440  goto Exit;
441  }
442 
443  /* It only works with PAL or RGB */
444  if (ColorUse > DIB_PAL_COLORS)
445  {
446  DPRINT1("Invalid ColorUse: %lu\n", ColorUse);
448  goto Exit;
449  }
450 
451  /* Use the header from the data */
452  Header = &Data->bmiHeader;
453  }
454  else
455  {
456  if (Init & CBM_INIT)
457  {
458  if (Bits != NULL)
459  {
460  if (cjInfoSize == 0)
461  {
462  goto Exit;
463  }
464  }
465  else
466  {
467  Init &= ~CBM_INIT;
468  }
469  }
470  }
471 
472  /* Header is required */
473  if (!Header)
474  {
475  DPRINT1("Header is NULL\n");
477  goto Exit;
478  }
479 
480  /* Get the bitmap format and dimensions */
481  if (DIB_GetBitmapInfo(Header, &Width, &Height, &Planes, &BitsPerPixel, &Compression, &DibSize) == -1)
482  {
483  DPRINT1("DIB_GetBitmapInfo failed!\n");
485  goto Exit;
486  }
487 
488  /* Check if the Compr is incompatible */
489  if ((Compression == BI_JPEG) || (Compression == BI_PNG) || (Compression == BI_BITFIELDS))
490  {
491  DPRINT1("Invalid compression: %lu!\n", Compression);
492  goto Exit;
493  }
494 
495  /* Only DIB_RGB_COLORS (0), DIB_PAL_COLORS (1) and 2 are valid. */
496  if (ColorUse > DIB_PAL_COLORS + 1)
497  {
498  DPRINT1("Invalid compression: %lu!\n", Compression);
500  goto Exit;
501  }
502 
503  /* If some Bits are given, only DIB_PAL_COLORS and DIB_RGB_COLORS are valid */
504  if (Bits && (ColorUse > DIB_PAL_COLORS))
505  {
506  DPRINT1("Invalid ColorUse: %lu\n", ColorUse);
508  goto Exit;
509  }
510 
511  /* Negative width is not allowed */
512  if (Width < 0)
513  {
514  DPRINT1("Negative width: %li\n", Width);
515  goto Exit;
516  }
517 
518  /* Top-down DIBs have a negative height. */
519  Height = abs(Height);
520 
521 // For Icm support.
522 // GdiGetHandleUserData(hdc, GDI_OBJECT_TYPE_DC, (PVOID)&pDc_Attr))
523 
524  cjBmpScanSize = GdiGetBitmapBitsSize(pbmiConverted);
525 
526  DPRINT("pBMI %p, Size bpp %u, dibsize %d, Conv %u, BSS %u\n",
527  Data, BitsPerPixel, DibSize, cjInfoSize, cjBmpScanSize);
528 
529  if (!Width || !Height)
530  {
531  hBitmap = GetStockObject(DEFAULT_BITMAP);
532  }
533  else
534  {
536  Width,
537  Height,
538  Init,
539  (LPBYTE)Bits,
540  (LPBITMAPINFO)pbmiConverted,
541  ColorUse,
542  cjInfoSize,
543  cjBmpScanSize,
544  0, 0);
545  }
546 
547 Exit:
548  /* Cleanup converted BITMAPINFO */
549  if ((pbmiConverted != NULL) && (pbmiConverted != Data))
550  {
551  RtlFreeHeap(RtlGetProcessHeap(), 0, pbmiConverted);
552  }
553 
554  return hBitmap;
555 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define abs(i)
Definition: fconv.c:206
unsigned short WORD
Definition: ntddk_ex.h:93
#define HBITMAP
Definition: msvc.h:28
__kernel_entry W32KAPI HBITMAP APIENTRY NtGdiCreateDIBitmapInternal(_In_ HDC hdc, _In_ INT cx, _In_ INT cy, _In_ DWORD fInit, _In_reads_bytes_opt_(cjMaxBits) LPBYTE pjInit, _In_reads_bytes_opt_(cjMaxInitInfo) LPBITMAPINFO pbmi, _In_ DWORD iUsage, _In_ UINT cjMaxInitInfo, _In_ UINT cjMaxBits, _In_ FLONG f, _In_ HANDLE hcmXform)
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1453
#define DIB_PAL_COLORS
Definition: wingdi.h:364
unsigned char * LPBYTE
Definition: typedefs.h:52
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
#define BI_JPEG
Definition: wingdi.h:38
#define BI_BITFIELDS
Definition: mmreg.h:507
#define CBM_INIT
Definition: wingdi.h:363
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define DEFAULT_BITMAP
Definition: ntgdityp.h:192
HDC hDC
Definition: wglext.h:521
static void Exit(void)
Definition: sock.c:1331
VOID WINAPI GdiSetLastError(DWORD dwErrCode)
Definition: misc.c:873
int WINAPI GdiGetBitmapBitsSize(BITMAPINFO *lpbmi)
Definition: bitmap.c:161
#define BI_PNG
Definition: wingdi.h:39
unsigned int UINT
Definition: ndis.h:50
#define DPRINT1
Definition: precomp.h:8
#define CBM_CREATDIB
INT WINAPI DIB_GetBitmapInfo(const BITMAPINFOHEADER *header, PLONG width, PLONG height, PWORD planes, PWORD bpp, PLONG compr, PLONG size)
Definition: bitmap.c:97
LPBITMAPINFO WINAPI ConvertBitmapInfo(CONST BITMAPINFO *BitmapInfo, UINT ColorSpec, UINT *BitmapInfoSize, BOOL FollowedByData)
Definition: utils.c:172
static HBITMAP hBitmap
Definition: timezone.c:34
HBITMAP WINAPI CreateDIBSection ( HDC  hDC,
CONST BITMAPINFO BitmapInfo,
UINT  Usage,
VOID **  Bits,
HANDLE  hSection,
DWORD  dwOffset 
)

Definition at line 197 of file bitmap.c.

Referenced by alpha_blend_hdc_pixels(), alpha_blend_image(), ARGB2BMP(), BITMAP_CopyImage(), BITMAP_LoadImageW(), ConvertBitmapTo32Bpp(), Create24BppBitmap(), Create32BitHBITMAP(), create_bitmap(), create_dib(), create_hatch_bitmap(), create_render_dc(), create_test_bitmap(), create_test_icon(), CreateCompatibleBitmap(), CreateDIBWithProperties(), ATL::CImage::CreateInternal(), CreateStarBitmap(), draw_graphics(), DrawDibBegin(), DrawShadowText(), GdipCreateBitmapFromScan0(), GdipCreateHBITMAPFromBitmap(), GdipDrawImagePointsRect(), GdipGetDC(), ID3DXFontImpl_DrawTextW(), ImageList_CreateImage(), InitBitmap(), InitLogo(), InitPerBitDepth(), LoadDIBImage(), mi_paint_rect(), mstsc_ProtocolIOThread(), OLEPictureImpl_LoadWICSource(), PaintCells(), PlayEnhMetaFileRecord(), START_TEST(), sw_fb_renderbuffer_storage(), test_32bit_ddb(), test_alpha_hdc(), test_BitBlt(), test_bitmap_colors(), test_bitmap_font_glyph_index(), test_bitmap_rendering(), test_bitmapinfoheadersize(), test_boundsrect(), test_clipping(), test_color_table(), test_CopyImage_Bitmap(), test_CreateIcon(), test_data_handles(), test_device_caps(), test_dib_formats(), test_DIB_PAL_COLORS(), Test_Dibsection(), test_dibsections(), test_DrawDib_sizeimage(), test_DrawIcon(), test_DrawIconEx(), test_DrawState(), test_emf_BitBlt(), test_GdiAlphaBlend(), test_GdiGradientFill(), test_GdipCreateBitmapFromHBITMAP(), test_GetCursorFrameInfo(), Test_GetDIBColorTable(), test_GetDIBits_BI_BITFIELDS(), test_GetDIBits_scanlines(), test_GetDIBits_selected_DIB(), test_GetDIBits_top_down(), test_hdc_caching(), test_ImageList_DrawIndirect(), Test_MaskBlt_16bpp(), Test_MaskBlt_1bpp(), Test_MaskBlt_32bpp(), Test_MaskBlt_Brush(), test_mono_dibsection(), Test_NtGdiDoPalette_SetDIBColorTable(), test_palette_brush(), test_path_state(), test_pattern_brush(), Test_SelectDIBSection(), Test_SetDIBits(), test_SetDIBits(), test_SetDIBits_RLE4(), test_SetDIBits_RLE8(), test_SetDIBitsToDevice(), test_SetDIBitsToDevice_RLE8(), Test_SetPixel_PAL(), test_simple_graphics(), Test_SrcMono(), test_StretchBlt(), test_StretchDIBits(), UXTHEME_DrawThemePartToDib(), and WinGCreateBitmap().

204 {
205  PBITMAPINFO pConvertedInfo;
206  UINT ConvertedInfoSize;
207  HBITMAP hBitmap = NULL;
208  PVOID bmBits = NULL;
209 
210  pConvertedInfo = ConvertBitmapInfo(BitmapInfo, Usage, &ConvertedInfoSize,
211  FALSE);
212 
213  if (pConvertedInfo)
214  {
215  // Verify header due to converted may == info.
216  if (pConvertedInfo->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER))
217  {
218  if (pConvertedInfo->bmiHeader.biCompression == BI_JPEG
219  || pConvertedInfo->bmiHeader.biCompression == BI_PNG)
220  {
222  return NULL;
223  }
224  }
225  bmBits = Bits;
226  hBitmap = NtGdiCreateDIBSection(hDC, hSection, dwOffset, pConvertedInfo, Usage,
227  ConvertedInfoSize, 0, // fl
228  0, // dwColorSpace
229  &bmBits);
230 
231  if (BitmapInfo != pConvertedInfo)
232  RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo);
233 
234  if (!hBitmap)
235  {
236  bmBits = NULL;
237  }
238  }
239 
240  if (Bits)
241  *Bits = bmBits;
242 
243  return hBitmap;
244 }
DWORD *typedef PVOID
Definition: winlogon.h:52
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define HBITMAP
Definition: msvc.h:28
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1453
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:382
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
#define BI_JPEG
Definition: wingdi.h:38
_In_ DWORD _In_ DWORD dwOffset
Definition: ntgdi.h:2032
__kernel_entry W32KAPI HBITMAP APIENTRY NtGdiCreateDIBSection(_In_ HDC hdc, _In_opt_ HANDLE hSectionApp, _In_ DWORD dwOffset, _In_reads_bytes_opt_(cjHeader) LPBITMAPINFO pbmi, _In_ DWORD iUsage, _In_ UINT cjHeader, _In_ FLONG fl, _In_ ULONG_PTR dwColorSpace, _Outptr_ PVOID *ppvBits)
#define FALSE
Definition: types.h:117
DWORD biCompression
Definition: amvideo.idl:35
smooth NULL
Definition: ftsmooth.c:416
HDC hDC
Definition: wglext.h:521
#define SetLastError(x)
Definition: compat.h:409
#define BI_PNG
Definition: wingdi.h:39
unsigned int UINT
Definition: ndis.h:50
LPBITMAPINFO WINAPI ConvertBitmapInfo(CONST BITMAPINFO *BitmapInfo, UINT ColorSpec, UINT *BitmapInfoSize, BOOL FollowedByData)
Definition: utils.c:172
_In_ const BITMAPINFO _In_ UINT _In_opt_ HANDLE hSection
Definition: wingdi.h:3216
static HBITMAP hBitmap
Definition: timezone.c:34
HBITMAP WINAPI CreateDiscardableBitmap ( HDC  hDC,
INT  Width,
INT  Height 
)

Definition at line 297 of file bitmap.c.

Referenced by test_CreateBitmap().

301 {
302  return CreateCompatibleBitmap(hDC, Width, Height);
303 }
HBITMAP WINAPI CreateCompatibleBitmap(HDC hDC, INT Width, INT Height)
Definition: bitmap.c:307
HDC hDC
Definition: wglext.h:521
INT FASTCALL DIB_BitmapInfoSize ( const BITMAPINFO info,
WORD  coloruse,
BOOL  max 
)

Definition at line 17 of file bitmap.c.

Referenced by GetDIBits(), IntSynthesizeBitmap(), and IntSynthesizeDib().

21 {
22  unsigned int colors, size, masks = 0;
23 
24  if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
25  {
26  const BITMAPCOREHEADER *core = (const BITMAPCOREHEADER *) info;
27  size = sizeof(BITMAPCOREHEADER);
28  if (core->bcBitCount <= 8)
29  {
30  colors = 1 << core->bcBitCount;
31  if (coloruse == DIB_RGB_COLORS)
32  size += colors * sizeof(RGBTRIPLE);
33  else
34  size += colors * sizeof(WORD);
35  }
36  return size;
37  }
38  else /* assume BITMAPINFOHEADER */
39  {
40  colors = max ? (1 << info->bmiHeader.biBitCount) : info->bmiHeader.biClrUsed;
41  if (colors > 256)
42  colors = 256;
43  if (!colors && (info->bmiHeader.biBitCount <= 8))
44  colors = 1 << info->bmiHeader.biBitCount;
46  masks = 3;
47  size = max(info->bmiHeader.biSize, sizeof(BITMAPINFOHEADER) + masks * sizeof(DWORD));
48  return size + colors * ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) : sizeof(WORD));
49  }
50 }
#define max(a, b)
Definition: svc.c:63
unsigned short WORD
Definition: ntddk_ex.h:93
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1453
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
#define BI_BITFIELDS
Definition: mmreg.h:507
DWORD DWORD
Definition: winlogon.h:75
DWORD biCompression
Definition: amvideo.idl:35
struct tagRGBTRIPLE RGBTRIPLE
GLsizeiptr size
Definition: glext.h:5919
if(!(yy_init))
Definition: macro.lex.yy.c:717
struct tagBITMAPCOREHEADER BITMAPCOREHEADER
#define DIB_RGB_COLORS
Definition: wingdi.h:365
static const BYTE masks[8]
Definition: dib.c:2760
UINT FASTCALL DIB_BitmapMaxBitsSize ( PBITMAPINFO  Info,
UINT  ScanLines 
)

Definition at line 59 of file bitmap.c.

Referenced by GetDIBits(), and SetDIBitsToDevice().

62 {
63  UINT Ret;
64 
65  if (!Info)
66  return 0;
67 
68  if (Info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
69  {
71  Ret = WIDTH_BYTES_ALIGN32(Core->bcWidth * Core->bcPlanes,
72  Core->bcBitCount) * ScanLines;
73  }
74  else /* assume BITMAPINFOHEADER */
75  {
77  {
78  Ret = WIDTH_BYTES_ALIGN32(
79  Info->bmiHeader.biWidth * Info->bmiHeader.biPlanes,
80  Info->bmiHeader.biBitCount) * ScanLines;
81  }
82  else
83  {
84  Ret = Info->bmiHeader.biSizeImage;
85  }
86  }
87  return Ret;
88 }
#define WIDTH_BYTES_ALIGN32(cx, bpp)
Definition: bitmap.c:7
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1453
#define BI_BITFIELDS
Definition: mmreg.h:507
DWORD biCompression
Definition: amvideo.idl:35
DWORD biSizeImage
Definition: amvideo.idl:36
struct tagBITMAPCOREHEADER * PBITMAPCOREHEADER
unsigned int UINT
Definition: ndis.h:50
#define BI_RGB
Definition: precomp.h:35
INT WINAPI DIB_GetBitmapInfo ( const BITMAPINFOHEADER header,
PLONG  width,
PLONG  height,
PWORD  planes,
PWORD  bpp,
PLONG  compr,
PLONG  size 
)

Definition at line 97 of file bitmap.c.

Referenced by CreateDIBitmap().

105 {
106  if (header->biSize == sizeof(BITMAPCOREHEADER))
107  {
108  BITMAPCOREHEADER *core = (BITMAPCOREHEADER *) header;
109  *width = core->bcWidth;
110  *height = core->bcHeight;
111  *planes = core->bcPlanes;
112  *bpp = core->bcBitCount;
113  *compr = 0;
114  *size = 0;
115  return 0;
116  }
117 
118  if (header->biSize == sizeof(BITMAPINFOHEADER))
119  {
120  *width = header->biWidth;
121  *height = header->biHeight;
122  *planes = header->biPlanes;
123  *bpp = header->biBitCount;
124  *compr = header->biCompression;
125  *size = header->biSizeImage;
126  return 1;
127  }
128 
129  if (header->biSize == sizeof(BITMAPV4HEADER))
130  {
131  BITMAPV4HEADER *v4hdr = (BITMAPV4HEADER *) header;
132  *width = v4hdr->bV4Width;
133  *height = v4hdr->bV4Height;
134  *planes = v4hdr->bV4Planes;
135  *bpp = v4hdr->bV4BitCount;
136  *compr = v4hdr->bV4V4Compression;
137  *size = v4hdr->bV4SizeImage;
138  return 4;
139  }
140 
141  if (header->biSize == sizeof(BITMAPV5HEADER))
142  {
143  BITMAPV5HEADER *v5hdr = (BITMAPV5HEADER *) header;
144  *width = v5hdr->bV5Width;
145  *height = v5hdr->bV5Height;
146  *planes = v5hdr->bV5Planes;
147  *bpp = v5hdr->bV5BitCount;
148  *compr = v5hdr->bV5Compression;
149  *size = v5hdr->bV5SizeImage;
150  return 5;
151  }
152  DPRINT("(%lu): wrong size for header\n", header->biSize);
153  return -1;
154 }
DWORD bV4SizeImage
Definition: wingdi.h:1475
LONG bV4Height
Definition: wingdi.h:1471
DWORD biCompression
Definition: amvideo.idl:35
WORD bV4BitCount
Definition: wingdi.h:1473
void DPRINT(...)
Definition: polytest.cpp:61
DWORD bV4V4Compression
Definition: wingdi.h:1474
WORD bV4Planes
Definition: wingdi.h:1472
LONG bV4Width
Definition: wingdi.h:1470
GLsizeiptr size
Definition: glext.h:5919
GLint GLint GLsizei width
Definition: gl.h:1546
static int compr(const void *a, const void *b)
Definition: bidi.c:685
DWORD biSizeImage
Definition: amvideo.idl:36
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
DWORD bpp
Definition: surface.c:181
HBITMAP WINAPI GdiConvertBitmapV5 ( HBITMAP  in_format_BitMap,
HBITMAP  src_BitMap,
INT  bpp,
INT  unuse 
)

Definition at line 931 of file bitmap.c.

936 {
937  /* FIXME guessing the prototypes */
938 
939  /*
940  * it have create a new bitmap with desired in format,
941  * then convert it src_bitmap to new format
942  * and return it as HBITMAP
943  */
944 
945  return FALSE;
946 }
#define FALSE
Definition: types.h:117
int WINAPI GdiGetBitmapBitsSize ( BITMAPINFO lpbmi)

Definition at line 161 of file bitmap.c.

Referenced by ConvertBitmapInfo(), CreateDIBitmap(), and StretchDIBits().

163 {
164  UINT Ret;
165 
166  if (!lpbmi)
167  return 0;
168 
169  if (lpbmi->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
170  {
171  PBITMAPCOREHEADER Core = (PBITMAPCOREHEADER) lpbmi;
172  Ret =
173  WIDTH_BYTES_ALIGN32(Core->bcWidth * Core->bcPlanes,
174  Core->bcBitCount) * Core->bcHeight;
175  }
176  else /* assume BITMAPINFOHEADER */
177  {
178  if (!(lpbmi->bmiHeader.biCompression) || (lpbmi->bmiHeader.biCompression == BI_BITFIELDS))
179  {
180  Ret = WIDTH_BYTES_ALIGN32(
181  lpbmi->bmiHeader.biWidth * lpbmi->bmiHeader.biPlanes,
182  lpbmi->bmiHeader.biBitCount) * abs(lpbmi->bmiHeader.biHeight);
183  }
184  else
185  {
186  Ret = lpbmi->bmiHeader.biSizeImage;
187  }
188  }
189  return Ret;
190 }
#define abs(i)
Definition: fconv.c:206
#define WIDTH_BYTES_ALIGN32(cx, bpp)
Definition: bitmap.c:7
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1453
#define BI_BITFIELDS
Definition: mmreg.h:507
DWORD biCompression
Definition: amvideo.idl:35
DWORD biSizeImage
Definition: amvideo.idl:36
struct tagBITMAPCOREHEADER * PBITMAPCOREHEADER
unsigned int UINT
Definition: ndis.h:50
DWORD WINAPI GetBitmapAttributes ( HBITMAP  hbm)

Definition at line 894 of file bitmap.c.

895 {
898  return 0;
899 }
#define SetLastError(x)
Definition: compat.h:409
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define UNIMPLEMENTED
Definition: debug.h:114
INT WINAPI GetDIBits ( HDC  hDC,
HBITMAP  hbmp,
UINT  uStartScan,
UINT  cScanLines,
LPVOID  lpvBits,
LPBITMAPINFO  lpbmi,
UINT  uUsage 
)

Definition at line 354 of file bitmap.c.

Referenced by test_createdibitmap(), test_dib_formats(), test_dibsections(), test_get16dibits(), test_GetDIBits(), test_GetDIBits_BI_BITFIELDS(), test_GetDIBits_scanlines(), test_GetDIBits_selected_DDB(), test_GetDIBits_selected_DIB(), test_GetDIBits_top_down(), and test_GetSetDIBits_rtl().

362 {
363  UINT cjBmpScanSize;
364  UINT cjInfoSize;
365 
366  if (!hDC || !GdiValidateHandle((HGDIOBJ) hDC) || !lpbmi)
367  {
369  return 0;
370  }
371 
372  cjBmpScanSize = DIB_BitmapMaxBitsSize(lpbmi, cScanLines);
373  /* Caller must provide maximum size possible */
374  cjInfoSize = DIB_BitmapInfoSize(lpbmi, uUsage, TRUE);
375 
376  if (lpvBits)
377  {
378  if (lpbmi->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER))
379  {
380  if (lpbmi->bmiHeader.biCompression == BI_JPEG
381  || lpbmi->bmiHeader.biCompression == BI_PNG)
382  {
384  return 0;
385  }
386  }
387  }
388 
389  return NtGdiGetDIBitsInternal(hDC, hbmp, uStartScan, cScanLines, lpvBits, lpbmi, uUsage,
390  cjBmpScanSize, cjInfoSize);
391 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1453
#define BI_JPEG
Definition: wingdi.h:38
UINT FASTCALL DIB_BitmapMaxBitsSize(PBITMAPINFO Info, UINT ScanLines)
Definition: bitmap.c:59
INT FASTCALL DIB_BitmapInfoSize(const BITMAPINFO *info, WORD coloruse, BOOL max)
Definition: bitmap.c:17
DWORD biCompression
Definition: amvideo.idl:35
HDC hDC
Definition: wglext.h:521
#define SetLastError(x)
Definition: compat.h:409
VOID WINAPI GdiSetLastError(DWORD dwErrCode)
Definition: misc.c:873
#define BI_PNG
Definition: wingdi.h:39
unsigned int UINT
Definition: ndis.h:50
HBITMAP hbmp
Definition: msvc.h:60
BOOL WINAPI GdiValidateHandle(HGDIOBJ)
Definition: misc.c:712
HBITMAP WINAPI SetBitmapAttributes ( HBITMAP  hbm,
DWORD  dwFlags 
)

Definition at line 906 of file bitmap.c.

907 {
910  return 0;
911 }
#define SetLastError(x)
Definition: compat.h:409
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define UNIMPLEMENTED
Definition: debug.h:114
INT WINAPI SetDIBits ( HDC  hDC,
HBITMAP  hBitmap,
UINT  uStartScan,
UINT  cScanLines,
CONST VOID lpvBits,
CONST BITMAPINFO lpbmi,
UINT  fuColorUse 
)

Definition at line 562 of file bitmap.c.

Referenced by test_dib_bits_access(), test_dib_formats(), test_GetDIBits(), test_GetSetDIBits_rtl(), test_SetDIBits(), test_SetDIBits_RLE4(), and test_SetDIBits_RLE8().

570 {
571  HDC hDCc, SavehDC, nhDC;
573  HGDIOBJ hOldBitmap;
574  HPALETTE hPal = NULL;
575  INT LinesCopied = 0;
576  BOOL newDC = FALSE;
577 
578  if (!lpvBits || (GDI_HANDLE_GET_TYPE(hBitmap) != GDI_OBJECT_TYPE_BITMAP))
579  return 0;
580 
581  if (lpbmi->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER))
582  {
583  if (lpbmi->bmiHeader.biCompression == BI_JPEG
584  || lpbmi->bmiHeader.biCompression == BI_PNG)
585  {
587  return 0;
588  }
589  }
590 
591  hDCc = NtGdiGetDCforBitmap(hBitmap); // hDC can be NULL, so, get it from the bitmap.
592  SavehDC = hDCc;
593  if (!hDCc) // No DC associated with bitmap, Clone or Create one.
594  {
595  nhDC = CreateCompatibleDC(hDC);
596  if (!nhDC)
597  return 0;
598  newDC = TRUE;
599  SavehDC = nhDC;
600  }
601  else if (!SaveDC(hDCc))
602  return 0;
603 
604  hOldBitmap = SelectObject(SavehDC, hBitmap);
605 
606  if (hOldBitmap)
607  {
608  if (hDC)
609  hPal = SelectPalette(SavehDC, (HPALETTE) GetCurrentObject(hDC, OBJ_PAL), FALSE);
610 
611  if (lpbmi->bmiHeader.biSize < sizeof(BITMAPINFOHEADER))
612  {
613  PBITMAPCOREINFO pbci = (PBITMAPCOREINFO) lpbmi;
614  dwWidth = pbci->bmciHeader.bcWidth;
615  dwHeight = pbci->bmciHeader.bcHeight;
616  }
617  else
618  {
619  dwWidth = lpbmi->bmiHeader.biWidth;
620  dwHeight = abs(lpbmi->bmiHeader.biHeight);
621  }
622 
623  LinesCopied = SetDIBitsToDevice(SavehDC, 0, 0, dwWidth, dwHeight, 0, 0, uStartScan,
624  cScanLines, (void *) lpvBits, (LPBITMAPINFO) lpbmi, fuColorUse);
625 
626  if (hDC)
627  SelectPalette(SavehDC, hPal, FALSE);
628 
629  SelectObject(SavehDC, hOldBitmap);
630  }
631 
632  if (newDC)
633  DeleteDC(SavehDC);
634  else
635  RestoreDC(SavehDC, -1);
636 
637  return LinesCopied;
638 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define abs(i)
Definition: fconv.c:206
#define TRUE
Definition: types.h:120
struct _BITMAPCOREINFO * PBITMAPCOREINFO
#define BI_JPEG
Definition: wingdi.h:38
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int32_t INT
Definition: typedefs.h:56
DWORD DWORD
Definition: winlogon.h:75
BITMAPCOREHEADER bmciHeader
Definition: wingdi.h:1430
#define FALSE
Definition: types.h:117
HPALETTE WINAPI SelectPalette(_In_ HDC, _In_ HPALETTE, _In_ BOOL)
smooth NULL
Definition: ftsmooth.c:416
__kernel_entry W32KAPI HDC APIENTRY NtGdiGetDCforBitmap(_In_ HBITMAP hsurf)
static const WCHAR dwHeight[]
Definition: provider.c:60
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
HDC hDC
Definition: wglext.h:521
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SetLastError(x)
Definition: compat.h:409
#define OBJ_PAL
Definition: objidl.idl:1413
#define GDI_OBJECT_TYPE_BITMAP
Definition: gdi.h:48
BOOL WINAPI DeleteDC(_In_ HDC)
#define BI_PNG
Definition: wingdi.h:39
static HDC
Definition: bitmap.c:44
int WINAPI SaveDC(_In_ HDC)
INT WINAPI SetDIBitsToDevice(HDC hdc, int XDest, int YDest, DWORD Width, DWORD Height, int XSrc, int YSrc, UINT StartScan, UINT ScanLines, CONST VOID *Bits, CONST BITMAPINFO *lpbmi, UINT ColorUse)
Definition: bitmap.c:646
BOOL WINAPI RestoreDC(_In_ HDC, _In_ int)
static HBITMAP hBitmap
Definition: timezone.c:34
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:439
static const WCHAR dwWidth[]
Definition: provider.c:59
INT WINAPI SetDIBitsToDevice ( HDC  hdc,
int  XDest,
int  YDest,
DWORD  Width,
DWORD  Height,
int  XSrc,
int  YSrc,
UINT  StartScan,
UINT  ScanLines,
CONST VOID Bits,
CONST BITMAPINFO lpbmi,
UINT  ColorUse 
)

Definition at line 646 of file bitmap.c.

Referenced by SetDIBits(), test_dib_formats(), test_mono_dibsection(), test_SetDIBitsToDevice(), and test_SetDIBitsToDevice_RLE8().

659 {
660  PDC_ATTR pDc_Attr;
661  PBITMAPINFO pConvertedInfo;
662  UINT ConvertedInfoSize;
663  INT LinesCopied = 0;
664  UINT cjBmpScanSize = 0;
665  BOOL Hit = FALSE;
666  PVOID pvSafeBits = (PVOID) Bits;
667 
668  if (!ScanLines || !lpbmi || !Bits)
669  return 0;
670 
671  if (ColorUse && ColorUse != DIB_PAL_COLORS && ColorUse != DIB_PAL_COLORS + 1)
672  return 0;
673 
674  pConvertedInfo = ConvertBitmapInfo(lpbmi, ColorUse, &ConvertedInfoSize, FALSE);
675  if (!pConvertedInfo)
676  return 0;
677 
680  0,
681  hdc,
682  XDest,
683  YDest,
684  Width,
685  Height,
686  XSrc,
687  YSrc,
688  StartScan,
689  ScanLines,
690  Bits,
691  lpbmi,
692  ColorUse);
693 
694  if ((pConvertedInfo->bmiHeader.biCompression == BI_RLE8) ||
695  (pConvertedInfo->bmiHeader.biCompression == BI_RLE4))
696  {
697  /* For compressed data, we must set the whole thing */
698  StartScan = 0;
699  ScanLines = pConvertedInfo->bmiHeader.biHeight;
700  }
701 
702  cjBmpScanSize = DIB_BitmapMaxBitsSize((LPBITMAPINFO) lpbmi, ScanLines);
703 
704  pvSafeBits = RtlAllocateHeap(GetProcessHeap(), 0, cjBmpScanSize);
705  if (pvSafeBits)
706  {
707  _SEH2_TRY
708  {
709  RtlCopyMemory(pvSafeBits, Bits, cjBmpScanSize);
710  }
712  {
713  Hit = TRUE;
714  }
715  _SEH2_END
716 
717  if (Hit)
718  {
719  // We don't die, we continue on with a allocated safe pointer to kernel
720  // space.....
721  DPRINT1("SetDIBitsToDevice fail to read BitMapInfo: %p or Bits: %p & Size: %u\n",
722  pConvertedInfo, Bits, cjBmpScanSize);
723  }
724  DPRINT("SetDIBitsToDevice Allocate Bits %u!!!\n", cjBmpScanSize);
725  }
726 
727  if (!GdiGetHandleUserData(hdc, GDI_OBJECT_TYPE_DC, (PVOID) & pDc_Attr))
728  {
730  return 0;
731  }
732  /*
733  if ( !pDc_Attr || // DC is Public
734  ColorUse == DIB_PAL_COLORS ||
735  ((pConvertedInfo->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER)) &&
736  (pConvertedInfo->bmiHeader.biCompression == BI_JPEG ||
737  pConvertedInfo->bmiHeader.biCompression == BI_PNG )) )*/
738  {
739  LinesCopied = NtGdiSetDIBitsToDeviceInternal(hdc, XDest, YDest, Width, Height, XSrc, YSrc,
740  StartScan, ScanLines, (LPBYTE) pvSafeBits, (LPBITMAPINFO) pConvertedInfo, ColorUse,
741  cjBmpScanSize, ConvertedInfoSize,
742  TRUE,
743  NULL);
744  }
745  if (Bits != pvSafeBits)
746  RtlFreeHeap(RtlGetProcessHeap(), 0, pvSafeBits);
747  if (lpbmi != pConvertedInfo)
748  RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo);
749 
750  return LinesCopied;
751 }
DWORD *typedef PVOID
Definition: winlogon.h:52
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1453
#define DIB_PAL_COLORS
Definition: wingdi.h:364
unsigned char * LPBYTE
Definition: typedefs.h:52
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
UINT FASTCALL DIB_BitmapMaxBitsSize(PBITMAPINFO Info, UINT ScanLines)
Definition: bitmap.c:59
int32_t INT
Definition: typedefs.h:56
#define HANDLE_METADC(_RetType, _Func, dwError, hdc,...)
Definition: gdi32p.h:547
_SEH2_TRY
Definition: create.c:4250
#define FALSE
Definition: types.h:117
DWORD biCompression
Definition: amvideo.idl:35
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
#define SetLastError(x)
Definition: compat.h:409
__kernel_entry W32KAPI INT APIENTRY NtGdiSetDIBitsToDeviceInternal(_In_ HDC hdcDest, _In_ INT xDst, _In_ INT yDst, _In_ DWORD cx, _In_ DWORD cy, _In_ INT xSrc, _In_ INT ySrc, _In_ DWORD iStartScan, _In_ DWORD cNumScan, _In_reads_bytes_(cjMaxBits) LPBYTE pInitBits, _In_reads_bytes_(cjMaxInfo) LPBITMAPINFO pbmi, _In_ DWORD iUsage, _In_ UINT cjMaxBits, _In_ UINT cjMaxInfo, _In_ BOOL bTransformCoordinates, _In_opt_ HANDLE hcmXform)
#define GDI_OBJECT_TYPE_DC
Definition: gdi.h:46
_SEH2_END
Definition: create.c:4424
PVOID GdiGetHandleUserData(_In_ HGDIOBJ hobj)
Definition: gditools.c:68
unsigned int UINT
Definition: ndis.h:50
#define BI_RLE4
Definition: precomp.h:36
#define DPRINT1
Definition: precomp.h:8
INT WINAPI SetDIBitsToDevice(HDC hdc, int XDest, int YDest, DWORD Width, DWORD Height, int XSrc, int YSrc, UINT StartScan, UINT ScanLines, CONST VOID *Bits, CONST BITMAPINFO *lpbmi, UINT ColorUse)
Definition: bitmap.c:646
LPBITMAPINFO WINAPI ConvertBitmapInfo(CONST BITMAPINFO *BitmapInfo, UINT ColorSpec, UINT *BitmapInfoSize, BOOL FollowedByData)
Definition: utils.c:172
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define BI_RLE8
Definition: wingdi.h:35
int WINAPI StretchDIBits ( HDC  hdc,
int  XDest,
int  YDest,
int  nDestWidth,
int  nDestHeight,
int  XSrc,
int  YSrc,
int  nSrcWidth,
int  nSrcHeight,
CONST VOID lpBits,
CONST BITMAPINFO lpBitsInfo,
UINT  iUsage,
DWORD  dwRop 
)

Definition at line 758 of file bitmap.c.

Referenced by check_StretchDIBits_pixel(), check_StretchDIBits_stretch(), and test_dib_formats().

773 {
774  PDC_ATTR pDc_Attr;
775  PBITMAPINFO pConvertedInfo = NULL;
776  UINT ConvertedInfoSize = 0;
777  INT LinesCopied = 0;
778  UINT cjBmpScanSize = 0;
779  PVOID pvSafeBits = NULL;
780  BOOL Hit = FALSE;
781 
782  DPRINT("StretchDIBits %p : %p : %u\n", lpBits, lpBitsInfo, iUsage);
783 #if 0
784 // Handle something other than a normal dc object.
786  {
788  return MFDRV_StretchBlt( hdc,
789  XDest,
790  YDest,
791  nDestWidth,
792  nDestHeight,
793  XSrc,
794  YSrc,
795  nSrcWidth,
796  nSrcHeight,
797  lpBits,
798  lpBitsInfo,
799  iUsage,
800  dwRop);
801  else
802  {
803  PLDC pLDC = GdiGetLDC(hdc);
804  if ( !pLDC )
805  {
807  return 0;
808  }
809  if (pLDC->iType == LDC_EMFLDC)
810  {
811  return EMFDRV_StretchBlt(hdc,
812  XDest,
813  YDest,
814  nDestWidth,
815  nDestHeight,
816  XSrc,
817  YSrc,
818  nSrcWidth,
819  nSrcHeight,
820  lpBits,
821  lpBitsInfo,
822  iUsage,
823  dwRop);
824  }
825  return 0;
826  }
827  }
828 #endif
829  pConvertedInfo = ConvertBitmapInfo(lpBitsInfo, iUsage, &ConvertedInfoSize,
830  FALSE);
831  if (!pConvertedInfo)
832  {
833  return 0;
834  }
835 
836  cjBmpScanSize = GdiGetBitmapBitsSize((BITMAPINFO *) pConvertedInfo);
837 
838  if (lpBits)
839  {
840  pvSafeBits = RtlAllocateHeap(GetProcessHeap(), 0, cjBmpScanSize);
841  if (pvSafeBits)
842  {
843  _SEH2_TRY
844  {
845  RtlCopyMemory(pvSafeBits, lpBits, cjBmpScanSize);
846  }
848  {
849  Hit = TRUE;
850  }
851  _SEH2_END
852 
853  if (Hit)
854  {
855  // We don't die, we continue on with a allocated safe pointer to kernel
856  // space.....
857  DPRINT1("StretchDIBits fail to read BitMapInfo: %p or Bits: %p & Size: %u\n",
858  pConvertedInfo, lpBits, cjBmpScanSize);
859  }
860  DPRINT("StretchDIBits Allocate Bits %u!!!\n", cjBmpScanSize);
861  }
862  }
863 
864  if (!GdiGetHandleUserData(hdc, GDI_OBJECT_TYPE_DC, (PVOID) & pDc_Attr))
865  {
867  return 0;
868  }
869  /*
870  if ( !pDc_Attr ||
871  iUsage == DIB_PAL_COLORS ||
872  ((pConvertedInfo->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER)) &&
873  (pConvertedInfo->bmiHeader.biCompression == BI_JPEG ||
874  pConvertedInfo->bmiHeader.biCompression == BI_PNG )) )*/
875  {
876  LinesCopied = NtGdiStretchDIBitsInternal(hdc, XDest, YDest, nDestWidth, nDestHeight, XSrc,
877  YSrc, nSrcWidth, nSrcHeight, pvSafeBits, pConvertedInfo, (DWORD) iUsage, dwRop,
878  ConvertedInfoSize, cjBmpScanSize,
879  NULL);
880  }
881  if (pvSafeBits)
882  RtlFreeHeap(RtlGetProcessHeap(), 0, pvSafeBits);
883  if (lpBitsInfo != pConvertedInfo)
884  RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo);
885 
886  return LinesCopied;
887 }
DWORD *typedef PVOID
Definition: winlogon.h:52
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
__kernel_entry W32KAPI INT APIENTRY NtGdiStretchDIBitsInternal(_In_ HDC hdc, _In_ INT xDst, _In_ INT yDst, _In_ INT cxDst, _In_ INT cyDst, _In_ INT xSrc, _In_ INT ySrc, _In_ INT cxSrc, _In_ INT cySrc, _In_reads_bytes_opt_(cjMaxBits) LPBYTE pjInit, _In_ LPBITMAPINFO pbmi, _In_ DWORD dwUsage, _In_ DWORD dwRop4, _In_ UINT cjMaxInfo, _In_ UINT cjMaxBits, _In_opt_ HANDLE hcmXform)
BOOL MFDRV_StretchBlt(PHYSDEV devDst, struct bitblt_coords *dst, PHYSDEV devSrc, struct bitblt_coords *src, DWORD rop)
Definition: bitblt.c:47
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
BOOL EMFDRV_StretchBlt(PHYSDEV devDst, struct bitblt_coords *dst, PHYSDEV devSrc, struct bitblt_coords *src, DWORD rop)
Definition: bitblt.c:67
int32_t INT
Definition: typedefs.h:56
DWORD DWORD
Definition: winlogon.h:75
_SEH2_TRY
Definition: create.c:4250
#define FALSE
Definition: types.h:117
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define LDC_EMFLDC
Definition: ntgdihdl.h:171
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
PLDC FASTCALL GdiGetLDC(HDC hDC)
Definition: misc.c:785
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
#define SetLastError(x)
Definition: compat.h:409
#define GDI_OBJECT_TYPE_METADC
Definition: gdi.h:57
Definition: ntgdihdl.h:271
INT iType
Definition: ntgdihdl.h:275
#define GDI_OBJECT_TYPE_DC
Definition: gdi.h:46
_SEH2_END
Definition: create.c:4424
int WINAPI GdiGetBitmapBitsSize(BITMAPINFO *lpbmi)
Definition: bitmap.c:161
PVOID GdiGetHandleUserData(_In_ HGDIOBJ hobj)
Definition: gditools.c:68
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO _In_ UINT iUsage
Definition: ntgdi.h:2780
unsigned int UINT
Definition: ndis.h:50
#define DPRINT1
Definition: precomp.h:8
LPBITMAPINFO WINAPI ConvertBitmapInfo(CONST BITMAPINFO *BitmapInfo, UINT ColorSpec, UINT *BitmapInfoSize, BOOL FollowedByData)
Definition: utils.c:172
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6