Rounds to the lowest integer, not the nearest.
[wine.git] / graphics / bitblt.c
blob9e2572505c4986c52fe934b042ce563b59a1453e
1 /*
2 * GDI bit-blit operations
4 * Copyright 1993, 1994 Alexandre Julliard
5 */
7 #include "dc.h"
8 #include "debugtools.h"
10 DEFAULT_DEBUG_CHANNEL(bitblt)
11 DECLARE_DEBUG_CHANNEL(bitmap)
12 DECLARE_DEBUG_CHANNEL(gdi)
15 /***********************************************************************
16 * PatBlt16 (GDI.29)
18 BOOL16 WINAPI PatBlt16( HDC16 hdc, INT16 left, INT16 top,
19 INT16 width, INT16 height, DWORD rop)
21 DC * dc = DC_GetDCPtr( hdc );
22 if (!dc || !dc->funcs->pPatBlt) return FALSE;
24 TRACE("%04x %d,%d %dx%d %06lx\n", hdc, left, top, width, height, rop );
25 return dc->funcs->pPatBlt( dc, left, top, width, height, rop );
29 /***********************************************************************
30 * PatBlt32 (GDI32.260)
32 BOOL WINAPI PatBlt( HDC hdc, INT left, INT top,
33 INT width, INT height, DWORD rop)
35 DC * dc = DC_GetDCPtr( hdc );
36 if (!dc || !dc->funcs->pPatBlt) return FALSE;
38 TRACE("%04x %d,%d %dx%d %06lx\n", hdc, left, top, width, height, rop );
39 return dc->funcs->pPatBlt( dc, left, top, width, height, rop );
43 /***********************************************************************
44 * BitBlt16 (GDI.34)
46 BOOL16 WINAPI BitBlt16( HDC16 hdcDst, INT16 xDst, INT16 yDst, INT16 width,
47 INT16 height, HDC16 hdcSrc, INT16 xSrc, INT16 ySrc,
48 DWORD rop )
50 DC *dcDst, *dcSrc;
52 if (!(dcDst = DC_GetDCPtr( hdcDst ))) return FALSE;
53 if (!dcDst->funcs->pBitBlt) return FALSE;
54 dcSrc = DC_GetDCPtr( hdcSrc );
56 TRACE("hdcSrc=%04x %d,%d %d bpp->hdcDest=%04x %d,%d %dx%dx%d rop=%06lx\n",
57 hdcSrc, xSrc, ySrc, dcSrc ? dcSrc->w.bitsPerPixel : 0,
58 hdcDst, xDst, yDst, width, height, dcDst->w.bitsPerPixel, rop);
59 return dcDst->funcs->pBitBlt( dcDst, xDst, yDst, width, height,
60 dcSrc, xSrc, ySrc, rop );
64 /***********************************************************************
65 * BitBlt32 (GDI32.10)
67 BOOL WINAPI BitBlt( HDC hdcDst, INT xDst, INT yDst, INT width,
68 INT height, HDC hdcSrc, INT xSrc, INT ySrc,
69 DWORD rop )
71 DC *dcDst, *dcSrc;
73 if (!(dcDst = DC_GetDCPtr( hdcDst ))) return FALSE;
74 if (!dcDst->funcs->pBitBlt) return FALSE;
75 dcSrc = DC_GetDCPtr( hdcSrc );
77 TRACE("hdcSrc=%04x %d,%d %d bpp->hdcDest=%04x %d,%d %dx%dx%d rop=%06lx\n",
78 hdcSrc, xSrc, ySrc, dcSrc ? dcSrc->w.bitsPerPixel : 0,
79 hdcDst, xDst, yDst, width, height, dcDst->w.bitsPerPixel, rop);
80 return dcDst->funcs->pBitBlt( dcDst, xDst, yDst, width, height,
81 dcSrc, xSrc, ySrc, rop );
85 /***********************************************************************
86 * StretchBlt16 (GDI.35)
88 BOOL16 WINAPI StretchBlt16( HDC16 hdcDst, INT16 xDst, INT16 yDst,
89 INT16 widthDst, INT16 heightDst,
90 HDC16 hdcSrc, INT16 xSrc, INT16 ySrc,
91 INT16 widthSrc, INT16 heightSrc, DWORD rop )
93 DC *dcDst, *dcSrc;
95 if (!(dcDst = DC_GetDCPtr( hdcDst ))) return FALSE;
96 if (!dcDst->funcs->pStretchBlt) return FALSE;
97 dcSrc = DC_GetDCPtr( hdcSrc );
99 TRACE("%04x %d,%d %dx%dx%d -> %04x %d,%d %dx%dx%d rop=%06lx\n",
100 hdcSrc, xSrc, ySrc, widthSrc, heightSrc,
101 dcSrc ? dcSrc->w.bitsPerPixel : 0, hdcDst, xDst, yDst,
102 widthDst, heightDst, dcDst->w.bitsPerPixel, rop );
103 return dcDst->funcs->pStretchBlt( dcDst, xDst, yDst, widthDst, heightDst,
104 dcSrc, xSrc, ySrc, widthSrc, heightSrc,
105 rop );
109 /***********************************************************************
110 * StretchBlt32 (GDI32.350)
112 BOOL WINAPI StretchBlt( HDC hdcDst, INT xDst, INT yDst,
113 INT widthDst, INT heightDst,
114 HDC hdcSrc, INT xSrc, INT ySrc,
115 INT widthSrc, INT heightSrc, DWORD rop )
117 DC *dcDst, *dcSrc;
119 if (!(dcDst = DC_GetDCPtr( hdcDst ))) return FALSE;
120 if (!dcDst->funcs->pStretchBlt) return FALSE;
121 dcSrc = DC_GetDCPtr( hdcSrc );
123 TRACE("%04x %d,%d %dx%dx%d -> %04x %d,%d %dx%dx%d rop=%06lx\n",
124 hdcSrc, xSrc, ySrc, widthSrc, heightSrc,
125 dcSrc ? dcSrc->w.bitsPerPixel : 0, hdcDst, xDst, yDst,
126 widthDst, heightDst, dcDst->w.bitsPerPixel, rop );
127 return dcDst->funcs->pStretchBlt( dcDst, xDst, yDst, widthDst, heightDst,
128 dcSrc, xSrc, ySrc, widthSrc, heightSrc,
129 rop );
133 /***********************************************************************
134 * FastWindowFrame (GDI.400)
136 BOOL16 WINAPI FastWindowFrame16( HDC16 hdc, const RECT16 *rect,
137 INT16 width, INT16 height, DWORD rop )
139 HBRUSH hbrush = SelectObject( hdc, GetStockObject( GRAY_BRUSH ) );
140 PatBlt( hdc, rect->left, rect->top,
141 rect->right - rect->left - width, height, rop );
142 PatBlt( hdc, rect->left, rect->top + height, width,
143 rect->bottom - rect->top - height, rop );
144 PatBlt( hdc, rect->left + width, rect->bottom - 1,
145 rect->right - rect->left - width, -height, rop );
146 PatBlt( hdc, rect->right - 1, rect->top, -width,
147 rect->bottom - rect->top - height, rop );
148 SelectObject( hdc, hbrush );
149 return TRUE;
151 /***********************************************************************
152 * MaskBlt32 [GDI32.252]
154 BOOL WINAPI MaskBlt(HDC hdcDest, INT nXDest, INT nYDest,
155 INT nWidth, INT nHeight, HDC hdcSource,
156 INT nXSrc, INT nYSrc, HBITMAP hbmMask,
157 INT xMask, INT yMask, DWORD dwRop)
159 FIXME_(bitmap)("(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%ld): stub\n",
160 hdcDest,nXDest,nYDest,nWidth,nHeight,hdcSource,nXSrc,nYSrc,
161 hbmMask,xMask,yMask,dwRop);
162 return 1;
165 /*********************************************************************
166 * PlgBlt [GDI.267]
169 BOOL WINAPI PlgBlt( HDC hdcDest, const POINT *lpPoint,
170 HDC hdcSrc, INT nXDest, INT nYDest, INT nWidth,
171 INT nHeight, HBITMAP hbmMask, INT xMask, INT yMask)
173 FIXME_(gdi)("PlgBlt, stub\n");
174 return 1;