Merged wing.dll into gdi32.dll.
[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 "ldt.h"
17 #include "monitor.h"
18 #include "palette.h"
19 #include "windef.h"
20
21 DEFAULT_DEBUG_CHANNEL(wing)
22
23
24 typedef enum WING_DITHER_TYPE
25 {
26   WING_DISPERSED_4x4, WING_DISPERSED_8x8, WING_CLUSTERED_4x4
27 } WING_DITHER_TYPE;
28
29 /* 
30  * WinG DIB bitmaps can be selected into DC and then scribbled upon
31  * by GDI functions. They can also be changed directly. This gives us 
32  * three choices 
33  *      - use original WinG 16-bit DLL
34  *              requires working 16-bit driver interface
35  *      - implement DIB graphics driver from scratch
36  *              see wing.zip size
37  *      - use shared pixmaps
38  *              won't work with some videocards and/or videomodes
39  * 961208 - AK
40  */
41
42 /***********************************************************************
43  *          WinGCreateDC16      (WING.1001)
44  */
45 HDC16 WINAPI WinGCreateDC16(void)
46 {
47     TRACE("(void)\n");
48         return CreateCompatibleDC16(0);
49 }
50
51 /***********************************************************************
52  *  WinGRecommendDIBFormat16    (WING.1002)
53  */
54 BOOL16 WINAPI WinGRecommendDIBFormat16(BITMAPINFO *bmpi)
55 {
56     TRACE("(%p)\n", bmpi);
57     if (!bmpi)
58         return FALSE;
59
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 = MONITOR_GetDepth(&MONITOR_PrimaryMonitor);
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
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
94     TRACE("(%d,%p)\n", hWinGBitmap, bmpi);
95     if (!bmp) return (SEGPTR)NULL;
96
97     if (bmpi)
98         FIXME(": Todo - implement setting BITMAPINFO\n");
99
100 #ifndef X_DISPLAY_MISSING
101     return PTR_SEG_OFF_TO_SEGPTR(((X11DRV_DIBSECTION *) bmp->dib)->selector, 0);
102 #else /* !defined(X_DISPLAY_MISSING) */
103     return NULL;
104 #endif /* !defined(X_DISPLAY_MISSING) */
105 }
106
107 /***********************************************************************
108  *  WinGSetDIBColorTable   (WING.1004)
109  */
110 UINT16 WINAPI WinGSetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
111                                      RGBQUAD *colors)
112 {
113     TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
114     return SetDIBColorTable16(hdc, start, num, colors);
115 }
116
117 /***********************************************************************
118  *  WinGGetDIBColorTable16   (WING.1005)
119  */
120 UINT16 WINAPI WinGGetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
121                                      RGBQUAD *colors)
122 {
123     TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
124     return GetDIBColorTable16(hdc, start, num, colors);
125 }
126
127 /***********************************************************************
128  *  WinGCreateHalfTonePalette16   (WING.1007)
129  */
130 HPALETTE16 WINAPI WinGCreateHalfTonePalette16(void)
131 {
132     TRACE("(void)\n");
133     return CreateHalftonePalette16(GetDC16(0));
134 }
135
136 /***********************************************************************
137  *  WinGCreateHalfToneBrush16   (WING.1008)
138  */
139 HBRUSH16 WINAPI WinGCreateHalfToneBrush16(HDC16 winDC, COLORREF col,
140                                             WING_DITHER_TYPE type)
141 {
142     TRACE("(%d,%ld,%d)\n", winDC, col, type);
143     return CreateSolidBrush16(col);
144 }
145
146 /***********************************************************************
147  *  WinGStretchBlt16   (WING.1009)
148  */
149 BOOL16 WINAPI WinGStretchBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
150                                INT16 widDest, INT16 heiDest,
151                                HDC16 srcDC, INT16 xSrc, INT16 ySrc,
152                                INT16 widSrc, INT16 heiSrc)
153 {
154     BOOL16 retval;
155     TRACE("(%d,%d,...)\n", destDC, srcDC);
156     SetStretchBltMode16 ( destDC, COLORONCOLOR );
157     retval=StretchBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
158                         xSrc, ySrc, widSrc, heiSrc, SRCCOPY);
159     SetStretchBltMode16 ( destDC, BLACKONWHITE );
160     return retval;
161 }
162
163 /***********************************************************************
164  *  WinGBitBlt16   (WING.1010)
165  */
166 BOOL16 WINAPI WinGBitBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
167                            INT16 widDest, INT16 heiDest, HDC16 srcDC,
168                            INT16 xSrc, INT16 ySrc)
169 {
170     TRACE("(%d,%d,...)\n", destDC, srcDC);
171     return BitBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
172                     xSrc, ySrc, SRCCOPY);
173 }