Fixed some issues found by winapi_check.
[wine] / dlls / gdi / wing.c
1 /*
2  * WinG support
3  *
4  * Copyright (C) Robert Pouliot <krynos@clic.net>
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include "config.h"
22
23 #include "wine/winuser16.h"
24 #include "bitmap.h"
25 #include "wine/debug.h"
26 #include "palette.h"
27 #include "windef.h"
28
29 WINE_DEFAULT_DEBUG_CHANNEL(wing);
30
31
32 typedef enum WING_DITHER_TYPE
33 {
34   WING_DISPERSED_4x4, WING_DISPERSED_8x8, WING_CLUSTERED_4x4
35 } WING_DITHER_TYPE;
36
37 /*
38  * WinG DIB bitmaps can be selected into DC and then scribbled upon
39  * by GDI functions. They can also be changed directly. This gives us
40  * three choices
41  *      - use original WinG 16-bit DLL
42  *              requires working 16-bit driver interface
43  *      - implement DIB graphics driver from scratch
44  *              see wing.zip size
45  *      - use shared pixmaps
46  *              won't work with some videocards and/or videomodes
47  * 961208 - AK
48  */
49
50 /***********************************************************************
51  *          WinGCreateDC        (WING.1001)
52  */
53 HDC16 WINAPI WinGCreateDC16(void)
54 {
55     TRACE("(void)\n");
56         return CreateCompatibleDC16(0);
57 }
58
59 /***********************************************************************
60  *  WinGRecommendDIBFormat    (WING.1002)
61  */
62 BOOL16 WINAPI WinGRecommendDIBFormat16(BITMAPINFO *bmpi)
63 {
64     HDC hdc;
65     TRACE("(%p)\n", bmpi);
66     if (!bmpi)
67         return FALSE;
68
69     hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL );
70     bmpi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
71     bmpi->bmiHeader.biWidth = 320;
72     bmpi->bmiHeader.biHeight = -1;
73     bmpi->bmiHeader.biPlanes = 1;
74     bmpi->bmiHeader.biBitCount = 8;
75     bmpi->bmiHeader.biCompression = BI_RGB;
76     bmpi->bmiHeader.biSizeImage = 0;
77     bmpi->bmiHeader.biXPelsPerMeter = 0;
78     bmpi->bmiHeader.biYPelsPerMeter = 0;
79     bmpi->bmiHeader.biClrUsed = 0;
80     bmpi->bmiHeader.biClrImportant = 0;
81     DeleteDC(hdc);
82     return TRUE;
83 }
84
85 /***********************************************************************
86  *        WinGCreateBitmap    (WING.1003)
87  */
88 HBITMAP16 WINAPI WinGCreateBitmap16(HDC16 hdc, BITMAPINFO *bmpi,
89                                     SEGPTR *bits)
90 {
91     TRACE("(%d,%p,%p)\n", hdc, bmpi, bits);
92     TRACE(": create %ldx%ldx%d bitmap\n", bmpi->bmiHeader.biWidth,
93           bmpi->bmiHeader.biHeight, bmpi->bmiHeader.biPlanes);
94     return CreateDIBSection16(hdc, bmpi, 0, bits, 0, 0);
95 }
96
97 /***********************************************************************
98  *  WinGGetDIBPointer   (WING.1004)
99  */
100 SEGPTR WINAPI WinGGetDIBPointer16(HBITMAP16 hWinGBitmap, BITMAPINFO* bmpi)
101 {
102     BITMAPOBJ* bmp = (BITMAPOBJ *) GDI_GetObjPtr( hWinGBitmap, BITMAP_MAGIC );
103     SEGPTR res = 0;
104
105     TRACE("(%d,%p)\n", hWinGBitmap, bmpi);
106     if (!bmp) return 0;
107
108     if (bmpi) FIXME(": Todo - implement setting BITMAPINFO\n");
109
110     res = bmp->segptr_bits;
111     GDI_ReleaseObj( hWinGBitmap );
112     return res;
113 }
114
115 /***********************************************************************
116  *  WinGSetDIBColorTable   (WING.1006)
117  */
118 UINT16 WINAPI WinGSetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
119                                      RGBQUAD *colors)
120 {
121     TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
122     return SetDIBColorTable16(hdc, start, num, colors);
123 }
124
125 /***********************************************************************
126  *  WinGGetDIBColorTable   (WING.1005)
127  */
128 UINT16 WINAPI WinGGetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
129                                      RGBQUAD *colors)
130 {
131     TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
132     return GetDIBColorTable16(hdc, start, num, colors);
133 }
134
135 /***********************************************************************
136  *  WinGCreateHalfTonePalette   (WING.1007)
137  */
138 HPALETTE16 WINAPI WinGCreateHalfTonePalette16(void)
139 {
140     HDC hdc = CreateCompatibleDC(0);
141     HPALETTE16 ret = CreateHalftonePalette16(hdc);
142     TRACE("(void)\n");
143     DeleteDC(hdc);
144     return ret;
145 }
146
147 /***********************************************************************
148  *  WinGCreateHalfToneBrush   (WING.1008)
149  */
150 HBRUSH16 WINAPI WinGCreateHalfToneBrush16(HDC16 winDC, COLORREF col,
151                                             WING_DITHER_TYPE type)
152 {
153     TRACE("(%d,%ld,%d)\n", winDC, col, type);
154     return CreateSolidBrush16(col);
155 }
156
157 /***********************************************************************
158  *  WinGStretchBlt   (WING.1009)
159  */
160 BOOL16 WINAPI WinGStretchBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
161                                INT16 widDest, INT16 heiDest,
162                                HDC16 srcDC, INT16 xSrc, INT16 ySrc,
163                                INT16 widSrc, INT16 heiSrc)
164 {
165     BOOL16 retval;
166     TRACE("(%d,%d,...)\n", destDC, srcDC);
167     SetStretchBltMode16 ( destDC, COLORONCOLOR );
168     retval=StretchBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
169                         xSrc, ySrc, widSrc, heiSrc, SRCCOPY);
170     SetStretchBltMode16 ( destDC, BLACKONWHITE );
171     return retval;
172 }
173
174 /***********************************************************************
175  *  WinGBitBlt   (WING.1010)
176  */
177 BOOL16 WINAPI WinGBitBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
178                            INT16 widDest, INT16 heiDest, HDC16 srcDC,
179                            INT16 xSrc, INT16 ySrc)
180 {
181     TRACE("(%d,%d,...)\n", destDC, srcDC);
182     return BitBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
183                     xSrc, ySrc, SRCCOPY);
184 }