ReactOS  0.4.15-dev-1201-gb2cf5a4
bitblt.c File Reference
#include <string.h>
#include "mfdrv/metafiledrv.h"
#include "wine/debug.h"
Include dependency graph for bitblt.c:

Go to the source code of this file.

Macros

#define STRETCH_VIA_DIB
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (metafile)
 
BOOL MFDRV_PatBlt (PHYSDEV dev, struct bitblt_coords *dst, DWORD rop)
 
BOOL MFDRV_StretchBlt (PHYSDEV devDst, struct bitblt_coords *dst, PHYSDEV devSrc, struct bitblt_coords *src, DWORD rop)
 
INT MFDRV_StretchDIBits (PHYSDEV dev, INT xDst, INT yDst, INT widthDst, INT heightDst, INT xSrc, INT ySrc, INT widthSrc, INT heightSrc, const void *bits, BITMAPINFO *info, UINT wUsage, DWORD dwRop)
 
INT MFDRV_SetDIBitsToDevice (PHYSDEV dev, INT xDst, INT yDst, DWORD cx, DWORD cy, INT xSrc, INT ySrc, UINT startscan, UINT lines, LPCVOID bits, BITMAPINFO *info, UINT coloruse)
 

Macro Definition Documentation

◆ STRETCH_VIA_DIB

#define STRETCH_VIA_DIB

Definition at line 45 of file bitblt.c.

Function Documentation

◆ MFDRV_PatBlt()

BOOL MFDRV_PatBlt ( PHYSDEV  dev,
struct bitblt_coords dst,
DWORD  rop 
)

Definition at line 31 of file bitblt.c.

32 {
33  MFDRV_MetaParam6( dev, META_PATBLT, dst->log_x, dst->log_y, dst->log_width, dst->log_height,
34  HIWORD(rop), LOWORD(rop) );
35  return TRUE;
36 }
#define TRUE
Definition: types.h:120
#define META_PATBLT
Definition: wingdi.h:238
static int rop(int rop, int src, int dst)
Definition: nanoxwin.c:124
BOOL MFDRV_MetaParam6(PHYSDEV dev, short func, short param1, short param2, short param3, short param4, short param5, short param6)
Definition: init.c:587
GLenum GLenum dst
Definition: glext.h:6340
#define HIWORD(l)
Definition: typedefs.h:247
#define LOWORD(l)
Definition: pedump.c:82

◆ MFDRV_SetDIBitsToDevice()

INT MFDRV_SetDIBitsToDevice ( PHYSDEV  dev,
INT  xDst,
INT  yDst,
DWORD  cx,
DWORD  cy,
INT  xSrc,
INT  ySrc,
UINT  startscan,
UINT  lines,
LPCVOID  bits,
BITMAPINFO info,
UINT  coloruse 
)

Definition at line 166 of file bitblt.c.

170 {
171  DWORD infosize = get_dib_info_size(info, coloruse);
172  DWORD len = sizeof(METARECORD) + 8 * sizeof(WORD) + infosize + info->bmiHeader.biSizeImage;
173  METARECORD *mr = HeapAlloc( GetProcessHeap(), 0, len );
174  if(!mr) return 0;
175 
176  mr->rdSize = len / 2;
178  mr->rdParm[0] = coloruse;
179  mr->rdParm[1] = lines;
180  mr->rdParm[2] = startscan;
181  mr->rdParm[3] = (INT16)ySrc;
182  mr->rdParm[4] = (INT16)xSrc;
183  mr->rdParm[5] = (INT16)cy;
184  mr->rdParm[6] = (INT16)cx;
185  mr->rdParm[7] = (INT16)yDst;
186  mr->rdParm[8] = (INT16)xDst;
187  memcpy(mr->rdParm + 9, info, infosize);
188  memcpy(mr->rdParm + 9 + infosize / 2, bits, info->bmiHeader.biSizeImage);
189  MFDRV_WriteRecord( dev, mr, mr->rdSize * 2 );
190  HeapFree( GetProcessHeap(), 0, mr );
191  return lines;
192 }
WORD rdFunction
Definition: wingdi.h:2345
struct tagMETARECORD METARECORD
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
DWORD rdSize
Definition: wingdi.h:2344
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
eMaj lines
Definition: tritemp.h:206
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define META_SETDIBTODEV
Definition: wingdi.h:259
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
WORD rdParm[1]
Definition: wingdi.h:2346
_Out_opt_ int * cx
Definition: commctrl.h:581
static int get_dib_info_size(const BITMAPINFO *info, UINT coloruse)
Definition: gdi_private.h:180
BOOL MFDRV_WriteRecord(PHYSDEV dev, METARECORD *mr, DWORD rlen)
Definition: init.c:475
#define HeapFree(x, y, z)
Definition: compat.h:594
signed short INT16

◆ MFDRV_StretchBlt()

BOOL MFDRV_StretchBlt ( PHYSDEV  devDst,
struct bitblt_coords dst,
PHYSDEV  devSrc,
struct bitblt_coords src,
DWORD  rop 
)

