wing.c 5.05 KB
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
1
/*
Alexandre Julliard's avatar
Alexandre Julliard committed
2
 * WinG support
Alexandre Julliard's avatar
Alexandre Julliard committed
3 4 5 6
 *
 * Started by Robert Pouliot <krynos@clic.net>
 */

7 8
#include "config.h"

9
#include "wine/winuser16.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
10
#include "bitmap.h"
11
#include "debugtools.h"
12
#include "palette.h"
13
#include "windef.h"
14

15
DEFAULT_DEBUG_CHANNEL(wing);
16

Alexandre Julliard's avatar
Alexandre Julliard committed
17

Alexandre Julliard's avatar
Alexandre Julliard committed
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
typedef enum WING_DITHER_TYPE
{
  WING_DISPERSED_4x4, WING_DISPERSED_8x8, WING_CLUSTERED_4x4
} WING_DITHER_TYPE;

/* 
 * WinG DIB bitmaps can be selected into DC and then scribbled upon
 * by GDI functions. They can also be changed directly. This gives us 
 * three choices 
 *	- use original WinG 16-bit DLL
 *		requires working 16-bit driver interface
 * 	- implement DIB graphics driver from scratch
 *		see wing.zip size
 *	- use shared pixmaps
 *		won't work with some videocards and/or videomodes
 * 961208 - AK
 */

Alexandre Julliard's avatar
Alexandre Julliard committed
36
/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
37
 *          WinGCreateDC	(WING.1001)
Alexandre Julliard's avatar
Alexandre Julliard committed
38
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
39
HDC16 WINAPI WinGCreateDC16(void)
Alexandre Julliard's avatar
Alexandre Julliard committed
40
{
41
    TRACE("(void)\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
42
	return CreateCompatibleDC16(0);
Alexandre Julliard's avatar
Alexandre Julliard committed
43
}
Alexandre Julliard's avatar
Alexandre Julliard committed
44 45

/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
46
 *  WinGRecommendDIBFormat    (WING.1002)
Alexandre Julliard's avatar
Alexandre Julliard committed
47
 */
Brad Pepers's avatar
Brad Pepers committed
48
BOOL16 WINAPI WinGRecommendDIBFormat16(BITMAPINFO *bmpi)
Alexandre Julliard's avatar
Alexandre Julliard committed
49
{
50
    HDC hdc;
51
    TRACE("(%p)\n", bmpi);
Brad Pepers's avatar
Brad Pepers committed
52 53 54
    if (!bmpi)
	return FALSE;

55
    hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL );
Brad Pepers's avatar
Brad Pepers committed
56 57 58
    bmpi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    bmpi->bmiHeader.biWidth = 320;
    bmpi->bmiHeader.biHeight = -1;
59 60
    bmpi->bmiHeader.biPlanes = 1;
    bmpi->bmiHeader.biBitCount = 8;
Brad Pepers's avatar
Brad Pepers committed
61 62 63 64 65 66
    bmpi->bmiHeader.biCompression = BI_RGB;
    bmpi->bmiHeader.biSizeImage = 0;
    bmpi->bmiHeader.biXPelsPerMeter = 0;
    bmpi->bmiHeader.biYPelsPerMeter = 0;
    bmpi->bmiHeader.biClrUsed = 0;
    bmpi->bmiHeader.biClrImportant = 0;
67
    DeleteDC(hdc);
Alexandre Julliard's avatar
Alexandre Julliard committed
68
    return TRUE;
69
}
Alexandre Julliard's avatar
Alexandre Julliard committed
70 71

/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
72
 *        WinGCreateBitmap    (WING.1003)
Alexandre Julliard's avatar
Alexandre Julliard committed
73
 */
Brad Pepers's avatar
Brad Pepers committed
74 75
HBITMAP16 WINAPI WinGCreateBitmap16(HDC16 hdc, BITMAPINFO *bmpi,
                                    SEGPTR *bits)
Alexandre Julliard's avatar
Alexandre Julliard committed
76
{
77 78
    TRACE("(%d,%p,%p)\n", hdc, bmpi, bits);
    TRACE(": create %ldx%ldx%d bitmap\n", bmpi->bmiHeader.biWidth,
Brad Pepers's avatar
Brad Pepers committed
79 80
	  bmpi->bmiHeader.biHeight, bmpi->bmiHeader.biPlanes);
    return CreateDIBSection16(hdc, bmpi, 0, bits, 0, 0);
81
}
Alexandre Julliard's avatar
Alexandre Julliard committed
82

