1 module aurora.directx.wic;
2 
3 version(Windows):
4 
5 import aurora.directx.com;
6 
7 alias uint WICColor;
8 
9 enum WICColorContextType : int { 
10 	Uninitialized   = 0x00000000,
11 	Profile         = 0x00000001,
12 	ExifColorSpace  = 0x00000002
13 }
14 
15 enum WICBitmapPaletteType : int { 
16 	Custom            = 0x00000000,
17 	MedianCut         = 0x00000001,
18 	FixedBW           = 0x00000002,
19 	FixedHalftone8    = 0x00000003,
20 	FixedHalftone27   = 0x00000004,
21 	FixedHalftone64   = 0x00000005,
22 	FixedHalftone125  = 0x00000006,
23 	FixedHalftone216  = 0x00000007,
24 	FixedWebPalette   = FixedHalftone216,
25 	FixedHalftone252  = 0x00000008,
26 	FixedHalftone256  = 0x00000009,
27 	FixedGray4        = 0x0000000A,
28 	FixedGray16       = 0x0000000B,
29 	FixedGray256      = 0x0000000C
30 }
31 
32 enum WICBitmapCreateCacheOption { 
33 	NoCache        = 0x00000000,
34 	CacheOnDemand  = 0x00000001,
35 	CacheOnLoad    = 0x00000002
36 }
37 
38 enum WICBitmapAlphaChannelOption { 
39 	UseAlpha                         = 0x00000000,
40 	UsePremultipliedAlpha            = 0x00000001,
41 	IgnoreAlpha                      = 0x00000002,
42 	ALPHACHANNELOPTIONS_FORCE_DWORD  = 0xFFFFFFFF,
43 }
44 
45 enum WICDecodeOptions { 
46 	MetadataCacheOnDemand  = 0x00000000,
47 	MetadataCacheOnLoad    = 0x00000001
48 }
49 
50 enum WICBitmapTransformOptions { 
51 	Rotate0         = 0x00000000,
52 	Rotate90        = 0x00000001,
53 	Rotate180       = 0x00000002,
54 	Rotate270       = 0x00000003,
55 	FlipHorizontal  = 0x00000008,
56 	FlipVertical    = 0x00000010
57 }
58 
59 enum WICBitmapInterpolationMode { 
60 	NearestNeighbor  = 0x00000000,
61 	Linear           = 0x00000001,
62 	Cubic            = 0x00000002,
63 	Fant             = 0x00000003
64 }
65 
66 enum WICComponentType { 
67 	Decoder               = 0x00000001,
68 	Encoder               = 0x00000002,
69 	PixelFormatConverter  = 0x00000004,
70 	MetadataReader        = 0x00000008,
71 	MetadataWriter        = 0x00000010,
72 	PixelFormat           = 0x00000020,
73 	AllComponents         = 0x0000003F
74 }
75 
76 enum WICComponentSigning { 
77 	Signed    = 0x00000001,
78 	Unsigned  = 0x00000002,
79 	Safe      = 0x00000004,
80 	Disabled  = 0x80000000
81 }
82 
83 enum WICBitmapDecoderCapabilities { 
84 	SameEncoder           = 0x00000001,
85 	CanDecodeAllImages    = 0x00000002,
86 	CanDecodeSomeImages   = 0x00000004,
87 	CanEnumerateMetadata  = 0x00000008,
88 	CanDecodeThumbnail    = 0x00000010
89 }
90 
91 enum WICBitmapEncoderCacheOption { 
92 	CacheInMemory  = 0x00000000,
93 	CacheTempFile  = 0x00000001,
94 	NoCache        = 0x00000002
95 }
96 
97 enum WICBitmapDitherType { 
98 	None            = 0x00000000,
99 	Solid           = 0x00000000,
100 	Ordered4x4      = 0x00000001,
101 	Ordered8x8      = 0x00000002,
102 	Ordered16x16    = 0x00000003,
103 	Spiral4x4       = 0x00000004,
104 	Spiral8x8       = 0x00000005,
105 	DualSpiral4x4   = 0x00000006,
106 	DualSpiral8x8   = 0x00000007,
107 	ErrorDiffusion  = 0x00000008
108 }
109 
110 public struct WICRect 
111 {
112 	int X;
113 	int Y;
114 	int Width;
115 	int Height;
116 }
117 
118 public struct WICBitmapPattern {
119 	ULARGE_INTEGER Position;
120 	ulong Length;
121 	ubyte *Pattern;
122 	ubyte *Mask;
123 	BOOL           EndOfStream;
124 }
125 
126 mixin(uuid!(IWICColorContext, "3C613A02-34B2-44ea-9A7C-45AEA9C6FD6D"));
127 public interface IWICColorContext : IUnknown
128 {
129 extern(Windows):
130 	HRESULT GetExifColorSpace(uint *pValue);
131 	HRESULT GetProfileBytes(uint cbBuffer, ubyte *pbBuffer, uint *pcbActual);
132 	HRESULT GetType(WICColorContextType *pType);
133 	HRESULT InitializeFromExifColorSpace(uint value);
134 	HRESULT InitializeFromFilename(LPCWSTR wzFilename);
135 	HRESULT InitializeFromMemory(const(ubyte) *pbBuffer, uint cbBufferSize);
136 }
137 
138 mixin(uuid!(IWICPalette , "00000040-a8f2-4877-ba0a-fd2b6645fb94"));
139 public interface IWICPalette  : IUnknown
140 {
141 extern(Windows):
142 	HRESULT GetColorCount(uint *pcCount);
143 	HRESULT GetColors(uint colorCount, WICColor *pColors, uint *pcActualColors);
144 	HRESULT GetType(WICBitmapPaletteType *pePaletteType);
145 	HRESULT HasAlpha(BOOL *pfHasAlpha);
146 	HRESULT InitializeCustom(WICColor *pColors, uint colorCount);
147 	HRESULT InitializeFromBitmap(IWICBitmapSource *pISurface, uint colorCount, BOOL fAddTransparentColor);
148 	HRESULT InitializeFromPalette(IWICPalette *pIMILPalette);
149 	HRESULT InitializePredefined(WICBitmapPaletteType ePaletteType, BOOL fAddTransparentColor);
150 	HRESULT IsBlackWhite(BOOL *pfIsBlackWhite);
151 	HRESULT IsGrayscale(BOOL *pfIsGrayscale);
152 }
153 
154 mixin(uuid!(IWICBitmapLock, "00000123-a8f2-4877-ba0a-fd2b6645fb94"));
155 public interface IWICBitmapLock : IUnknown
156 {
157 extern(Windows):
158 	HRESULT GetDataPointer(uint *pcbBufferSize, ubyte **ppbData);
159 	HRESULT GetPixelFormat(GUID *pPixelFormat);
160 	HRESULT GetSize(uint *pWidth, uint *pHeight);
161 	HRESULT GetStride(uint *pcbStride);
162 }
163 
164 mixin(uuid!(IWICBitmapSource, "00000120-a8f2-4877-ba0a-fd2b6645fb94"));
165 public interface IWICBitmapSource : IUnknown
166 {
167 extern(Windows):
168 	HRESULT CopyPalette(IWICPalette pIPalette);
169 	HRESULT CopyPixels(const WICRect *prc, uint cbStride, uint cbBufferSize, ubyte *pbBuffer);
170 	HRESULT GetPixelFormat(GUID *pPixelFormat);
171 	HRESULT GetResolution(double *pDpiX, double *pDpiY);
172 	HRESULT GetSize(uint *puiWidth, uint *puiHeight);
173 }
174 
175 mixin(uuid!(IWICBitmap, "00000121-a8f2-4877-ba0a-fd2b6645fb94"));
176 public interface IWICBitmap : IWICBitmapSource
177 {
178 extern(Windows):
179 	HRESULT Lock(const WICRect *prcLock, DWORD flags, IWICBitmapLock **ppILock);
180 	HRESULT SetPalette(IWICPalette pIPalette);
181 	HRESULT SetResolution(double dpiX, double dpiY);
182 }
183 
184 mixin(uuid!(IWICImagingFactory , "ec5ec8a9-c395-4314-9c77-54d7a935ff70"));
185 public interface IWICImagingFactory : IUnknown
186 {
187 extern(Windows):
188 	HRESULT CreateBitmap(uint uiWidth, uint uiHeight, GUID* pixelFormat, WICBitmapCreateCacheOption option, IWICBitmap *ppIBitmap);
189 	HRESULT CreateBitmapClipper(IWICBitmapClipper **ppIBitmapClipper);
190 	HRESULT CreateBitmapFlipRotator(IWICBitmapFlipRotator **ppIBitmapFlipRotator);
191 	HRESULT CreateBitmapFromHBITMAP(HBITMAP hBitmap, HPALETTE hPalette, WICBitmapAlphaChannelOption options, IWICBitmap *ppIBitmap);
192 	HRESULT CreateBitmapFromHICON(HICON hIcon, IWICBitmap *ppIBitmap);
193 	HRESULT CreateBitmapFromMemory(uint uiWidth, uint uiHeight, GUID pixelFormat, uint cbStride, uint cbBufferSize, ubyte *pbBuffer, IWICBitmap *ppIBitmap);
194 	HRESULT CreateBitmapFromSource(IWICBitmapSource pIBitmapSource, WICBitmapCreateCacheOption option, IWICBitmap **ppIBitmap);
195 	HRESULT CreateBitmapFromSourceRect(IWICBitmapSource pIBitmapSource, uint x, uint y, uint width, uint height, IWICBitmap *ppIBitmap);
196 	HRESULT CreateBitmapScaler(IWICBitmapScaler *ppIBitmapScaler);
197 	HRESULT CreateColorContext(IWICColorContext *ppIWICColorContext);
198 	HRESULT CreateColorTransformer(IWICColorTransform *ppIWICColorTransform);
199 	HRESULT CreateComponentEnumerator(DWORD componentTypes, DWORD options, IEnumUnknown *ppIEnumUnknown);
200 	HRESULT CreateComponentInfo(CLSID* clsidComponent, IWICComponentInfo **ppIInfo);
201 	HRESULT CreateDecoder(GUID* guidContainerFormat, const GUID *pguidVendor, IWICBitmapDecoder **ppIDecoder);
202 	HRESULT CreateDecoderFromFileHandle(ulong* hFile, const GUID *pguidVendor, WICDecodeOptions metadataOptions, IWICBitmapDecoder *ppIDecoder);
203 	HRESULT CreateDecoderFromFilename(LPCWSTR wzFilename, const GUID *pguidVendor, DWORD dwDesiredAccess, WICDecodeOptions metadataOptions, IWICBitmapDecoder *ppIDecoder);
204 	HRESULT CreateDecoderFromStream(IStream *pIStream, const GUID *pguidVendor, WICDecodeOptions metadataOptions, IWICBitmapDecoder *ppIDecoder);
205 	HRESULT CreateEncoder(GUID* guidContainerFormat, const GUID *pguidVendor, IWICBitmapEncoder *ppIEncoder);
206 	HRESULT CreateFastMetadataEncoderFromDecoder(IWICBitmapDecoder pIDecoder, IWICFastMetadataEncoder *ppIFastEncoder);
207 	HRESULT CreateFastMetadataEncoderFromFrameDecode(IWICBitmapFrameDecode pIFrameDecoder, IWICFastMetadataEncoder *ppIFastEncoder);
208 	HRESULT CreateFormatConverter(IWICFormatConverter *ppIFormatConverter);
209 	HRESULT CreatePalette(IWICPalette *ppIPalette);
210 	HRESULT CreateQueryWriter(GUID* guidMetadataFormat, const GUID *pguidVendor, IWICMetadataQueryWriter *ppIQueryWriter);
211 	HRESULT CreateQueryWriterFromReader(IWICMetadataQueryReader pIQueryReader, const GUID *pguidVendor, IWICMetadataQueryWriter *ppIQueryWriter);
212 	HRESULT CreateStream(IWICStream *ppIWICStream);
213 }
214 
215 mixin(uuid!(IWICBitmapClipper, "E4FBCF03-223D-4e81-9333-D635556DD1B5"));
216 public interface IWICBitmapClipper : IWICBitmapSource
217 {
218 extern(Windows):
219 	HRESULT Initialize(IWICBitmapSource pISource, const WICRect *prc);
220 }
221 
222 mixin(uuid!(IWICBitmapFlipRotator, "5009834F-2D6A-41ce-9E1B-17C5AFF7A782"));
223 public interface IWICBitmapFlipRotator : IWICBitmapSource
224 {
225 extern(Windows):
226 	HRESULT Initialize(IWICBitmapSource pISource, WICBitmapTransformOptions options);
227 }
228 
229 mixin(uuid!(IWICBitmapScaler, "00000302-a8f2-4877-ba0a-fd2b6645fb94"));
230 public interface IWICBitmapScaler : IWICBitmapSource
231 {
232 extern(Windows):
233 	HRESULT Initialize(IWICBitmapSource *pISource, uint uiWidth, uint uiHeight, WICBitmapInterpolationMode mode);
234 }
235 
236 mixin(uuid!(IWICColorTransform, "B66F034F-D0E2-40ab-B436-6DE39E321A94"));
237 public interface IWICColorTransform : IWICBitmapSource
238 {
239 extern(Windows):
240 	HRESULT Initialize(IWICBitmapSource pIBitmapSource, IWICColorContext pIContextSource, IWICColorContext pIContextDest, GUID pixelFmtDest);
241 }
242 
243 mixin(uuid!(IWICComponentInfo , "23BC3F0A-698B-4357-886B-F24D50671334"));
244 public interface IWICComponentInfo : IUnknown
245 {
246 extern(Windows):
247 	HRESULT GetAuthor(uint cchAuthor, wchar *wzAuthor, uint *pcchActual);
248 	HRESULT GetCLSID(CLSID *pclsid);
249 	HRESULT GetComponentType(WICComponentType *pType);
250 	HRESULT GetFriendlyName(uint cchFriendlyName, wchar *wzFriendlyName, uint *pcchActual);
251 	HRESULT GetSigningStatus(DWORD *pStatus);
252 	HRESULT GetSpecVersion(uint cchSpecVersion, wchar *wzSpecVersion, uint *pcchActual);
253 	HRESULT GetVendorGUID(GUID *pguidVendor);
254 	HRESULT GetVersion(uint cchVersion, wchar *wzVersion, uint *pcchActual);
255 }
256 
257 mixin(uuid!(IWICBitmapDecoder , "9EDDE9E7-8DEE-47ea-99DF-E6FAF2ED44BF"));
258 public interface IWICBitmapDecoder : IUnknown
259 {
260 extern(Windows):
261 	HRESULT CopyPalette(IWICPalette pIPalette);
262 	HRESULT GetColorContexts(uint cCount, IWICColorContext *ppIColorContexts, uint *pcActualCount);
263 	HRESULT GetContainerFormat(GUID *pguidContainerFormat);
264 	HRESULT GetDecoderInfo(IWICBitmapDecoderInfo *ppIDecoderInfo);
265 	HRESULT GetFrame(uint index, IWICBitmapFrameDecode *ppIBitmapFrame);
266 	HRESULT GetFrameCount(uint *pCount);
267 	HRESULT GetMetadataQueryReader(IWICMetadataQueryReader *ppIMetadataQueryReader);
268 	HRESULT GetPreview(IWICBitmapSource *ppIBitmapSource);
269 	HRESULT GetThumbnail(IWICBitmapSource *ppIThumbnail);
270 	HRESULT Initialize(IStream *pIStream, WICDecodeOptions cacheOptions);
271 	HRESULT QueryCapability(IStream *pIStream, DWORD *pdwCapability);
272 }
273 
274 mixin(uuid!(IWICBitmapDecoderInfo, "D8CD007F-D08F-4191-9BFC-236EA7F0E4B5"));
275 public interface IWICBitmapDecoderInfo : IWICBitmapCodecInfo
276 {
277 extern(Windows):
278 	HRESULT CreateInstance(IWICBitmapDecoder *ppIBitmapDecoder);
279 	HRESULT GetPatterns(uint cbSizePatterns, WICBitmapPattern *pPatterns, uint *pcPatterns, uint *pcbPatternsActual);
280 	HRESULT MatchesPattern(IStream *pIStream, BOOL *pfMatches);
281 }
282 
283 mixin(uuid!(IWICBitmapCodecInfo , "E87A44C4-B76E-4c47-8B09-298EB12A2714"));
284 public interface IWICBitmapCodecInfo : IWICComponentInfo
285 {
286 extern(Windows):
287 	HRESULT DoesSupportAnimation(BOOL *pfSupportAnimation);
288 	HRESULT DoesSupportChromakey(BOOL *pfSupportChromakey);
289 	HRESULT DoesSupportLossless(BOOL *pfSupportLossless);
290 	HRESULT DoesSupportMultiframe(BOOL *pfSupportMultiframe);
291 	HRESULT GetColorManagementVersion(uint cchColorManagementVersion, wchar *wzColorManagementVersion, uint *pcchActual);
292 	HRESULT GetContainerFormat(GUID *pguidContainerFormat);
293 	HRESULT GetDeviceManufacturer(uint cchDeviceManufacturer, wchar *wzDeviceManufacturer, uint *pcchActual);
294 	HRESULT GetMetadataQueryReader(IWICMetadataQueryReader *ppIMetadataQueryReader);
295 	HRESULT GetDeviceModels(uint cchDeviceModels, wchar *wzDeviceModels, uint *pcchActual);
296 	HRESULT GetFileExtensions(uint cchFileExtensions, wchar *wzFileExtensions, uint *pcchActual);
297 	HRESULT GetMimeTypes(uint cchMimeTypes, wchar *wzMimeTypes, uint *pcchActual);
298 	HRESULT GetPixelFormats(uint cFormats, GUID *pguidPixelFormats, uint *pcActual);
299 	HRESULT MatchesMimeType(LPCWSTR wzMimeType, BOOL *pfMatches);
300 }
301 
302 mixin(uuid!(IWICBitmapFrameDecode, "3B16811B-6A43-4ec9-A813-3D930C13B940"));
303 public interface IWICBitmapFrameDecode : IWICBitmapSource
304 {
305 extern(Windows):
306 	HRESULT GetColorContexts(uint cCount, IWICColorContext *ppIColorContexts, uint *pcActualCount);
307 	HRESULT GetMetadataQueryReader(IWICMetadataQueryReader *ppIMetadataQueryReader);
308 	HRESULT GetThumbnail(IWICBitmapSource *ppIThumbnail);
309 }
310 
311 mixin(uuid!(IWICMetadataQueryReader, "30989668-E1C9-4597-B395-458EEDB808DF"));
312 public interface IWICMetadataQueryReader : IUnknown
313 {
314 extern(Windows):
315 	HRESULT GetContainerFormat(GUID *pguidContainerFormat);
316 	HRESULT GetEnumerator(IEnumString *ppIEnumString);
317 	HRESULT GetLocation(uint cchMaxLength, wchar *wzNamespace, uint *pcchActualLength);
318 	//PROPVARIANT Requires a complex binding, it can be done later
319 	//HRESULT GetMetadataByName(LPCWSTR wzName, PROPVARIANT *pvarValue);
320 }
321 
322 mixin(uuid!(IWICMetadataQueryWriter, "A721791A-0DEF-4d06-BD91-2118BF1DB10B"));
323 public interface IWICMetadataQueryWriter : IWICMetadataQueryReader
324 {
325 extern(Windows):
326 	HRESULT RemoveMetadataByName(LPCWSTR wzName);
327 	//PROPVARIANT Requires a complex binding, it can be done later
328 	//HRESULT SetMetadataByName(LPCWSTR wzName, const PROPVARIANT *pvarValue);
329 }
330 
331 mixin(uuid!(IWICBitmapEncoder, "00000103-a8f2-4877-ba0a-fd2b6645fb94"));
332 public interface IWICBitmapEncoder : IUnknown
333 {
334 extern(Windows):
335 	HRESULT Commit();
336 	//IPropertyBag2 Requires a complex binding, it can be done later
337 	//HRESULT CreateNewFrame(IWICBitmapFrameEncode *ppIFrameEncode, IPropertyBag2 **ppIEncoderOptions);
338 	HRESULT GetContainerFormat(GUID *pguidContainerFormat);
339 	HRESULT GetEncoderInfo(IWICBitmapEncoderInfo *ppIEncoderInfo);
340 	HRESULT GetMetadataQueryWriter(IWICMetadataQueryWriter *ppIMetadataQueryWriter);
341 	HRESULT Initialize(IStream *pIStream, WICBitmapEncoderCacheOption cacheOption);
342 	HRESULT SetColorContexts(uint cCount, IWICColorContext *ppIColorContext);
343 	HRESULT SetPalette(IWICPalette pIPalette);
344 	HRESULT SetPreview(IWICBitmapSource pIPreview);
345 	HRESULT SetThumbnail(IWICBitmapSource pIThumbnail);
346 }
347 
348 mixin(uuid!(IWICBitmapEncoderInfo, "94C9B4EE-A09F-4f92-8A1E-4A9BCE7E76FB"));
349 public interface IWICBitmapEncoderInfo : IWICBitmapCodecInfo
350 {
351 extern(Windows):
352 	HRESULT CreateInstance(IWICBitmapEncoder *ppIBitmapEncoder);
353 }
354 
355 mixin(uuid!(IWICBitmapFrameEncode, "00000105-a8f2-4877-ba0a-fd2b6645fb94"));
356 public interface IWICBitmapFrameEncode : IUnknown
357 {
358 extern(Windows):
359 	HRESULT Commit();
360 	HRESULT GetMetadataQueryWriter(IWICMetadataQueryWriter *ppIMetadataQueryWriter);
361 	HRESULT Initialize(IStream *pIStream, WICBitmapEncoderCacheOption cacheOption);
362 	HRESULT SetColorContexts(uint cCount, IWICColorContext *ppIColorContext);
363 	HRESULT SetPalette(IWICPalette pIPalette);
364 	HRESULT SetPixelFormat(GUID *pPixelFormat);
365 	HRESULT SetResolution(double dpiX, double dpiY);
366 	HRESULT SetSize(uint uiWidth, uint uiHeight);
367 	HRESULT SetThumbnail(IWICBitmapSource pIThumbnail);
368 	HRESULT WritePixels(uint lineCount, uint cbStride, uint cbBufferSize, ubyte *pbPixels);
369 	HRESULT WriteSource(IWICBitmapSource pIBitmapSource, WICRect *prc);
370 }
371 
372 mixin(uuid!(IWICFormatConverter, "00000301-a8f2-4877-ba0a-fd2b6645fb94"));
373 public interface IWICFormatConverter : IWICBitmapSource
374 {
375 extern(Windows):
376 	HRESULT CanConvert(GUID srcPixelFormat, GUID dstPixelFormat, BOOL *pfCanConvert);
377 	HRESULT Initialize(IWICBitmapSource pISource, GUID* dstFormat, WICBitmapDitherType dither, IWICPalette pIPalette, double alphaThresholdPercent, WICBitmapPaletteType paletteTranslate);
378 }
379 
380 mixin(uuid!(IWICStream, "135FF860-22B7-4ddf-B0F6-218F4F299A43"));
381 public interface IWICStream : IStream
382 {
383 extern(Windows):
384 	HRESULT InitializeFromFilename(LPCWSTR wzFileName, DWORD dwDesiredAccess);
385 	HRESULT InitializeFromIStream(IStream *pIStream);
386 	HRESULT InitializeFromIStreamRegion(IStream *pIStream, ULARGE_INTEGER ulOffset, ULARGE_INTEGER ulMaxSize);
387 	HRESULT InitializeFromMemory(ubyte *pbBuffer, DWORD cbBufferSize);
388 }
389 
390 mixin(uuid!(IWICFastMetadataEncoder, "B84E2C09-78C9-4AC4-8BD3-524AE1663A2F"));
391 public interface IWICFastMetadataEncoder : IUnknown
392 {
393 extern(Windows):
394 	HRESULT Commit();
395 	HRESULT GetMetadataQueryWriter(IWICMetadataQueryWriter *ppIMetadataQueryWriter);
396 }