1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.ximtec.igesture.io.win32;
16
17 import java.awt.Rectangle;
18
19 import com.sun.jna.Pointer;
20 import com.sun.jna.Structure;
21 import com.sun.jna.ptr.PointerByReference;
22
23
24
25 public interface GDI32 extends W32API {
26
27 public static class RECT extends Structure {
28
29 public int left, top, right, bottom;
30
31
32 public Rectangle toRectangle() {
33 return new Rectangle(left, top, right - left, bottom - top);
34 }
35
36
37 public String toString() {
38 return "[(" + left + "," + top + ")(" + right + "," + bottom + ")]";
39 }
40 }
41
42 int RDH_RECTANGLES = 1;
43
44 public static class RGNDATAHEADER extends Structure {
45 public int dwSize = size();
46 public int iType = RDH_RECTANGLES;
47 public int nCount;
48 public int nRgnSize;
49 public RECT rcBound;
50 }
51
52 public static class RGNDATA extends Structure {
53
54 public RGNDATAHEADER rdh;
55 public byte[] Buffer;
56
57
58 public RGNDATA(int bufferSize) {
59 Buffer = new byte[bufferSize];
60 allocateMemory();
61 }
62 }
63
64
65 public HRGN ExtCreateRegion(Pointer lpXform, int nCount, RGNDATA lpRgnData);
66
67 int RGN_AND = 1;
68 int RGN_OR = 2;
69 int RGN_XOR = 3;
70 int RGN_DIFF = 4;
71 int RGN_COPY = 5;
72
73 int ERROR = 0;
74 int NULLREGION = 1;
75 int SIMPLEREGION = 2;
76 int COMPLEXREGION = 3;
77
78
79 int CombineRgn(HRGN hrgnDest, HRGN hrgnSrc1, HRGN hrgnSrc2, int fnCombineMode);
80
81
82 HRGN CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect,
83 int nBottomRect);
84
85
86 HRGN CreateRoundRectRgn(int nLeftRect, int nTopRect, int nRightRect,
87 int nBottomRect, int nWidthEllipse, int nHeightEllipse);
88
89
90 boolean SetRectRgn(HRGN hrgn, int nLeftRect, int nTopRect, int nRightRect,
91 int nBottomRect);
92
93
94 int SetPixel(HDC hDC, int x, int y, int crColor);
95
96
97 HDC CreateCompatibleDC(HDC hDC);
98
99
100 boolean DeleteDC(HDC hDC);
101
102 int BI_RGB = 0;
103 int BI_RLE8 = 1;
104 int BI_RLE4 = 2;
105 int BI_BITFIELDS = 3;
106 int BI_JPEG = 4;
107 int BI_PNG = 5;
108
109 public static class BITMAPINFOHEADER extends Structure {
110
111 public int biSize = size();
112 public int biWidth;
113 public int biHeight;
114 public short biPlanes;
115 public short biBitCount;
116 public int biCompression;
117 public int biSizeImage;
118 public int biXPelsPerMeter;
119 public int biYPelsPerMeter;
120 public int biClrUsed;
121 public int biClrImportant;
122 }
123
124 public static class RGBQUAD extends Structure {
125
126 public byte rgbBlue;
127 public byte rgbGreen;
128 public byte rgbRed;
129 public byte rgbReserved = 0;
130 }
131
132 public static class BITMAPINFO extends Structure {
133
134 public BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER();
135
136
137
138
139
140 int[] bmiColors = new int[1];
141
142
143 public BITMAPINFO() {
144 this(1);
145 }
146
147
148 public BITMAPINFO(int size) {
149 bmiColors = new int[size];
150 allocateMemory();
151 }
152 }
153 int DIB_RGB_COLORS = 0;
154 int DIB_PAL_COLORS = 1;
155
156
157 HBITMAP CreateDIBitmap(HDC hDC, BITMAPINFOHEADER lpbmih, int fdwInit,
158 Pointer lpbInit, BITMAPINFO lpbmi, int fuUsage);
159
160
161 HBITMAP CreateDIBSection(HDC hDC, BITMAPINFO pbmi, int iUsage,
162 PointerByReference ppvBits, Pointer hSection, int dwOffset);
163
164
165 HBITMAP CreateCompatibleBitmap(HDC hDC, int width, int height);
166
167
168 HANDLE SelectObject(HDC hDC, HANDLE hGDIObj);
169
170
171 boolean DeleteObject(HANDLE p);
172 }