1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
2 /* GdkPixbuf library - Win32 GDI+ Pixbuf Loader
4 * Copyright (C) 2007 Google (Evan Stade)
5 * Copyright (C) 2008 Alberto Ruiz <aruiz@gnome.org>
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.
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.
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
22 #ifndef _HAVE_IO_GDIP_NATIVE_H
23 #define _HAVE_IO_GDIP_NATIVE_H
29 /* //////////// Native API ///////////// */
31 #define WINGDIPAPI __stdcall
34 typedef gint PixelFormat;
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;
48 #define PixelFormatIndexed 0x00010000
49 #define PixelFormatGDI 0x00020000
50 #define PixelFormatAlpha 0x00040000
51 #define PixelFormatPAlpha 0x00080000
52 #define PixelFormatExtended 0x00100000
53 #define PixelFormatCanonical 0x00200000
55 #define PixelFormatUndefined 0
56 #define PixelFormatDontCare 0
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
81 InsufficientBuffer = 5,
89 UnknownImageFormat = 13,
90 FontFamilyNotFound = 14,
91 FontStyleNotFound = 15,
93 UnsupportedGdiplusVersion = 17,
94 GdiplusNotInitialized = 18,
95 PropertyNotFound = 19,
96 PropertyNotSupported = 20,
99 typedef enum _Status Status;
100 typedef enum _Status GpStatus;
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
121 ImageLockModeRead = 1,
122 ImageLockModeWrite = 2,
123 ImageLockModeUserInputBuf = 4
125 typedef enum _ImageLockMode ImageLockMode;
133 typedef enum _ImageType ImageType;
135 typedef struct _GpImage GpImage;
136 typedef struct _GpBitmap GpBitmap;
137 typedef struct _GpGraphics GpGraphics;
139 struct _GdiplusStartupInput
141 UINT32 GdiplusVersion;
142 gpointer DebugEventCallback;
143 BOOL SuppressBackgroundThread;
144 BOOL SuppressExternalCodecs;
146 typedef struct _GdiplusStartupInput GdiplusStartupInput;
155 typedef struct _PropItem PropertyItem;
157 struct _EncoderParameter
160 ULONG NumberOfValues;
164 typedef struct _EncoderParameter EncoderParameter;
166 struct _EncoderParameters
168 UINT Count; /* Number of parameters in this structure */
169 EncoderParameter Parameter[1]; /* Parameter values */
171 typedef struct _EncoderParameters EncoderParameters;
173 struct _ImageCodecInfo
177 const WCHAR* CodecName;
178 const WCHAR* DllName;
179 const WCHAR* FormatDescription;
180 const WCHAR* FilenameExtension;
181 const WCHAR* MimeType;
186 const BYTE* SigPattern;
189 typedef struct _ImageCodecInfo ImageCodecInfo;
196 PixelFormat PixelFormat;
200 typedef struct _BitmapData BitmapData;
209 typedef struct _GpRect GpRect;
211 #ifndef IStream_Release
212 #define IStream_Release(This) (This)->lpVtbl->Release(This)
216 #define IStream_Seek(This,dlibMove,dwOrigin,plibNewPosition) (This)->lpVtbl->Seek(This,dlibMove,dwOrigin,plibNewPosition)
220 #define IStream_Read(This,pv,cb,pcbRead) (This)->lpVtbl->Read(This,pv,cb,pcbRead)
223 #ifndef IStream_SetSize
224 #define IStream_SetSize(This,size) (This)->lpVtbl->SetSize(This,size)
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,
242 typedef GpStatus (WINGDIPAPI* GdipSaveImageToStreamFunc) (GpImage *image, IStream* stream, const CLSID* clsidEncoder,
243 const EncoderParameters* encoderParams);
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);
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);
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);