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
26 #include "wine/wingdi16.h"
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(wing
);
31 /*************************************************************************
34 * The Windows Game dll provides a number of functions designed to allow
35 * programmers to bypass Gdi and write directly to video memory. The intention
36 * was to bolster the use of Windows as a gaming platform and remove the
37 * need for Dos based games using 32 bit Dos extenders.
39 * This initial approach could not compete with the performance of Dos games
40 * (such as Doom and Warcraft) at the time, and so this dll was eventually
41 * superseded by DirectX. It should not be used by new applications, and is
42 * provided only for compatibility with older Windows programs.
45 typedef enum WING_DITHER_TYPE
47 WING_DISPERSED_4x4
, WING_DISPERSED_8x8
, WING_CLUSTERED_4x4
51 * WinG DIB bitmaps can be selected into DC and then scribbled upon
52 * by GDI functions. They can also be changed directly. This gives us
54 * - use original WinG 16-bit DLL
55 * requires working 16-bit driver interface
56 * - implement DIB graphics driver from scratch
58 * - use shared pixmaps
59 * won't work with some videocards and/or videomodes
63 /***********************************************************************
64 * WinGCreateDC (WING.1001)
66 * Create a new WinG device context.
72 * Success: A handle to the created device context.
73 * Failure: A NULL handle.
75 HDC16 WINAPI
WinGCreateDC16(void)
78 return CreateCompatibleDC16(0);
81 /***********************************************************************
82 * WinGRecommendDIBFormat (WING.1002)
84 * Get the recommended format of bitmaps for the current display.
87 * bmpi [O] Destination for format information
90 * Success: TRUE. bmpi is filled with the best (fastest) bitmap format
91 * Failure: FALSE, if bmpi is NULL.
93 BOOL16 WINAPI
WinGRecommendDIBFormat16(BITMAPINFO
*bmpi
)
95 static const WCHAR szDisplayW
[] = { 'D','I','S','P','L','A','Y','\0' };
97 TRACE("(%p)\n", bmpi
);
101 hdc
= CreateDCW( szDisplayW
, 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;
117 /***********************************************************************
118 * WinGCreateBitmap (WING.1003)
120 * Create a new WinG bitmap.
123 * hdc [I] WinG device context
124 * bmpi [I] Information about the bitmap
125 * bits [I] Location of the bitmap image data
128 * Success: A handle to the created bitmap.
129 * Failure: A NULL handle.
131 HBITMAP16 WINAPI
WinGCreateBitmap16(HDC16 hdc
, BITMAPINFO
*bmpi
,
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
),
149 TRACE("(%d,%p)\n", hWinGBitmap
, bmpi
);
152 if (bmpi
) FIXME(": Todo - implement setting BITMAPINFO\n");
154 res
= bmp
->segptr_bits
;
155 GDI_ReleaseObj( HBITMAP_32(hWinGBitmap
) );
159 /***********************************************************************
160 * WinGSetDIBColorTable (WING.1006)
162 * Set all or part of the color table for a WinG device context.
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
171 * The number of entries set.
173 UINT16 WINAPI
WinGSetDIBColorTable16(HDC16 hdc
, UINT16 start
, UINT16 num
,
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.
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
192 * The number of entries retrieved.
194 UINT16 WINAPI
WinGGetDIBColorTable16(HDC16 hdc
, UINT16 start
, UINT16 num
,
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.
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
);
222 /***********************************************************************
223 * WinGCreateHalfToneBrush (WING.1008)
225 * Create a half tone brush for a WinG device context.
228 * winDC [I] WinG device context
230 * type [I] Desired dithering type.
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)
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
)
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
);
262 /***********************************************************************
263 * WinGBitBlt (WING.1010)
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
);