Definition at line 47 of file bitblt.c.

49 {
50  BOOL ret;
51  DWORD len;
52  METARECORD *mr;
53  BITMAP BM;
54 #ifdef STRETCH_VIA_DIB
55  LPBITMAPINFOHEADER lpBMI;
56  WORD nBPP;
57 #endif
59 
60  if (devSrc->funcs == devDst->funcs) return FALSE; /* can't use a metafile DC as source */
61 
62  if (GetObjectW(hBitmap, sizeof(BITMAP), &BM) != sizeof(BITMAP))
63  {
64  WARN("bad bitmap object %p passed for hdc %p\n", hBitmap, devSrc->hdc);
65  return FALSE;
66  }
67 #ifdef STRETCH_VIA_DIB
68  nBPP = BM.bmPlanes * BM.bmBitsPixel;
69  if(nBPP > 8) nBPP = 24; /* FIXME Can't get 16bpp to work for some reason */
70  len = sizeof(METARECORD) + 10 * sizeof(INT16)
71  + sizeof(BITMAPINFOHEADER) + (nBPP <= 8 ? 1 << nBPP: 0) * sizeof(RGBQUAD)
72  + get_dib_stride( BM.bmWidth, nBPP ) * BM.bmHeight;
73  if (!(mr = HeapAlloc( GetProcessHeap(), 0, len)))
74  return FALSE;
76  lpBMI=(LPBITMAPINFOHEADER)(mr->rdParm+10);
77  lpBMI->biSize = sizeof(BITMAPINFOHEADER);
78  lpBMI->biWidth = BM.bmWidth;
79  lpBMI->biHeight = BM.bmHeight;
80  lpBMI->biPlanes = 1;
81  lpBMI->biBitCount = nBPP;
82  lpBMI->biSizeImage = get_dib_image_size( (BITMAPINFO *)lpBMI );
83  lpBMI->biClrUsed = nBPP <= 8 ? 1 << nBPP : 0;
84  lpBMI->biCompression = BI_RGB;
85  lpBMI->biXPelsPerMeter = MulDiv(GetDeviceCaps(devSrc->hdc,LOGPIXELSX),3937,100);
86  lpBMI->biYPelsPerMeter = MulDiv(GetDeviceCaps(devSrc->hdc,LOGPIXELSY),3937,100);
87  lpBMI->biClrImportant = 0; /* 1 meter = 39.37 inch */
88 
89  TRACE("MF_StretchBltViaDIB->len = %d rop=%x PixYPM=%d Caps=%d\n",
91 
92  if (GetDIBits(devSrc->hdc, hBitmap, 0, (UINT)lpBMI->biHeight,
93  (LPSTR)lpBMI + get_dib_info_size( (BITMAPINFO *)lpBMI, DIB_RGB_COLORS ),
95 #else
96  len = sizeof(METARECORD) + 15 * sizeof(INT16) + BM.bmWidthBytes * BM.bmHeight;
97  if (!(mr = HeapAlloc( GetProcessHeap(), 0, len )))
98  return FALSE;
100  *(mr->rdParm +10) = BM.bmWidth;
101  *(mr->rdParm +11) = BM.bmHeight;
102  *(mr->rdParm +12) = BM.bmWidthBytes;
103  *(mr->rdParm +13) = BM.bmPlanes;
104  *(mr->rdParm +14) = BM.bmBitsPixel;
105  TRACE("len = %ld rop=%lx\n", len, rop);
106  if (GetBitmapBits( hBitmap, BM.bmWidthBytes * BM.bmHeight, mr->rdParm + 15))
107 #endif
108  {
109  mr->rdSize = len / sizeof(INT16);
110  *(mr->rdParm) = LOWORD(rop);
111  *(mr->rdParm + 1) = HIWORD(rop);
112  *(mr->rdParm + 2) = src->log_height;
113  *(mr->rdParm + 3) = src->log_width;
114  *(mr->rdParm + 4) = src->log_y;
115  *(mr->rdParm + 5) = src->log_x;
116  *(mr->rdParm + 6) = dst->log_height;
117  *(mr->rdParm + 7) = dst->log_width;
118  *(mr->rdParm + 8) = dst->log_y;
119  *(mr->rdParm + 9) = dst->log_x;
120  ret = MFDRV_WriteRecord( devDst, mr, mr->rdSize * 2);
121  }
122  else
123  ret = FALSE;
124  HeapFree( GetProcessHeap(), 0, mr);
125  return ret;
126 }
#define LOGPIXELSX
Definition: wingdi.h:717
DWORD biClrImportant
Definition: amvideo.idl:40
LONG biXPelsPerMeter
Definition: amvideo.idl:37
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
#define WARN(fmt,...)
Definition: debug.h:112
WORD rdFunction
Definition: wingdi.h:2345
char * LPSTR
Definition: xmlstorage.h:182
struct tagMETARECORD METARECORD
LONG biYPelsPerMeter
Definition: amvideo.idl:38
DWORD rdSize
Definition: wingdi.h:2344
static int get_dib_image_size(const BITMAPINFO *info)
Definition: imagelist.c:203
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static int get_dib_stride(int width, int bpp)
Definition: imagelist.c:198
static int rop(int rop, int src, int dst)
Definition: nanoxwin.c:124
DWORD biCompression
Definition: amvideo.idl:35
#define META_DIBSTRETCHBLT
Definition: wingdi.h:267
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
ULONG RGBQUAD
Definition: precomp.h:50
struct BITMAPINFOHEADER * LPBITMAPINFOHEADER
LONG WINAPI GetBitmapBits(_In_ HBITMAP hbit, _In_ LONG cb, _Out_writes_bytes_(cb) LPVOID lpvBits)
#define META_STRETCHBLT
Definition: wingdi.h:244
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD biSizeImage
Definition: amvideo.idl:36
int ret
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
WORD rdParm[1]
Definition: wingdi.h:2346
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
Definition: bl.h:1331
GLenum GLenum dst
Definition: glext.h:6340
unsigned int UINT
Definition: ndis.h:50
int WINAPI GetDIBits(_In_ HDC hdc, _In_ HBITMAP hbm, _In_ UINT start, _In_ UINT cLines, _Out_opt_ LPVOID lpvBits, _At_((LPBITMAPINFOHEADER) lpbmi, _Inout_) LPBITMAPINFO lpbmi, _In_ UINT usage)
static int get_dib_info_size(const BITMAPINFO *info, UINT coloruse)
Definition: gdi_private.h:180
#define HIWORD(l)
Definition: typedefs.h:247
BOOL MFDRV_WriteRecord(PHYSDEV dev, METARECORD *mr, DWORD rlen)
Definition: init.c:475
#define LOGPIXELSY
Definition: wingdi.h:718
static HBITMAP
Definition: button.c:44
const struct gdi_dc_funcs * funcs
Definition: gdi_driver.h:31
#define DIB_RGB_COLORS
Definition: wingdi.h:366
#define BI_RGB
Definition: precomp.h:47
static HBITMAP hBitmap
Definition: timezone.c:26
#define LOWORD(l)
Definition: pedump.c:82
#define OBJ_BITMAP
Definition: objidl.idl:1415
#define HeapFree(x, y, z)
Definition: compat.h:594
#define MulDiv(x, y, z)
Definition: gdifloat.h:86
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:441
signed short INT16

Referenced by StretchDIBits().

◆ MFDRV_StretchDIBits()

INT MFDRV_StretchDIBits ( PHYSDEV  dev,
INT  xDst,
INT  yDst,
INT  widthDst,
INT  heightDst,
INT  xSrc,
INT  ySrc,
INT  widthSrc,
INT  heightSrc,
const void bits,
BITMAPINFO info,
UINT  wUsage,
DWORD  dwRop 
)

Definition at line 132 of file bitblt.c.

136 {
137  DWORD infosize = get_dib_info_size(info, wUsage);
138  DWORD len = sizeof(METARECORD) + 10 * sizeof(WORD) + infosize + info->bmiHeader.biSizeImage;
139  METARECORD *mr = HeapAlloc( GetProcessHeap(), 0, len );
140  if(!mr) return 0;
141 
142  mr->rdSize = len / 2;
144  mr->rdParm[0] = LOWORD(dwRop);
145  mr->rdParm[1] = HIWORD(dwRop);
146  mr->rdParm[2] = wUsage;
147  mr->rdParm[3] = (INT16)heightSrc;
148  mr->rdParm[4] = (INT16)widthSrc;
149  mr->rdParm[5] = (INT16)ySrc;
150  mr->rdParm[6] = (INT16)xSrc;
151  mr->rdParm[7] = (INT16)heightDst;
152  mr->rdParm[8] = (INT16)widthDst;
153  mr->rdParm[9] = (INT16)yDst;
154  mr->rdParm[10] = (INT16)xDst;
155  memcpy(mr->rdParm + 11, info, infosize);
156  memcpy(mr->rdParm + 11 + infosize / 2, bits, info->bmiHeader.biSizeImage);
157  MFDRV_WriteRecord( dev, mr, mr->rdSize * 2 );
158  HeapFree( GetProcessHeap(), 0, mr );
159  return heightSrc;
160 }
#define META_STRETCHDIB
Definition: wingdi.h:269
WORD rdFunction
Definition: wingdi.h:2345
struct tagMETARECORD METARECORD
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
DWORD rdSize
Definition: wingdi.h:2344
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
WORD rdParm[1]
Definition: wingdi.h:2346
static int get_dib_info_size(const BITMAPINFO *info, UINT coloruse)
Definition: gdi_private.h:180
#define HIWORD(l)
Definition: typedefs.h:247
BOOL MFDRV_WriteRecord(PHYSDEV dev, METARECORD *mr, DWORD rlen)
Definition: init.c:475
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:594
signed short INT16

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( metafile  )