1 /* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
2  *
3  * The contents of this file is dual-licensed under 2
4  * alternative Open Source/Free licenses: LGPL 2.1 or later and
5  * Apache License 2.0. (starting with JNA version 4.0.0).
6  *
7  * You can freely decide which license you want to apply to
8  * the project.
9  *
10  * You may obtain a copy of the LGPL License at:
11  *
12  * http://www.gnu.org/licenses/licenses.html
13  *
14  * A copy is also included in the downloadable source code package
15  * containing JNA, in file "LGPL2.1".
16  *
17  * You may obtain a copy of the Apache License at:
18  *
19  * http://www.apache.org/licenses/
20  *
21  * A copy is also included in the downloadable source code package
22  * containing JNA, in file "AL2.0".
23  */
24 package com.sun.jna.platform.win32;
25 
26 import com.sun.jna.NativeLong;
27 import com.sun.jna.Pointer;
28 import com.sun.jna.Structure;
29 import com.sun.jna.Structure.FieldOrder;
30 import com.sun.jna.platform.win32.WinNT.HANDLE;
31 import com.sun.jna.platform.win32.WinDef.HBITMAP;
32 import com.sun.jna.platform.win32.WinDef.RECT;
33 
34 /**
35  * Ported from WinGDI.h.
36  * Microsoft Windows SDK 6.0A.
37  * @author dblock[at]dblock.org
38  * @author Andreas "PAX" Lück, onkelpax-git[at]yahoo.de
39  */
40 public interface WinGDI {
41     int RDH_RECTANGLES = 1;
42 
43     @FieldOrder({"dwSize", "iType", "nCount", "nRgnSize", "rcBound"})
44     class RGNDATAHEADER extends Structure {
45         public int dwSize = size();
46         public int iType = RDH_RECTANGLES; // required
47         public int nCount;
48         public int nRgnSize;
49         public RECT rcBound;
50     }
51 
52     @FieldOrder({"rdh", "Buffer"})
53     class RGNDATA extends Structure {
54         public RGNDATAHEADER rdh;
55         public byte[] Buffer;
56 
RGNDATA()57         public RGNDATA() {
58             this(1);
59         }
RGNDATA(int bufferSize)60         public RGNDATA(int bufferSize) {
61             Buffer = new byte[bufferSize];
62             allocateMemory();
63         }
64     }
65 
66     HANDLE HGDI_ERROR = new HANDLE(Pointer.createConstant(0xFFFFFFFF));
67 
68     int RGN_AND = 1;
69     int RGN_OR = 2;
70     int RGN_XOR = 3;
71     int RGN_DIFF = 4;
72     int RGN_COPY = 5;
73 
74     int ERROR = 0;
75     int NULLREGION = 1;
76     int SIMPLEREGION = 2;
77     int COMPLEXREGION = 3;
78 
79     int ALTERNATE = 1;
80     int WINDING = 2;
81 
82     int BI_RGB = 0;
83     int BI_RLE8 = 1;
84     int BI_RLE4 = 2;
85     int BI_BITFIELDS = 3;
86     int BI_JPEG = 4;
87     int BI_PNG = 5;
88 
89     int PFD_TYPE_RGBA = 0;
90     int PFD_TYPE_COLORINDEX = 1;
91 
92     int PFD_MAIN_PLANE = 0;
93     int PFD_OVERLAY_PLANE = 1;
94     int PFD_UNDERLAY_PLANE = (-1);
95 
96     int PFD_DOUBLEBUFFER = 0x00000001;
97     int PFD_STEREO = 0x00000002;
98     int PFD_DRAW_TO_WINDOW = 0x00000004;
99     int PFD_DRAW_TO_BITMAP = 0x00000008;
100     int PFD_SUPPORT_GDI = 0x00000010;
101     int PFD_SUPPORT_OPENGL = 0x00000020;
102     int PFD_GENERIC_FORMAT = 0x00000040;
103     int PFD_NEED_PALETTE = 0x00000080;
104     int PFD_NEED_SYSTEM_PALETTE = 0x00000100;
105     int PFD_SWAP_EXCHANGE = 0x00000200;
106     int PFD_SWAP_COPY = 0x00000400;
107     int PFD_SWAP_LAYER_BUFFERS = 0x00000800;
108     int PFD_GENERIC_ACCELERATED = 0x00001000;
109     int PFD_SUPPORT_DIRECTDRAW = 0x00002000;
110 
111     @FieldOrder({"biSize", "biWidth", "biHeight", "biPlanes", "biBitCount",
112         "biCompression", "biSizeImage", "biXPelsPerMeter", "biYPelsPerMeter",
113         "biClrUsed", "biClrImportant"})
114     class BITMAPINFOHEADER extends Structure {
115         public int biSize = size();
116         public int biWidth;
117         public int biHeight;
118         public short biPlanes;
119         public short biBitCount;
120         public int biCompression;
121         public int biSizeImage;
122         public int biXPelsPerMeter;
123         public int biYPelsPerMeter;
124         public int biClrUsed;
125         public int biClrImportant;
126     }
127 
128     @FieldOrder({"rgbBlue", "rgbGreen", "rgbRed", "rgbReserved"})
129     class RGBQUAD extends Structure {
130         public byte rgbBlue;
131         public byte rgbGreen;
132         public byte rgbRed;
133         public byte rgbReserved = 0;
134     }
135 
136     @FieldOrder({"bmiHeader", "bmiColors"})
137     class BITMAPINFO extends Structure {
138 
139         public BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER();
140         public RGBQUAD[] bmiColors = new RGBQUAD[1];
BITMAPINFO()141         public BITMAPINFO() {
142             this(1);
143         }
BITMAPINFO(int size)144         public BITMAPINFO(int size) {
145             bmiColors = new RGBQUAD[size];
146         }
147     }
148 
149     @FieldOrder({"fIcon", "xHotspot", "yHotspot", "hbmMask", "hbmColor"})
150     class ICONINFO extends Structure {
151         public boolean fIcon;
152         public int xHotspot;
153         public int yHotspot;
154         public HBITMAP hbmMask;
155         public HBITMAP hbmColor;
156     }
157 
158     @FieldOrder({"bmType", "bmWidth", "bmHeight", "bmWidthBytes", "bmPlanes", "bmBitsPixel", "bmBits"})
159     class BITMAP extends Structure {
160         public NativeLong bmType;
161         public NativeLong bmWidth;
162         public NativeLong bmHeight;
163         public NativeLong bmWidthBytes;
164         public short bmPlanes;
165         public short bmBitsPixel;
166         public Pointer bmBits;
167     }
168 
169     @FieldOrder({"dsBm", "dsBmih", "dsBitfields", "dshSection", "dsOffset"})
170     class DIBSECTION extends Structure {
171         public BITMAP           dsBm;
172         public BITMAPINFOHEADER dsBmih;
173         public int[]            dsBitfields = new int[3];
174         public HANDLE           dshSection;
175         public int              dsOffset;
176     }
177 
178     int DIB_RGB_COLORS = 0;
179     int DIB_PAL_COLORS = 1;
180 
181     /**
182      * The PIXELFORMATDESCRIPTOR structure describes the pixel format of a drawing surface.
183      */
184     @FieldOrder({"nSize", "nVersion", "dwFlags", "iPixelType",
185         "cColorBits", "cRedBits", "cRedShift", "cGreenBits", "cGreenShift", "cBlueBits", "cBlueShift", "cAlphaBits", "cAlphaShift",
186         "cAccumBits", "cAccumRedBits", "cAccumGreenBits", "cAccumBlueBits", "cAccumAlphaBits",
187         "cDepthBits", "cStencilBits", "cAuxBuffers", "iLayerType", "bReserved", "dwLayerMask", "dwVisibleMask", "dwDamageMask"})
188     class PIXELFORMATDESCRIPTOR extends Structure {
PIXELFORMATDESCRIPTOR()189         public PIXELFORMATDESCRIPTOR() {
190             nSize = (short) size();
191         }
192 
PIXELFORMATDESCRIPTOR(Pointer memory)193         public PIXELFORMATDESCRIPTOR(Pointer memory) {
194             super(memory);
195             read();
196         }
197 
198         public static class ByReference extends PIXELFORMATDESCRIPTOR implements Structure.ByReference {
199         }
200 
201         /**
202          * Specifies the size of this data structure. This value should be set to sizeof(PIXELFORMATDESCRIPTOR).
203          */
204         public short  nSize;
205         /**
206          * Specifies the version of this data structure. This value should be set to 1.
207          */
208         public short  nVersion;
209         /**
210          * A set of bit flags that specify properties of the pixel buffer.
211          */
212         public int dwFlags;
213         /**
214          * Specifies the type of pixel data.
215          */
216         public byte  iPixelType;
217         /**
218          * Specifies the number of color bitplanes in each color buffer.
219          */
220         public byte  cColorBits;
221         /**
222          * Specifies the number of red bitplanes in each RGBA color buffer.
223          */
224         public byte  cRedBits;
225         /**
226          * Specifies the shift count for red bitplanes in each RGBA color buffer.
227          */
228         public byte  cRedShift;
229         /**
230          * Specifies the number of green bitplanes in each RGBA color buffer.
231          */
232         public byte  cGreenBits;
233         /**
234          * Specifies the shift count for green bitplanes in each RGBA color buffer.
235          */
236         public byte  cGreenShift;
237         /**
238          * Specifies the number of blue bitplanes in each RGBA color buffer.
239          */
240         public byte  cBlueBits;
241         /**
242          * Specifies the shift count for blue bitplanes in each RGBA color buffer.
243          */
244         public byte  cBlueShift;
245         /**
246          * Specifies the number of alpha bitplanes in each RGBA color buffer. Alpha bitplanes are not supported.
247          */
248         public byte  cAlphaBits;
249         /**
250          * Specifies the shift count for alpha bitplanes in each RGBA color buffer. Alpha bitplanes are not supported.
251          */
252         public byte  cAlphaShift;
253         /**
254          * Specifies the total number of bitplanes in the accumulation buffer.
255          */
256         public byte  cAccumBits;
257         /**
258          * Specifies the number of red bitplanes in the accumulation buffer.
259          */
260         public byte  cAccumRedBits;
261         /**
262          * Specifies the number of green bitplanes in the accumulation buffer.
263          */
264         public byte  cAccumGreenBits;
265         /**
266          * Specifies the number of blue bitplanes in the accumulation buffer.
267          */
268         public byte  cAccumBlueBits;
269         /**
270          * Specifies the number of alpha bitplanes in the accumulation buffer.
271          */
272         public byte  cAccumAlphaBits;
273         /**
274          * Specifies the depth of the depth (z-axis) buffer.
275          */
276         public byte  cDepthBits;
277         /**
278          * Specifies the depth of the stencil buffer.
279          */
280         public byte  cStencilBits;
281         /**
282          * Specifies the number of auxiliary buffers. Auxiliary buffers are not supported.
283          */
284         public byte  cAuxBuffers;
285         /**
286          * Ignored. Earlier implementations of OpenGL used this member, but it is no longer used.
287          */
288         public byte  iLayerType;
289         /**
290          * Specifies the number of overlay and underlay planes.
291          */
292         public byte  bReserved;
293         /**
294          * Ignored. Earlier implementations of OpenGL used this member, but it is no longer used.
295          */
296         public int dwLayerMask;
297         /**
298          * Specifies the transparent color or index of an underlay plane.
299          */
300         public int dwVisibleMask;
301         /**
302          * Ignored. Earlier implementations of OpenGL used this member, but it is no longer used.
303          */
304         public int dwDamageMask;
305     }
306 }
307