Alexandre Julliard's avatar
Alexandre Julliard committed
83
/***********************************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
84
 *  WinGGetDIBPointer   (WING.1004)
Alexandre Julliard's avatar
Alexandre Julliard committed
85
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
86
SEGPTR WINAPI WinGGetDIBPointer16(HBITMAP16 hWinGBitmap, BITMAPINFO* bmpi)
Alexandre Julliard's avatar
Alexandre Julliard committed
87
{
88
    BITMAPOBJ* bmp = (BITMAPOBJ *) GDI_GetObjPtr( hWinGBitmap, BITMAP_MAGIC );
89
    SEGPTR res = 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
90

91
    TRACE("(%d,%p)\n", hWinGBitmap, bmpi);
92
    if (!bmp) return 0;
Brad Pepers's avatar
Brad Pepers committed
93

94
    if (bmpi) FIXME(": Todo - implement setting BITMAPINFO\n");
Brad Pepers's avatar
Brad Pepers committed
95

96
    res = bmp->segptr_bits;
97 98
    GDI_ReleaseObj( hWinGBitmap );
    return res;
Alexandre Julliard's avatar
Alexandre Julliard committed
99 100 101
}

/***********************************************************************
102
 *  WinGSetDIBColorTable   (WING.1006)
Alexandre Julliard's avatar
Alexandre Julliard committed
103
 */
Brad Pepers's avatar
Brad Pepers committed
104 105
UINT16 WINAPI WinGSetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
                                     RGBQUAD *colors)
Alexandre Julliard's avatar
Alexandre Julliard committed
106
{
107
    TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
Brad Pepers's avatar
Brad Pepers committed
108
    return SetDIBColorTable16(hdc, start, num, colors);
Alexandre Julliard's avatar
Alexandre Julliard committed
109 110 111
}

/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
112
 *  WinGGetDIBColorTable   (WING.1005)
Alexandre Julliard's avatar
Alexandre Julliard committed
113
 */
Brad Pepers's avatar
Brad Pepers committed
114 115
UINT16 WINAPI WinGGetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
				     RGBQUAD *colors)
Alexandre Julliard's avatar
Alexandre Julliard committed
116
{
117
    TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
Brad Pepers's avatar
Brad Pepers committed
118
    return GetDIBColorTable16(hdc, start, num, colors);
Alexandre Julliard's avatar
Alexandre Julliard committed
119 120
}

Alexandre Julliard's avatar
Alexandre Julliard committed
121
/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
122
 *  WinGCreateHalfTonePalette   (WING.1007)
Alexandre Julliard's avatar
Alexandre Julliard committed
123
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
124
HPALETTE16 WINAPI WinGCreateHalfTonePalette16(void)
Alexandre Julliard's avatar
Alexandre Julliard committed
125
{
126 127
    HDC hdc = CreateCompatibleDC(0);
    HPALETTE16 ret = CreateHalftonePalette16(hdc);
128
    TRACE("(void)\n");
129 130
    DeleteDC(hdc);
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
131 132 133
}

/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
134
 *  WinGCreateHalfToneBrush   (WING.1008)
Alexandre Julliard's avatar
Alexandre Julliard committed
135
 */
Brad Pepers's avatar
Brad Pepers committed
136
HBRUSH16 WINAPI WinGCreateHalfToneBrush16(HDC16 winDC, COLORREF col,
Alexandre Julliard's avatar
Alexandre Julliard committed
137
                                            WING_DITHER_TYPE type)
Alexandre Julliard's avatar
Alexandre Julliard committed
138
{
139
    TRACE("(%d,%ld,%d)\n", winDC, col, type);
Brad Pepers's avatar
Brad Pepers committed
140
    return CreateSolidBrush16(col);
Alexandre Julliard's avatar
Alexandre Julliard committed
141 142
}

Alexandre Julliard's avatar
Alexandre Julliard committed
143
/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
144
 *  WinGStretchBlt   (WING.1009)
Alexandre Julliard's avatar
Alexandre Julliard committed
145
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
146 147 148 149
BOOL16 WINAPI WinGStretchBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
                               INT16 widDest, INT16 heiDest,
                               HDC16 srcDC, INT16 xSrc, INT16 ySrc,
                               INT16 widSrc, INT16 heiSrc)
Alexandre Julliard's avatar
Alexandre Julliard committed
150
{
Peter Ganten's avatar
Peter Ganten committed
151
    BOOL16 retval;
152
    TRACE("(%d,%d,...)\n", destDC, srcDC);
Peter Ganten's avatar
Peter Ganten committed
153 154
    SetStretchBltMode16 ( destDC, COLORONCOLOR );
    retval=StretchBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
Brad Pepers's avatar
Brad Pepers committed
155
			xSrc, ySrc, widSrc, heiSrc, SRCCOPY);
Peter Ganten's avatar
Peter Ganten committed
156 157
    SetStretchBltMode16 ( destDC, BLACKONWHITE );
    return retval;
Alexandre Julliard's avatar
Alexandre Julliard committed
158 159 160
}

/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
161
 *  WinGBitBlt   (WING.1010)
Alexandre Julliard's avatar
Alexandre Julliard committed
162
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
163 164 165
BOOL16 WINAPI WinGBitBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
                           INT16 widDest, INT16 heiDest, HDC16 srcDC,
                           INT16 xSrc, INT16 ySrc)
Alexandre Julliard's avatar
Alexandre Julliard committed
166
{
167
    TRACE("(%d,%d,...)\n", destDC, srcDC);
Brad Pepers's avatar
Brad Pepers committed
168 169
    return BitBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
		    xSrc, ySrc, SRCCOPY);
Alexandre Julliard's avatar
Alexandre Julliard committed
170
}