4 * Copyright (C) Robert Pouliot <krynos@clic.net>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "gdi_private.h"
30 #include "wine/wingdi16.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(wing);
35 /*************************************************************************
38 * The Windows Game dll provides a number of functions designed to allow
39 * programmers to bypass Gdi and write directly to video memory. The intention
40 * was to bolster the use of Windows as a gaming platform and remove the
41 * need for Dos based games using 32 bit Dos extenders.
43 * This initial approach could not compete with the performance of Dos games
44 * (such as Doom and Warcraft) at the time, and so this dll was eventually
45 * superseded by DirectX. It should not be used by new applications, and is
46 * provided only for compatibility with older Windows programs.
49 typedef enum WING_DITHER_TYPE
51 WING_DISPERSED_4x4, WING_DISPERSED_8x8, WING_CLUSTERED_4x4
55 * WinG DIB bitmaps can be selected into DC and then scribbled upon
56 * by GDI functions. They can also be changed directly. This gives us
58 * - use original WinG 16-bit DLL
59 * requires working 16-bit driver interface
60 * - implement DIB graphics driver from scratch
62 * - use shared pixmaps
63 * won't work with some videocards and/or videomodes
67 /***********************************************************************
68 * WinGCreateDC (WING.1001)
70 * Create a new WinG device context.
76 * Success: A handle to the created device context.
77 * Failure: A NULL handle.
79 HDC16 WINAPI WinGCreateDC16(void)
82 return CreateCompatibleDC16(0);
85 /***********************************************************************
86 * WinGRecommendDIBFormat (WING.1002)
88 * Get the recommended format of bitmaps for the current display.
91 * bmpi [O] Destination for format information
94 * Success: TRUE. bmpi is filled with the best (fastest) bitmap format
95 * Failure: FALSE, if bmpi is NULL.
97 BOOL16 WINAPI WinGRecommendDIBFormat16(BITMAPINFO *bmpi)
99 TRACE("(%p)\n", bmpi);
104 bmpi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
105 bmpi->bmiHeader.biWidth = 320;
106 bmpi->bmiHeader.biHeight = -1;
107 bmpi->bmiHeader.biPlanes = 1;
108 bmpi->bmiHeader.biBitCount = 8;
109 bmpi->bmiHeader.biCompression = BI_RGB;
110 bmpi->bmiHeader.biSizeImage = 0;
111 bmpi->bmiHeader.biXPelsPerMeter = 0;
112 bmpi->bmiHeader.biYPelsPerMeter = 0;
113 bmpi->bmiHeader.biClrUsed = 0;
114 bmpi->bmiHeader.biClrImportant = 0;
119 /***********************************************************************
120 * WinGCreateBitmap (WING.1003)
122 * Create a new WinG bitmap.
125 * hdc [I] WinG device context
126 * bmpi [I] Information about the bitmap
127 * bits [I] Location of the bitmap image data
130 * Success: A handle to the created bitmap.
131 * Failure: A NULL handle.
133 HBITMAP16 WINAPI WinGCreateBitmap16(HDC16 hdc, BITMAPINFO *bmpi,
136 TRACE("(%d,%p,%p)\n", hdc, bmpi, bits);
137 TRACE(": create %dx%dx%d bitmap\n", bmpi->bmiHeader.biWidth,
138 bmpi->bmiHeader.biHeight, bmpi->bmiHeader.biPlanes);
139 return CreateDIBSection16(hdc, bmpi, 0, bits, 0, 0);
142 /***********************************************************************
143 * WinGGetDIBPointer (WING.1004)
145 SEGPTR WINAPI WinGGetDIBPointer16(HBITMAP16 hWinGBitmap, BITMAPINFO* bmpi)
147 BITMAPOBJ* bmp = (BITMAPOBJ *) GDI_GetObjPtr( HBITMAP_32(hWinGBitmap),
151 TRACE("(%d,%p)\n", hWinGBitmap, bmpi);
154 if (bmpi) FIXME(": Todo - implement setting BITMAPINFO\n");
156 res = bmp->segptr_bits;
157 GDI_ReleaseObj( HBITMAP_32(hWinGBitmap) );
161 /***********************************************************************
162 * WinGSetDIBColorTable (WING.1006)
164 * Set all or part of the color table for a WinG device context.
167 * hdc [I] WinG device context
168 * start [I] Start color
169 * num [I] Number of entries to set
170 * colors [I] Array of color data
173 * The number of entries set.
175 UINT16 WINAPI WinGSetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
178 TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
179 return SetDIBColorTable16(hdc, start, num, colors);
182 /***********************************************************************
183 * WinGGetDIBColorTable (WING.1005)
185 * Get all or part of the color table for a WinG device context.
188 * hdc [I] WinG device context
189 * start [I] Start color
190 * num [I] Number of entries to set
191 * colors [O] Destination for the array of color data
194 * The number of entries retrieved.
196 UINT16 WINAPI WinGGetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
199 TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
200 return GetDIBColorTable16(hdc, start, num, colors);
203 /***********************************************************************
204 * WinGCreateHalfTonePalette (WING.1007)
206 * Create a half tone palette.
212 * Success: A handle to the created palette.
213 * Failure: A NULL handle.
215 HPALETTE16 WINAPI WinGCreateHalfTonePalette16(void)
217 HDC16 hdc = CreateCompatibleDC16(0);
218 HPALETTE16 ret = CreateHalftonePalette16(hdc);
224 /***********************************************************************
225 * WinGCreateHalfToneBrush (WING.1008)
227 * Create a half tone brush for a WinG device context.
230 * winDC [I] WinG device context
232 * type [I] Desired dithering type.
235 * Success: A handle to the created brush.
236 * Failure: A NULL handle.
238 HBRUSH16 WINAPI WinGCreateHalfToneBrush16(HDC16 winDC, COLORREF col,
239 WING_DITHER_TYPE type)
241 TRACE("(%d,%d,%d)\n", winDC, col, type);
242 return CreateSolidBrush16(col);
245 /***********************************************************************
246 * WinGStretchBlt (WING.1009)
250 BOOL16 WINAPI WinGStretchBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
251 INT16 widDest, INT16 heiDest,
252 HDC16 srcDC, INT16 xSrc, INT16 ySrc,
253 INT16 widSrc, INT16 heiSrc)
256 TRACE("(%d,%d,...)\n", destDC, srcDC);
257 SetStretchBltMode16 ( destDC, COLORONCOLOR );
258 retval=StretchBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
259 xSrc, ySrc, widSrc, heiSrc, SRCCOPY);
260 SetStretchBltMode16 ( destDC, BLACKONWHITE );
264 /***********************************************************************
265 * WinGBitBlt (WING.1010)
269 BOOL16 WINAPI WinGBitBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
270 INT16 widDest, INT16 heiDest, HDC16 srcDC,
271 INT16 xSrc, INT16 ySrc)
273 TRACE("(%d,%d,...)\n", destDC, srcDC);
274 return BitBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
275 xSrc, ySrc, SRCCOPY);