Release 0.9.14.
[wine/multimedia.git] / dlls / gdi / wing.c
bloba4cdc1fa22d7c53414317451cd68212c2ae87298
1 /*
2 * WinG support
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
21 #include "config.h"
23 #include "windef.h"
24 #include "wownt32.h"
25 #include "gdi.h"
26 #include "gdi_private.h"
27 #include "wine/wingdi16.h"
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(wing);
32 /*************************************************************************
33 * WING {WING}
35 * The Windows Game dll provides a number of functions designed to allow
36 * programmers to bypass Gdi and write directly to video memory. The intention
37 * was to bolster the use of Windows as a gaming platform and remove the
38 * need for Dos based games using 32 bit Dos extenders.
40 * This initial approach could not compete with the performance of Dos games
41 * (such as Doom and Warcraft) at the time, and so this dll was eventually
42 * superseded by DirectX. It should not be used by new applications, and is
43 * provided only for compatibility with older Windows programs.
46 typedef enum WING_DITHER_TYPE
48 WING_DISPERSED_4x4, WING_DISPERSED_8x8, WING_CLUSTERED_4x4
49 } WING_DITHER_TYPE;
52 * WinG DIB bitmaps can be selected into DC and then scribbled upon
53 * by GDI functions. They can also be changed directly. This gives us
54 * three choices
55 * - use original WinG 16-bit DLL
56 * requires working 16-bit driver interface
57 * - implement DIB graphics driver from scratch
58 * see wing.zip size
59 * - use shared pixmaps
60 * won't work with some videocards and/or videomodes
61 * 961208 - AK
64 /***********************************************************************
65 * WinGCreateDC (WING.1001)
67 * Create a new WinG device context.
69 * PARAMS
70 * None.
72 * RETURNS
73 * Success: A handle to the created device context.
74 * Failure: A NULL handle.
76 HDC16 WINAPI WinGCreateDC16(void)
78 TRACE("(void)\n");
79 return CreateCompatibleDC16(0);
82 /***********************************************************************
83 * WinGRecommendDIBFormat (WING.1002)
85 * Get the recommended format of bitmaps for the current display.
87 * PARAMS
88 * bmpi [O] Destination for format information
90 * RETURNS
91 * Success: TRUE. bmpi is filled with the best (fastest) bitmap format
92 * Failure: FALSE, if bmpi is NULL.
94 BOOL16 WINAPI WinGRecommendDIBFormat16(BITMAPINFO *bmpi)
96 static const WCHAR szDisplayW[] = { 'D','I','S','P','L','A','Y','\0' };
97 HDC hdc;
98 TRACE("(%p)\n", bmpi);
99 if (!bmpi)
100 return FALSE;
102 hdc = CreateDCW( szDisplayW, NULL, NULL, NULL );
103 bmpi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
104 bmpi->bmiHeader.biWidth = 320;
105 bmpi->bmiHeader.biHeight = -1;
106 bmpi->bmiHeader.biPlanes = 1;
107 bmpi->bmiHeader.biBitCount = 8;
108 bmpi->bmiHeader.biCompression = BI_RGB;
109 bmpi->bmiHeader.biSizeImage = 0;
110 bmpi->bmiHeader.biXPelsPerMeter = 0;
111 bmpi->bmiHeader.biYPelsPerMeter = 0;
112 bmpi->bmiHeader.biClrUsed = 0;
113 bmpi->bmiHeader.biClrImportant = 0;
114 DeleteDC(hdc);
115 return TRUE;
118 /***********************************************************************
119 * WinGCreateBitmap (WING.1003)
121 * Create a new WinG bitmap.
123 * PARAMS
124 * hdc [I] WinG device context
125 * bmpi [I] Information about the bitmap
126 * bits [I] Location of the bitmap image data
128 * RETURNS
129 * Success: A handle to the created bitmap.
130 * Failure: A NULL handle.
132 HBITMAP16 WINAPI WinGCreateBitmap16(HDC16 hdc, BITMAPINFO *bmpi,
133 SEGPTR *bits)
135 TRACE("(%d,%p,%p)\n", hdc, bmpi, bits);
136 TRACE(": create %ldx%ldx%d bitmap\n", bmpi->bmiHeader.biWidth,
137 bmpi->bmiHeader.biHeight, bmpi->bmiHeader.biPlanes);
138 return CreateDIBSection16(hdc, bmpi, 0, bits, 0, 0);
141 /***********************************************************************
142 * WinGGetDIBPointer (WING.1004)
144 SEGPTR WINAPI WinGGetDIBPointer16(HBITMAP16 hWinGBitmap, BITMAPINFO* bmpi)
146 BITMAPOBJ* bmp = (BITMAPOBJ *) GDI_GetObjPtr( HBITMAP_32(hWinGBitmap),
147 BITMAP_MAGIC );
148 SEGPTR res = 0;
150 TRACE("(%d,%p)\n", hWinGBitmap, bmpi);
151 if (!bmp) return 0;
153 if (bmpi) FIXME(": Todo - implement setting BITMAPINFO\n");
155 res = bmp->segptr_bits;
156 GDI_ReleaseObj( HBITMAP_32(hWinGBitmap) );
157 return res;
160 /***********************************************************************
161 * WinGSetDIBColorTable (WING.1006)
163 * Set all or part of the color table for a WinG device context.
165 * PARAMS
166 * hdc [I] WinG device context
167 * start [I] Start color
168 * num [I] Number of entries to set
169 * colors [I] Array of color data
171 * RETURNS
172 * The number of entries set.
174 UINT16 WINAPI WinGSetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
175 RGBQUAD *colors)
177 TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
178 return SetDIBColorTable16(hdc, start, num, colors);
181 /***********************************************************************
182 * WinGGetDIBColorTable (WING.1005)
184 * Get all or part of the color table for a WinG device context.
186 * PARAMS
187 * hdc [I] WinG device context
188 * start [I] Start color
189 * num [I] Number of entries to set
190 * colors [O] Destination for the array of color data
192 * RETURNS
193 * The number of entries retrieved.
195 UINT16 WINAPI WinGGetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
196 RGBQUAD *colors)
198 TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
199 return GetDIBColorTable16(hdc, start, num, colors);
202 /***********************************************************************
203 * WinGCreateHalfTonePalette (WING.1007)
205 * Create a half tone palette.
207 * PARAMS
208 * None.
210 * RETURNS
211 * Success: A handle to the created palette.
212 * Failure: A NULL handle.
214 HPALETTE16 WINAPI WinGCreateHalfTonePalette16(void)
216 HDC16 hdc = CreateCompatibleDC16(0);
217 HPALETTE16 ret = CreateHalftonePalette16(hdc);
218 TRACE("(void)\n");
219 DeleteDC16(hdc);
220 return ret;
223 /***********************************************************************
224 * WinGCreateHalfToneBrush (WING.1008)
226 * Create a half tone brush for a WinG device context.
228 * PARAMS
229 * winDC [I] WinG device context
230 * col [I] Color
231 * type [I] Desired dithering type.
233 * RETURNS
234 * Success: A handle to the created brush.
235 * Failure: A NULL handle.
237 HBRUSH16 WINAPI WinGCreateHalfToneBrush16(HDC16 winDC, COLORREF col,
238 WING_DITHER_TYPE type)
240 TRACE("(%d,%ld,%d)\n", winDC, col, type);
241 return CreateSolidBrush16(col);
244 /***********************************************************************
245 * WinGStretchBlt (WING.1009)
247 * See StretchBlt16.
249 BOOL16 WINAPI WinGStretchBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
250 INT16 widDest, INT16 heiDest,
251 HDC16 srcDC, INT16 xSrc, INT16 ySrc,
252 INT16 widSrc, INT16 heiSrc)
254 BOOL16 retval;
255 TRACE("(%d,%d,...)\n", destDC, srcDC);
256 SetStretchBltMode16 ( destDC, COLORONCOLOR );
257 retval=StretchBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
258 xSrc, ySrc, widSrc, heiSrc, SRCCOPY);
259 SetStretchBltMode16 ( destDC, BLACKONWHITE );
260 return retval;
263 /***********************************************************************
264 * WinGBitBlt (WING.1010)
266 * See BitBlt16.
268 BOOL16 WINAPI WinGBitBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
269 INT16 widDest, INT16 heiDest, HDC16 srcDC,
270 INT16 xSrc, INT16 ySrc)
272 TRACE("(%d,%d,...)\n", destDC, srcDC);
273 return BitBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
274 xSrc, ySrc, SRCCOPY);