Documentation updates.
[wine/hacks.git] / dlls / gdi / wing.c
blob1026d7ca4b62a1cf761d3523a4e94cdda0eeed42
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
23 #include "wine/winuser16.h"
24 #include "bitmap.h"
25 #include "wine/debug.h"
26 #include "palette.h"
27 #include "windef.h"
28 #include "wownt32.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 * superceeded by DirectX. It should not be used by new applications, and is
43 * provided only for compatability 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 HDC hdc;
97 TRACE("(%p)\n", bmpi);
98 if (!bmpi)
99 return FALSE;
101 hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL );
102 bmpi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
103 bmpi->bmiHeader.biWidth = 320;
104 bmpi->bmiHeader.biHeight = -1;
105 bmpi->bmiHeader.biPlanes = 1;
106 bmpi->bmiHeader.biBitCount = 8;
107 bmpi->bmiHeader.biCompression = BI_RGB;
108 bmpi->bmiHeader.biSizeImage = 0;
109 bmpi->bmiHeader.biXPelsPerMeter = 0;
110 bmpi->bmiHeader.biYPelsPerMeter = 0;
111 bmpi->bmiHeader.biClrUsed = 0;
112 bmpi->bmiHeader.biClrImportant = 0;
113 DeleteDC(hdc);
114 return TRUE;
117 /***********************************************************************
118 * WinGCreateBitmap (WING.1003)
120 * Create a new WinG bitmap.
122 * PARAMS
123 * hdc [I] WinG device context
124 * bmpi [I] Information about the bitmap
125 * bits [I] Location of the bitmap image data
127 * RETURNS
128 * Success: A handle to the created bitmap.
129 * Failure: A NULL handle.
131 HBITMAP16 WINAPI WinGCreateBitmap16(HDC16 hdc, BITMAPINFO *bmpi,
132 SEGPTR *bits)
134 TRACE("(%d,%p,%p)\n", hdc, bmpi, bits);
135 TRACE(": create %ldx%ldx%d bitmap\n", bmpi->bmiHeader.biWidth,
136 bmpi->bmiHeader.biHeight, bmpi->bmiHeader.biPlanes);
137 return CreateDIBSection16(hdc, bmpi, 0, bits, 0, 0);
140 /***********************************************************************
141 * WinGGetDIBPointer (WING.1004)
143 SEGPTR WINAPI WinGGetDIBPointer16(HBITMAP16 hWinGBitmap, BITMAPINFO* bmpi)
145 BITMAPOBJ* bmp = (BITMAPOBJ *) GDI_GetObjPtr( HBITMAP_32(hWinGBitmap),
146 BITMAP_MAGIC );
147 SEGPTR res = 0;
149 TRACE("(%d,%p)\n", hWinGBitmap, bmpi);
150 if (!bmp) return 0;
152 if (bmpi) FIXME(": Todo - implement setting BITMAPINFO\n");
154 res = bmp->segptr_bits;
155 GDI_ReleaseObj( HBITMAP_32(hWinGBitmap) );
156 return res;
159 /***********************************************************************
160 * WinGSetDIBColorTable (WING.1006)
162 * Set all or part of the color table for a WinG device context.
164 * PARAMS
165 * hdc [I] WinG device context
166 * start [I] Start color
167 * num [I] Number of entries to set
168 * colors [I] Array of color data
170 * RETURNS
171 * The number of entries set.
173 UINT16 WINAPI WinGSetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
174 RGBQUAD *colors)
176 TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
177 return SetDIBColorTable16(hdc, start, num, colors);
180 /***********************************************************************
181 * WinGGetDIBColorTable (WING.1005)
183 * Get all or part of the color table for a WinG device context.
185 * PARAMS
186 * hdc [I] WinG device context
187 * start [I] Start color
188 * num [I] Number of entries to set
189 * colors [O] Destination for the array of color data
191 * RETURNS
192 * The number of entries retrieved.
194 UINT16 WINAPI WinGGetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
195 RGBQUAD *colors)
197 TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
198 return GetDIBColorTable16(hdc, start, num, colors);
201 /***********************************************************************
202 * WinGCreateHalfTonePalette (WING.1007)
204 * Create a half tone palette.
206 * PARAMS
207 * None.
209 * RETURNS
210 * Success: A handle to the created palette.
211 * Failure: A NULL handle.
213 HPALETTE16 WINAPI WinGCreateHalfTonePalette16(void)
215 HDC16 hdc = CreateCompatibleDC16(0);
216 HPALETTE16 ret = CreateHalftonePalette16(hdc);
217 TRACE("(void)\n");
218 DeleteDC16(hdc);
219 return ret;
222 /***********************************************************************
223 * WinGCreateHalfToneBrush (WING.1008)
225 * Create a half tone brush for a WinG device context.
227 * PARAMS
228 * winDC [I] WinG device context
229 * col [I] Color
230 * type [I] Desired dithering type.
232 * RETURNS
233 * Success: A handle to the created brush.
234 * Failure: A NULL handle.
236 HBRUSH16 WINAPI WinGCreateHalfToneBrush16(HDC16 winDC, COLORREF col,
237 WING_DITHER_TYPE type)
239 TRACE("(%d,%ld,%d)\n", winDC, col, type);
240 return CreateSolidBrush16(col);
243 /***********************************************************************
244 * WinGStretchBlt (WING.1009)
246 * See StretchBlt16.
248 BOOL16 WINAPI WinGStretchBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
249 INT16 widDest, INT16 heiDest,
250 HDC16 srcDC, INT16 xSrc, INT16 ySrc,
251 INT16 widSrc, INT16 heiSrc)
253 BOOL16 retval;
254 TRACE("(%d,%d,...)\n", destDC, srcDC);
255 SetStretchBltMode16 ( destDC, COLORONCOLOR );
256 retval=StretchBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
257 xSrc, ySrc, widSrc, heiSrc, SRCCOPY);
258 SetStretchBltMode16 ( destDC, BLACKONWHITE );
259 return retval;
262 /***********************************************************************
263 * WinGBitBlt (WING.1010)
265 * See BitBlt16.
267 BOOL16 WINAPI WinGBitBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
268 INT16 widDest, INT16 heiDest, HDC16 srcDC,
269 INT16 xSrc, INT16 ySrc)
271 TRACE("(%d,%d,...)\n", destDC, srcDC);
272 return BitBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
273 xSrc, ySrc, SRCCOPY);