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