]> Pileus Git - ~andy/gtk/blob - gdk-pixbuf/io-gdip-native.h
Bug 457086 - numpad does not work when the Thai-Lao input method is used
[~andy/gtk] / gdk-pixbuf / io-gdip-native.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
2 /* GdkPixbuf library - Win32 GDI+ Pixbuf Loader
3  *
4  * Copyright (C) 2007 Google (Evan Stade)
5  * Copyright (C) 2008 Alberto Ruiz <aruiz@gnome.org>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21
22 #ifndef _HAVE_IO_GDIP_NATIVE_H
23 #define _HAVE_IO_GDIP_NATIVE_H
24
25 #include <windows.h>
26
27 #include <glib.h>
28
29 /* //////////// Native API ///////////// */
30
31 #define WINGDIPAPI __stdcall
32
33 typedef gulong ARGB;
34 typedef gint PixelFormat;
35
36 typedef enum {
37     EncoderParameterValueTypeByte = 1,
38     EncoderParameterValueTypeASCII = 2,
39     EncoderParameterValueTypeShort = 3,
40     EncoderParameterValueTypeLong = 4,
41     EncoderParameterValueTypeRational = 5,
42     EncoderParameterValueTypeLongRange = 6,
43     EncoderParameterValueTypeUndefined = 7,
44     EncoderParameterValueTypeRationalRange = 8,
45     EncoderParameterValueTypePointer = 9
46 } EncoderParameterValueType;
47
48 #define    PixelFormatIndexed   0x00010000
49 #define    PixelFormatGDI       0x00020000
50 #define    PixelFormatAlpha     0x00040000
51 #define    PixelFormatPAlpha    0x00080000
52 #define    PixelFormatExtended  0x00100000
53 #define    PixelFormatCanonical 0x00200000
54
55 #define    PixelFormatUndefined 0
56 #define    PixelFormatDontCare  0
57
58 #define    PixelFormat1bppIndexed       (1 | ( 1 << 8) | PixelFormatIndexed | PixelFormatGDI)
59 #define    PixelFormat4bppIndexed       (2 | ( 4 << 8) | PixelFormatIndexed | PixelFormatGDI)
60 #define    PixelFormat8bppIndexed       (3 | ( 8 << 8) | PixelFormatIndexed | PixelFormatGDI)
61 #define    PixelFormat16bppGrayScale    (4 | (16 << 8) | PixelFormatExtended)
62 #define    PixelFormat16bppRGB555       (5 | (16 << 8) | PixelFormatGDI)
63 #define    PixelFormat16bppRGB565       (6 | (16 << 8) | PixelFormatGDI)
64 #define    PixelFormat16bppARGB1555     (7 | (16 << 8) | PixelFormatAlpha | PixelFormatGDI)
65 #define    PixelFormat24bppRGB          (8 | (24 << 8) | PixelFormatGDI)
66 #define    PixelFormat32bppRGB          (9 | (32 << 8) | PixelFormatGDI)
67 #define    PixelFormat32bppARGB         (10 | (32 << 8) | PixelFormatAlpha | PixelFormatGDI | PixelFormatCanonical)
68 #define    PixelFormat32bppPARGB        (11 | (32 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatGDI)
69 #define    PixelFormat48bppRGB          (12 | (48 << 8) | PixelFormatExtended)
70 #define    PixelFormat64bppARGB         (13 | (64 << 8) | PixelFormatAlpha  | PixelFormatCanonical | PixelFormatExtended)
71 #define    PixelFormat64bppPARGB        (14 | (64 << 8) | PixelFormatAlpha  | PixelFormatPAlpha | PixelFormatExtended)
72 #define    PixelFormatMax               15
73
74 enum _Status
75 {
76     Ok                          = 0,
77     GenericError                = 1,
78     InvalidParameter            = 2,
79     OutOfMemory                 = 3,
80     ObjectBusy                  = 4,
81     InsufficientBuffer          = 5,
82     NotImplemented              = 6,
83     Win32Error                  = 7,
84     WrongState                  = 8,
85     Aborted                     = 9,
86     FileNotFound                = 10,
87     ValueOverflow               = 11,
88     AccessDenied                = 12,
89     UnknownImageFormat          = 13,
90     FontFamilyNotFound          = 14,
91     FontStyleNotFound           = 15,
92     NotTrueTypeFont             = 16,
93     UnsupportedGdiplusVersion   = 17,
94     GdiplusNotInitialized       = 18,
95     PropertyNotFound            = 19,
96     PropertyNotSupported        = 20,
97     ProfileNotFound             = 21
98 };
99 typedef enum _Status Status;
100 typedef enum _Status GpStatus;
101
102 typedef enum {
103     ImageFlagsNone = 0,
104     ImageFlagsScalable = 0x0001,
105     ImageFlagsHasAlpha = 0x0002,
106     ImageFlagsHasTranslucent = 0x0004,
107     ImageFlagsPartiallyScalable = 0x0008,
108     ImageFlagsColorSpaceRGB = 0x0010,
109     ImageFlagsColorSpaceCMYK = 0x0020,
110     ImageFlagsColorSpaceGRAY = 0x0040,
111     ImageFlagsColorSpaceYCBCR = 0x0080,
112     ImageFlagsColorSpaceYCCK = 0x0100,
113     ImageFlagsHasRealDPI = 0x1000,
114     ImageFlagsHasRealPixelSize = 0x2000,
115     ImageFlagsReadOnly = 0x00010000,
116     ImageFlagsCaching = 0x00020000
117 } ImageFlags;
118
119 enum _ImageLockMode
120 {
121     ImageLockModeRead           = 1,
122     ImageLockModeWrite          = 2,
123     ImageLockModeUserInputBuf   = 4
124 };
125 typedef enum _ImageLockMode ImageLockMode;
126
127 enum _ImageType
128 {
129     ImageTypeUnknown,
130     ImageTypeBitmap,
131     ImageTypeMetafile
132 };
133 typedef enum _ImageType ImageType;
134
135 typedef struct _GpImage GpImage;
136 typedef struct _GpBitmap GpBitmap;
137 typedef struct _GpGraphics GpGraphics;
138
139 struct _GdiplusStartupInput
140 {
141     UINT32 GdiplusVersion;
142     gpointer DebugEventCallback;
143     BOOL SuppressBackgroundThread;
144     BOOL SuppressExternalCodecs;
145 };
146 typedef struct _GdiplusStartupInput GdiplusStartupInput;
147
148 struct _PropItem
149 {
150   ULONG id;
151   ULONG length;
152   WORD type;
153   VOID *value;
154 };
155 typedef struct _PropItem PropertyItem;
156
157 struct _EncoderParameter
158 {
159     GUID    Guid;
160     ULONG   NumberOfValues;
161     ULONG   Type;
162     VOID*   Value;
163 };
164 typedef struct _EncoderParameter EncoderParameter;
165
166 struct _EncoderParameters
167 {
168     UINT Count;                      /* Number of parameters in this structure */
169     EncoderParameter Parameter[1];   /* Parameter values */
170 };
171 typedef struct _EncoderParameters EncoderParameters;
172
173 struct _ImageCodecInfo
174 {
175     CLSID Clsid;
176     GUID  FormatID;
177     const WCHAR* CodecName;
178     const WCHAR* DllName;
179     const WCHAR* FormatDescription;
180     const WCHAR* FilenameExtension;
181     const WCHAR* MimeType;
182     DWORD Flags;
183     DWORD Version;
184     DWORD SigCount;
185     DWORD SigSize;
186     const BYTE* SigPattern;
187     const BYTE* SigMask;
188 };
189 typedef struct _ImageCodecInfo ImageCodecInfo;
190
191 struct _BitmapData
192 {
193     UINT Width;
194     UINT Height;
195     INT Stride;
196     PixelFormat PixelFormat;
197     VOID* Scan0;
198     UINT_PTR Reserved;
199 };
200 typedef struct _BitmapData BitmapData;
201
202 struct _GpRect
203 {
204     INT X;
205     INT Y;
206     INT Width;
207     INT Height;
208 };
209 typedef struct _GpRect GpRect;
210
211 #ifndef IStream_Release
212 #define IStream_Release(This) (This)->lpVtbl->Release(This)
213 #endif
214
215 #ifndef IStream_Seek
216 #define IStream_Seek(This,dlibMove,dwOrigin,plibNewPosition) (This)->lpVtbl->Seek(This,dlibMove,dwOrigin,plibNewPosition)
217 #endif
218
219 #ifndef IStream_Read
220 #define IStream_Read(This,pv,cb,pcbRead) (This)->lpVtbl->Read(This,pv,cb,pcbRead)
221 #endif
222
223 #ifndef IStream_SetSize
224 #define IStream_SetSize(This,size) (This)->lpVtbl->SetSize(This,size)
225 #endif
226
227 typedef GpStatus (WINGDIPAPI* GdiplusStartupFunc) (gpointer, const gpointer, gpointer);
228 typedef GpStatus (WINGDIPAPI* GdipCreateBitmapFromStreamFunc) (gpointer, GpBitmap**);
229 typedef GpStatus (WINGDIPAPI* GdipBitmapGetPixelFunc) (GpBitmap*, gint x, gint y, ARGB*);
230 typedef GpStatus (WINGDIPAPI* GdipGetImageWidthFunc) (GpImage*, guint*);
231 typedef GpStatus (WINGDIPAPI* GdipGetImageHeightFunc) (GpImage*, guint*);
232 typedef GpStatus (WINGDIPAPI* GdipDisposeImageFunc) (GpImage*);
233 typedef GpStatus (WINGDIPAPI* GdipGetImageFlagsFunc) (GpImage *, guint*);
234 typedef GpStatus (WINGDIPAPI* GdipImageGetFrameCountFunc) (GpImage *image, const GUID* dimensionID, UINT* count);
235 typedef GpStatus (WINGDIPAPI* GdipImageSelectActiveFrameFunc) (GpImage *image, const GUID* dimensionID, UINT frameIndex);
236 typedef GpStatus (WINGDIPAPI* GdipGetPropertyItemSizeFunc) (GpImage *image, int propId, guint* size);
237 typedef GpStatus (WINGDIPAPI* GdipGetPropertyItemFunc) (GpImage *image, int propId, guint propSize, PropertyItem* buffer);
238 typedef GpStatus (WINGDIPAPI* GdipGetPropertyCountFunc) (GpImage *image, guint* numOfProperty);
239 typedef GpStatus (WINGDIPAPI* GdipGetPropertyIdListFunc) (GpImage *image, guint numOfProperty, PROPID* list);
240 typedef GpStatus (WINGDIPAPI* GdipCreateBitmapFromScan0Func) (INT width, INT height, INT stride, PixelFormat format, BYTE* scan0, 
241                                                               GpBitmap** bitmap);
242 typedef GpStatus (WINGDIPAPI* GdipSaveImageToStreamFunc) (GpImage *image, IStream* stream, const CLSID* clsidEncoder, 
243                                                           const EncoderParameters* encoderParams);
244
245 typedef GpStatus (WINGDIPAPI* GdipGetImageEncodersFunc) (UINT numEncoders, UINT size, ImageCodecInfo *encoders);
246 typedef GpStatus (WINGDIPAPI* GdipGetImageEncodersSizeFunc) (UINT *numEncoders, UINT *size);
247 typedef GpStatus (WINGDIPAPI* GdipBitmapSetPixelFunc) (GpBitmap* bitmap, INT x, INT y, ARGB color);
248
249 typedef GpStatus (WINGDIPAPI* GdipDrawImageIFunc) (GpGraphics *graphics, GpImage *image, INT x, INT y);
250 typedef GpStatus (WINGDIPAPI* GdipGetImageGraphicsContextFunc) (GpImage *image, GpGraphics **graphics);
251 typedef GpStatus (WINGDIPAPI* GdipFlushFunc) (GpGraphics *graphics, INT intention);
252 typedef GpStatus (WINGDIPAPI* GdipGraphicsClearFunc) (GpGraphics *graphics, ARGB color);
253 typedef GpStatus (WINGDIPAPI* GdipBitmapSetResolutionFunc) (GpBitmap* bitmap, float xdpi, float ydpi);
254 typedef GpStatus (WINGDIPAPI* GdipGetImageHorizontalResolutionFunc) (GpImage *image, float *resolution);
255 typedef GpStatus (WINGDIPAPI* GdipGetImageVerticalResolutionFunc) (GpImage *image, float *resolution);
256 typedef GpStatus (WINGDIPAPI* GdipLoadImageFromStreamFunc) (IStream* stream, GpImage **image);
257 typedef GpStatus (WINGDIPAPI* GdipDeleteGraphicsFunc) (GpGraphics *graphics);
258
259 typedef GpStatus (WINGDIPAPI* GdipBitmapLockBitsFunc) (GpBitmap* bitmap, const GpRect* rect, UINT flags, PixelFormat format, BitmapData* lockedBitmapData);
260 typedef GpStatus (WINGDIPAPI* GdipBitmapUnlockBitsFunc) (GpBitmap* bitmap, BitmapData* lockedBitmapData);
261 typedef GpStatus (WINGDIPAPI* GdipGetImagePixelFormatFunc) (GpImage *image, PixelFormat *format);
262 typedef GpStatus (WINGDIPAPI* GdipCloneBitmapAreaIFunc) (INT x, INT y, INT width, INT height, PixelFormat format, GpBitmap *srcBitmap, GpBitmap **dstBitmap);
263
264 #endif