Added missing string.h include.
[wine.git] / graphics / wing.c
blobf044cd998886b17883cee88b4350fd4ca50c47a7
1 /*
2 * WinG support
4 * Started by Robert Pouliot <krynos@clic.net>
5 */
7 #include "config.h"
9 #include "ts_xlib.h"
10 #ifdef HAVE_LIBXXSHM
11 #include <sys/types.h>
12 #include <sys/ipc.h>
13 #ifndef __EMX__
14 #include <sys/shm.h>
15 #endif /* !defined(__EMX__) */
16 #include "ts_xshm.h"
17 #endif /* defined(HAVE_LIBXXSHM) */
18 #include "x11drv.h"
20 #include "bitmap.h"
21 #include "palette.h"
22 #include "dc.h"
23 #include "debug.h"
24 #include "gdi.h"
25 #include "heap.h"
26 #include "selectors.h"
27 #include "monitor.h"
28 #include "wintypes.h"
29 #include "xmalloc.h"
31 typedef enum WING_DITHER_TYPE
33 WING_DISPERSED_4x4, WING_DISPERSED_8x8, WING_CLUSTERED_4x4
34 } WING_DITHER_TYPE;
36 /*
37 * WinG DIB bitmaps can be selected into DC and then scribbled upon
38 * by GDI functions. They can also be changed directly. This gives us
39 * three choices
40 * - use original WinG 16-bit DLL
41 * requires working 16-bit driver interface
42 * - implement DIB graphics driver from scratch
43 * see wing.zip size
44 * - use shared pixmaps
45 * won't work with some videocards and/or videomodes
46 * 961208 - AK
49 /***********************************************************************
50 * WinGCreateDC16 (WING.1001)
52 HDC16 WINAPI WinGCreateDC16(void)
54 TRACE(wing, "(void)\n");
55 return CreateCompatibleDC16(0);
58 /***********************************************************************
59 * WinGRecommendDIBFormat16 (WING.1002)
61 BOOL16 WINAPI WinGRecommendDIBFormat16(BITMAPINFO *bmpi)
63 TRACE(wing, "(%p)\n", bmpi);
64 if (!bmpi)
65 return FALSE;
67 bmpi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
68 bmpi->bmiHeader.biWidth = 320;
69 bmpi->bmiHeader.biHeight = -1;
70 bmpi->bmiHeader.biPlanes = 1;
71 bmpi->bmiHeader.biBitCount = MONITOR_GetDepth(&MONITOR_PrimaryMonitor);
72 bmpi->bmiHeader.biCompression = BI_RGB;
73 bmpi->bmiHeader.biSizeImage = 0;
74 bmpi->bmiHeader.biXPelsPerMeter = 0;
75 bmpi->bmiHeader.biYPelsPerMeter = 0;
76 bmpi->bmiHeader.biClrUsed = 0;
77 bmpi->bmiHeader.biClrImportant = 0;
79 return TRUE;
82 /***********************************************************************
83 * WinGCreateBitmap16 (WING.1003)
85 HBITMAP16 WINAPI WinGCreateBitmap16(HDC16 hdc, BITMAPINFO *bmpi,
86 SEGPTR *bits)
88 TRACE(wing, "(%d,%p,%p)\n", hdc, bmpi, bits);
89 TRACE(wing, ": create %ldx%ldx%d bitmap\n", bmpi->bmiHeader.biWidth,
90 bmpi->bmiHeader.biHeight, bmpi->bmiHeader.biPlanes);
91 return CreateDIBSection16(hdc, bmpi, 0, bits, 0, 0);
94 /***********************************************************************
95 * WinGGetDIBPointer (WING.1004)
97 SEGPTR WINAPI WinGGetDIBPointer16(HBITMAP16 hWinGBitmap, BITMAPINFO* bmpi)
99 BITMAPOBJ* bmp = (BITMAPOBJ *) GDI_GetObjPtr( hWinGBitmap, BITMAP_MAGIC );
101 TRACE(wing, "(%d,%p)\n", hWinGBitmap, bmpi);
102 if (!bmp) return (SEGPTR)NULL;
104 if (bmpi)
105 FIXME(wing, ": Todo - implement setting BITMAPINFO\n");
107 return PTR_SEG_OFF_TO_SEGPTR(bmp->dib->selector, 0);
110 /***********************************************************************
111 * WinGSetDIBColorTable (WING.1004)
113 UINT16 WINAPI WinGSetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
114 RGBQUAD *colors)
116 TRACE(wing, "(%d,%d,%d,%p)\n", hdc, start, num, colors);
117 return SetDIBColorTable16(hdc, start, num, colors);
120 /***********************************************************************
121 * WinGGetDIBColorTable16 (WING.1005)
123 UINT16 WINAPI WinGGetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
124 RGBQUAD *colors)
126 TRACE(wing, "(%d,%d,%d,%p)\n", hdc, start, num, colors);
127 return GetDIBColorTable16(hdc, start, num, colors);
130 /***********************************************************************
131 * WinGCreateHalfTonePalette16 (WING.1007)
133 HPALETTE16 WINAPI WinGCreateHalfTonePalette16(void)
135 TRACE(wing, "(void)\n");
136 return CreateHalftonePalette16(GetDC16(0));
139 /***********************************************************************
140 * WinGCreateHalfToneBrush16 (WING.1008)
142 HBRUSH16 WINAPI WinGCreateHalfToneBrush16(HDC16 winDC, COLORREF col,
143 WING_DITHER_TYPE type)
145 TRACE(wing, "(%d,%ld,%d)\n", winDC, col, type);
146 return CreateSolidBrush16(col);
149 /***********************************************************************
150 * WinGStretchBlt16 (WING.1009)
152 BOOL16 WINAPI WinGStretchBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
153 INT16 widDest, INT16 heiDest,
154 HDC16 srcDC, INT16 xSrc, INT16 ySrc,
155 INT16 widSrc, INT16 heiSrc)
157 TRACE(wing, "(%d,%d,...)\n", destDC, srcDC);
158 return StretchBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
159 xSrc, ySrc, widSrc, heiSrc, SRCCOPY);
162 /***********************************************************************
163 * WinGBitBlt16 (WING.1010)
165 BOOL16 WINAPI WinGBitBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
166 INT16 widDest, INT16 heiDest, HDC16 srcDC,
167 INT16 xSrc, INT16 ySrc)
169 TRACE(wing, "(%d,%d,...)\n", destDC, srcDC);
170 return BitBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
171 xSrc, ySrc, SRCCOPY);