root/trunk/freeimage/freeimage.d

Revision 234, 37.0 kB (checked in by jascha, 10 months ago)

- header file port and
- rudimentary wrapper

Line 
1 // ==========================================================
2 // FreeImage 3
3 //
4 // D header conversion by
5 // - Jascha Wetzel
6 //
7 // Design and implementation by
8 // - Floris van den Berg
9 // - Hervé Drolon
10 //
11 // Contributors:
12 // - Adam Gates
13 // - Alex Kwak
14 // - Alexander Dymerets
15 // - Detlev Vendt
16 // - Jan L. Nauta
17 // - Jani Kajala
18 // - Juergen Riecker
19 // - Karl-Heinz Bussian
20 // - Laurent Rocher
21 // - Luca Piergentili
22 // - Machiel ten Brinke
23 // - Markus Loibl
24 // - Martin Weber
25 // - Matthias Wandel
26 // - Michal Novotny
27 // - Petr Pytelka
28 // - Riley McNiff
29 // - Ryan Rubley
30 // - Volker GÀrtner
31 //
32 // This file is part of FreeImage 3
33 //
34 // COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
35 // OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
36 // THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
37 // OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
38 // CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
39 // THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
40 // SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
41 // PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
42 // THIS DISCLAIMER.
43 //
44 // Use at your own risk!
45 // ==========================================================
46
47 module freeimage;
48
49 pragma(lib, "freeimage.lib");
50
51 // Version information ------------------------------------------------------
52
53 const uint  FREEIMAGE_MAJOR_VERSION = 3,
54             FREEIMAGE_MINOR_VERSION = 9,
55             FREEIMAGE_RELEASE_SERIAL = 3;
56
57 // Bitmap types -------------------------------------------------------------
58
59 struct FIBITMAP { void *data; };
60 struct FIMULTIBITMAP { void *data; };
61
62 // Types used in the library (directly copied from Windows) -----------------
63
64 const uint FALSE = 0,
65            TRUE = 1;
66 const void* NULL = null;
67
68 const uint  SEEK_SET = 0,
69             SEEK_CUR = 1,
70             SEEK_END = 2;
71
72 alias int BOOL;
73 alias ubyte BYTE;
74 alias ushort WORD;
75 alias uint DWORD;
76 alias int LONG;
77
78 align(1) struct RGBQUAD
79 {
80     version(BigEndian) {
81         BYTE rgbRed;
82         BYTE rgbGreen;
83         BYTE rgbBlue;
84     } else {
85         BYTE rgbBlue;
86         BYTE rgbGreen;
87         BYTE rgbRed;
88     } // BigEndian
89     BYTE rgbReserved;
90 }
91
92 align(1) struct RGBTRIPLE
93 {
94     version(BigEndian) {
95         BYTE rgbtRed;
96         BYTE rgbtGreen;
97         BYTE rgbtBlue;
98     } else {
99         BYTE rgbtBlue;
100         BYTE rgbtGreen;
101         BYTE rgbtRed;
102     } // BigEndian
103 }
104
105 struct BITMAPINFOHEADER{
106   DWORD biSize;
107   LONG  biWidth;
108   LONG  biHeight;
109   WORD  biPlanes;
110   WORD  biBitCount;
111   DWORD biCompression;
112   DWORD biSizeImage;
113   LONG  biXPelsPerMeter;
114   LONG  biYPelsPerMeter;
115   DWORD biClrUsed;
116   DWORD biClrImportant;
117 }
118 alias BITMAPINFOHEADER* PBITMAPINFOHEADER;
119
120 struct BITMAPINFO {
121   BITMAPINFOHEADER bmiHeader;
122   RGBQUAD          bmiColors[1];
123 }
124 alias BITMAPINFO* PBITMAPINFO;
125
126 // Types used in the library (specific to FreeImage) ------------------------
127
128 alias uint unsigned;
129
130 /** 48-bit RGB
131 */
132 align(1) struct FIRGB16 {
133     WORD red;
134     WORD green;
135     WORD blue;
136 }
137
138 /** 64-bit RGBA
139 */
140 align(1) struct FIRGBA16 {
141     WORD red;
142     WORD green;
143     WORD blue;
144     WORD alpha;
145 }
146
147 /** 96-bit RGB Float
148 */
149 align(1) struct FIRGBF {
150     float red;
151     float green;
152     float blue;
153 }
154
155 /** 128-bit RGBA Float
156 */
157 align(1) struct FIRGBAF {
158     float red;
159     float green;
160     float blue;
161     float alpha;
162 }
163
164 /** Data structure for COMPLEX type (complex number)
165 */
166 align(1) struct FICOMPLEX {
167     /// real part
168     double r;
169     /// imaginary part
170     double i;
171 }
172
173 // Indexes for byte arrays, masks and shifts for treating pixels as words ---
174 // These coincide with the order of RGBQUAD and RGBTRIPLE -------------------
175
176 version(BigEndian) {
177 // Big Endian (PPC / Linux, MaxOSX) : RGB(A) order
178 const uint  FI_RGBA_RED         = 0,
179             FI_RGBA_GREEN       = 1,
180             FI_RGBA_BLUE        = 2,
181             FI_RGBA_ALPHA       = 3,
182             FI_RGBA_RED_MASK    = 0xFF000000,
183             FI_RGBA_GREEN_MASK  = 0x00FF0000,
184             FI_RGBA_BLUE_MASK   = 0x0000FF00,
185             FI_RGBA_ALPHA_MASK  = 0x000000FF,
186             FI_RGBA_RED_SHIFT   = 24,
187             FI_RGBA_GREEN_SHIFT = 16,
188             FI_RGBA_BLUE_SHIFT  = 8,
189             FI_RGBA_ALPHA_SHIFT = 0;
190 } else {
191 // Little Endian (x86 / MS Windows, Linux) : BGR(A) order
192 const uint  FI_RGBA_RED             = 2,
193             FI_RGBA_GREEN           = 1,
194             FI_RGBA_BLUE            = 0,
195             FI_RGBA_ALPHA           = 3,
196             FI_RGBA_RED_MASK        = 0x00FF0000,
197             FI_RGBA_GREEN_MASK      = 0x0000FF00,
198             FI_RGBA_BLUE_MASK       = 0x000000FF,
199             FI_RGBA_ALPHA_MASK      = 0xFF000000,
200             FI_RGBA_RED_SHIFT       = 16,
201             FI_RGBA_GREEN_SHIFT     = 8,
202             FI_RGBA_BLUE_SHIFT      = 0,
203             FI_RGBA_ALPHA_SHIFT     = 24;
204 } // BigEndian
205
206 const uint FI_RGBA_RGB_MASK = (FI_RGBA_RED_MASK|FI_RGBA_GREEN_MASK|FI_RGBA_BLUE_MASK);
207
208 // The 16bit macros only include masks and shifts, since each color element is not byte aligned
209
210 const ushort    FI16_555_RED_MASK       = 0x7C00,
211                 FI16_555_GREEN_MASK     = 0x03E0,
212                 FI16_555_BLUE_MASK      = 0x001F,
213                 FI16_555_RED_SHIFT      = 10,
214                 FI16_555_GREEN_SHIFT    = 5,
215                 FI16_555_BLUE_SHIFT     = 0,
216                 FI16_565_RED_MASK       = 0xF800,
217                 FI16_565_GREEN_MASK     = 0x07E0,
218                 FI16_565_BLUE_MASK      = 0x001F,
219                 FI16_565_RED_SHIFT      = 11,
220                 FI16_565_GREEN_SHIFT    = 5,
221                 FI16_565_BLUE_SHIFT     = 0;
222
223 // ICC profile support ------------------------------------------------------
224
225 const uint  FIICC_DEFAULT       = 0x00,
226             FIICC_COLOR_IS_CMYK = 0x01;
227
228 struct FIICCPROFILE {
229     WORD    flags;  // info flag
230     DWORD   size;   // profile's size measured in bytes
231     void   *data;   // points to a block of contiguous memory containing the profile
232 };
233
234 // Important enums ----------------------------------------------------------
235
236 /** I/O image format identifiers.
237 */
238 enum FREE_IMAGE_FORMAT
239 {
240     FIF_UNKNOWN = -1,
241     FIF_BMP     = 0,
242     FIF_ICO     = 1,
243     FIF_JPEG    = 2,
244     FIF_JNG     = 3,
245     FIF_KOALA   = 4,
246     FIF_LBM     = 5,
247     FIF_IFF = FIF_LBM,
248     FIF_MNG     = 6,
249     FIF_PBM     = 7,
250     FIF_PBMRAW  = 8,
251     FIF_PCD     = 9,
252     FIF_PCX     = 10,
253     FIF_PGM     = 11,
254     FIF_PGMRAW  = 12,
255     FIF_PNG     = 13,
256     FIF_PPM     = 14,
257     FIF_PPMRAW  = 15,
258     FIF_RAS     = 16,
259     FIF_TARGA   = 17,
260     FIF_TIFF    = 18,
261     FIF_WBMP    = 19,
262     FIF_PSD     = 20,
263     FIF_CUT     = 21,
264     FIF_XBM     = 22,
265     FIF_XPM     = 23,
266     FIF_DDS     = 24,
267     FIF_GIF     = 25,
268     FIF_HDR     = 26,
269     FIF_FAXG3   = 27,
270     FIF_SGI     = 28
271 };
272
273 /** Image type used in FreeImage.
274 */
275 enum FREE_IMAGE_TYPE {
276     FIT_UNKNOWN = 0,    // unknown type
277     FIT_BITMAP  = 1,    // standard image           : 1-, 4-, 8-, 16-, 24-, 32-bit
278     FIT_UINT16  = 2,    // array of unsigned short  : unsigned 16-bit
279     FIT_INT16   = 3,    // array of short           : signed 16-bit
280     FIT_UINT32  = 4,    // array of unsigned long   : unsigned 32-bit
281     FIT_INT32   = 5,    // array of long            : signed 32-bit
282     FIT_FLOAT   = 6,    // array of float           : 32-bit IEEE floating point
283     FIT_DOUBLE  = 7,    // array of double          : 64-bit IEEE floating point
284     FIT_COMPLEX = 8,    // array of FICOMPLEX       : 2 x 64-bit IEEE floating point
285     FIT_RGB16   = 9,    // 48-bit RGB image         : 3 x 16-bit
286     FIT_RGBA16  = 10,   // 64-bit RGBA image        : 4 x 16-bit
287     FIT_RGBF    = 11,   // 96-bit RGB float image   : 3 x 32-bit IEEE floating point
288     FIT_RGBAF   = 12    // 128-bit RGBA float image : 4 x 32-bit IEEE floating point
289 };
290
291 /** Image color type used in FreeImage.
292 */
293 enum FREE_IMAGE_COLOR_TYPE {
294     FIC_MINISWHITE = 0,     // min value is white
295     FIC_MINISBLACK = 1,     // min value is black
296     FIC_RGB        = 2,     // RGB color model
297     FIC_PALETTE    = 3,     // color map indexed
298     FIC_RGBALPHA   = 4,     // RGB color model with alpha channel
299     FIC_CMYK       = 5      // CMYK color model
300 };
301
302 /** Color quantization algorithms.
303 Constants used in FreeImage_ColorQuantize.
304 */
305 enum FREE_IMAGE_QUANTIZE {
306     FIQ_WUQUANT = 0,        // Xiaolin Wu color quantization algorithm
307     FIQ_NNQUANT = 1         // NeuQuant neural-net quantization algorithm by Anthony Dekker
308 };
309
310 /** Dithering algorithms.
311 Constants used in FreeImage_Dither.
312 */
313 enum FREE_IMAGE_DITHER {
314     FID_FS          = 0,    // Floyd & Steinberg error diffusion
315     FID_BAYER4x4    = 1,    // Bayer ordered dispersed dot dithering (order 2 dithering matrix)
316     FID_BAYER8x8    = 2,    // Bayer ordered dispersed dot dithering (order 3 dithering matrix)
317     FID_CLUSTER6x6  = 3,    // Ordered clustered dot dithering (order 3 - 6x6 matrix)
318     FID_CLUSTER8x8  = 4,    // Ordered clustered dot dithering (order 4 - 8x8 matrix)
319     FID_CLUSTER16x16= 5,    // Ordered clustered dot dithering (order 8 - 16x16 matrix)
320     FID_BAYER16x16  = 6     // Bayer ordered dispersed dot dithering (order 4 dithering matrix)
321 };
322
323 /** Lossless JPEG transformations
324 Constants used in FreeImage_JPEGTransform
325 */
326 enum FREE_IMAGE_JPEG_OPERATION {
327     FIJPEG_OP_NONE          = 0,    // no transformation
328     FIJPEG_OP_FLIP_H        = 1,    // horizontal flip
329     FIJPEG_OP_FLIP_V        = 2,    // vertical flip
330     FIJPEG_OP_TRANSPOSE     = 3,    // transpose across UL-to-LR axis
331     FIJPEG_OP_TRANSVERSE    = 4,    // transpose across UR-to-LL axis
332     FIJPEG_OP_ROTATE_90     = 5,    // 90-degree clockwise rotation
333     FIJPEG_OP_ROTATE_180    = 6,    // 180-degree rotation
334     FIJPEG_OP_ROTATE_270    = 7     // 270-degree clockwise (or 90 ccw)
335 };
336
337 /** Tone mapping operators.
338 Constants used in FreeImage_ToneMapping.
339 */
340 enum FREE_IMAGE_TMO {
341     FITMO_DRAGO03    = 0,   // Adaptive logarithmic mapping (F. Drago, 2003)
342     FITMO_REINHARD05 = 1,   // Dynamic range reduction inspired by photoreceptor physiology (E. Reinhard, 2005)
343 };
344
345 /** Upsampling / downsampling filters.
346 Constants used in FreeImage_Rescale.
347 */
348 enum FREE_IMAGE_FILTER {
349     FILTER_BOX        = 0,  // Box, pulse, Fourier window, 1st order (constant) b-spline
350     FILTER_BICUBIC    = 1,  // Mitchell & Netravali's two-param cubic filter
351     FILTER_BILINEAR   = 2,  // Bilinear filter
352     FILTER_BSPLINE    = 3,  // 4th order (cubic) b-spline
353     FILTER_CATMULLROM = 4,  // Catmull-Rom spline, Overhauser spline
354     FILTER_LANCZOS3   = 5   // Lanczos3 filter
355 };
356
357 /** Color channels.
358 Constants used in color manipulation routines.
359 */
360 enum FREE_IMAGE_COLOR_CHANNEL {
361     FICC_RGB    = 0,    // Use red, green and blue channels
362     FICC_RED    = 1,    // Use red channel
363     FICC_GREEN  = 2,    // Use green channel
364     FICC_BLUE   = 3,    // Use blue channel
365     FICC_ALPHA  = 4,    // Use alpha channel
366     FICC_BLACK  = 5,    // Use black channel
367     FICC_REAL   = 6,    // Complex images: use real part
368     FICC_IMAG   = 7,    // Complex images: use imaginary part
369     FICC_MAG    = 8,    // Complex images: use magnitude
370     FICC_PHASE  = 9     // Complex images: use phase
371 };
372
373 // Metadata support ---------------------------------------------------------
374
375 /**
376   Tag data type information (based on TIFF specifications)
377
378   Note: RATIONALs are the ratio of two 32-bit integer values.
379 */
380 enum FREE_IMAGE_MDTYPE {
381     FIDT_NOTYPE     = 0,    // placeholder
382     FIDT_BYTE       = 1,    // 8-bit unsigned integer
383     FIDT_ASCII      = 2,    // 8-bit bytes w/ last byte null
384     FIDT_SHORT      = 3,    // 16-bit unsigned integer
385     FIDT_LONG       = 4,    // 32-bit unsigned integer
386     FIDT_RATIONAL   = 5,    // 64-bit unsigned fraction
387     FIDT_SBYTE      = 6,    // 8-bit signed integer
388     FIDT_UNDEFINED  = 7,    // 8-bit untyped data
389     FIDT_SSHORT     = 8,    // 16-bit signed integer
390     FIDT_SLONG      = 9,    // 32-bit signed integer
391     FIDT_SRATIONAL  = 10,   // 64-bit signed fraction
392     FIDT_FLOAT      = 11,   // 32-bit IEEE floating point
393     FIDT_DOUBLE     = 12,   // 64-bit IEEE floating point
394     FIDT_IFD        = 13,   // 32-bit unsigned integer (offset)
395     FIDT_PALETTE    = 14    // 32-bit RGBQUAD
396 };
397
398 /**
399   Metadata models supported by FreeImage
400 */
401 enum FREE_IMAGE_MDMODEL {
402     FIMD_NODATA         = -1,
403     FIMD_COMMENTS       = 0,    // single comment or keywords
404     FIMD_EXIF_MAIN      = 1,    // Exif-TIFF metadata
405     FIMD_EXIF_EXIF      = 2,    // Exif-specific metadata
406     FIMD_EXIF_GPS       = 3,    // Exif GPS metadata
407     FIMD_EXIF_MAKERNOTE = 4,    // Exif maker note metadata
408     FIMD_EXIF_INTEROP   = 5,    // Exif interoperability metadata
409     FIMD_IPTC           = 6,    // IPTC/NAA metadata
410     FIMD_XMP            = 7,    // Abobe XMP metadata
411     FIMD_GEOTIFF        = 8,    // GeoTIFF metadata
412     FIMD_ANIMATION      = 9,    // Animation metadata
413     FIMD_CUSTOM         = 10    // Used to attach other metadata types to a dib
414 };
415
416 /**
417   Handle to a metadata model
418 */
419 struct FIMETADATA { void *data; };
420
421 /**
422   Handle to a FreeImage tag
423 */
424 struct FITAG { void *data; };
425
426 // File IO routines ---------------------------------------------------------
427
428 version(FREEIMAGE_IO) {
429
430 alias void* fi_handle;
431 alias unsigned function (void *buffer, unsigned size, unsigned count, fi_handle handle)     FI_ReadProc;
432 alias unsigned function (void *buffer, unsigned size, unsigned count, fi_handle handle)     FI_WriteProc;
433 alias int function (fi_handle handle, long offset, int origin)                              FI_SeekProc;
434 alias long function (fi_handle handle)                                                      FI_TellProc;
435
436 align(1) struct FreeImageIO {
437     FI_ReadProc  read_proc;     // pointer to the function used to read data
438     FI_WriteProc write_proc;    // pointer to the function used to write data
439     FI_SeekProc  seek_proc;     // pointer to the function used to seek
440     FI_TellProc  tell_proc;     // pointer to the function used to aquire the current position
441 };
442
443 /**
444 Handle to a memory I/O stream
445 */
446 struct FIMEMORY { void *data; };
447
448 } // FREEIMAGE_IO
449
450 // Plugin routines ----------------------------------------------------------
451
452 version(PLUGINS) {
453
454 alias const char *function ()                                           FI_FormatProc;
455 alias const char *function ()                                           FI_DescriptionProc;
456 alias const char *function ()                                           FI_ExtensionListProc;
457 alias const char *function ()                                           FI_RegExprProc;
458 alias void *function(FreeImageIO *io, fi_handle handle, BOOL read)      FI_OpenProc;
459 alias void function(FreeImageIO *io, fi_handle handle, void *data)      FI_CloseProc;
460 alias int function(FreeImageIO *io, fi_handle handle, void *data)       FI_PageCountProc;
461 alias int function(FreeImageIO *io, fi_handle handle, void *data)       FI_PageCapabilityProc;
462 alias FIBITMAP *function(FreeImageIO *io, fi_handle handle, int page, int flags, void *data)            FI_LoadProc;
463 alias BOOL function(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data)  FI_SaveProc;
464 alias BOOL function(FreeImageIO *io, fi_handle handle)                  FI_ValidateProc;
465 alias const char *function ()                                           FI_MimeProc;
466 alias BOOL function(int bpp)                                            FI_SupportsExportBPPProc;
467 alias BOOL function(FREE_IMAGE_TYPE type)                               FI_SupportsExportTypeProc;
468 alias BOOL function()                                                   FI_SupportsICCProfilesProc;
469
470 struct Plugin {
471     FI_FormatProc format_proc;
472     FI_DescriptionProc description_proc;
473     FI_ExtensionListProc extension_proc;
474     FI_RegExprProc regexpr_proc;
475     FI_OpenProc open_proc;
476     FI_CloseProc close_proc;
477     FI_PageCountProc pagecount_proc;
478     FI_PageCapabilityProc pagecapability_proc;
479     FI_LoadProc load_proc;
480     FI_SaveProc save_proc;
481     FI_ValidateProc validate_proc;
482     FI_MimeProc mime_proc;
483     FI_SupportsExportBPPProc supports_export_bpp_proc;
484     FI_SupportsExportTypeProc supports_export_type_proc;
485     FI_SupportsICCProfilesProc supports_icc_profiles_proc;
486 };
487
488 alias void function(Plugin *plugin, int format_id) FI_InitProc;
489
490 } // PLUGINS
491
492
493 // Load / Save flag constants -----------------------------------------------
494
495 const uint  BMP_DEFAULT         = 0,
496             BMP_SAVE_RLE        = 1,
497             CUT_DEFAULT         = 0,
498             DDS_DEFAULT         = 0,
499             FAXG3_DEFAULT       = 0,
500             GIF_DEFAULT         = 0,
501             GIF_LOAD256         = 1,    // Load the image as a 256 color image with ununsed palette entries, if it's 16 or 2 color
502             GIF_PLAYBACK        = 2,    // 'Play' the GIF to generate each frame (as 32bpp) instead of returning raw frame data when loading
503             HDR_DEFAULT         = 0,
504             ICO_DEFAULT         = 0,
505             ICO_MAKEALPHA       = 1,    // convert to 32bpp and create an alpha channel from the AND-mask when loading
506             IFF_DEFAULT         = 0,
507             JPEG_DEFAULT        = 0,        // loading (see JPEG_FAST); saving (see JPEG_QUALITYGOOD)
508             JPEG_FAST           = 0x0001,   // load the file as fast as possible, sacrificing some quality
509             JPEG_ACCURATE       = 0x0002,   // load the file with the best quality, sacrificing some speed
510             JPEG_CMYK           = 0x0004,   // load separated CMYK "as is" (use | to combine with other load flags)
511             JPEG_QUALITYSUPERB  = 0x80, // save with superb quality (100:1)
512             JPEG_QUALITYGOOD    = 0x0100,   // save with good quality (75:1)
513             JPEG_QUALITYNORMAL  = 0x0200,   // save with normal quality (50:1)
514             JPEG_QUALITYAVERAGE = 0x0400,   // save with average quality (25:1)
515             JPEG_QUALITYBAD     = 0x0800,   // save with bad quality (10:1)
516             JPEG_PROGRESSIVE    = 0x2000,   // save as a progressive-JPEG (use | to combine with other save flags)
517             KOALA_DEFAULT       = 0,
518             LBM_DEFAULT         = 0,
519             MNG_DEFAULT         = 0,
520             PCD_DEFAULT         = 0,
521             PCD_BASE            = 1,    // load the bitmap sized 768 x 512
522             PCD_BASEDIV4        = 2,    // load the bitmap sized 384 x 256
523             PCD_BASEDIV16       = 3,    // load the bitmap sized 192 x 128
524             PCX_DEFAULT         = 0,
525             PNG_DEFAULT         = 0,
526             PNG_IGNOREGAMMA     = 1,    // avoid gamma correction
527             PNM_DEFAULT         = 0,
528             PNM_SAVE_RAW        = 0,       // If set the writer saves in RAW format (i.e. P4, P5 or P6)
529             PNM_SAVE_ASCII      = 1,       // If set the writer saves in ASCII format (i.e. P1, P2 or P3)
530             PSD_DEFAULT         = 0,
531             RAS_DEFAULT         = 0,
532             SGI_DEFAULT         = 0,
533             TARGA_DEFAULT       = 0,
534             TARGA_LOAD_RGB888   = 1,       // If set the loader converts RGB555 and ARGB8888 -> RGB888.
535             TIFF_DEFAULT        = 0,
536             TIFF_CMYK           = 0x0001,   // reads/stores tags for separated CMYK (use | to combine with compression flags)
537             TIFF_PACKBITS       = 0x0100,  // save using PACKBITS compression
538             TIFF_DEFLATE        = 0x0200,  // save using DEFLATE compression (a.k.a. ZLIB compression)
539             TIFF_ADOBE_DEFLATE  = 0x0400,  // save using ADOBE DEFLATE compression
540             TIFF_NONE           = 0x0800,  // save without any compression
541             TIFF_CCITTFAX3      = 0x1000,  // save using CCITT Group 3 fax encoding
542             TIFF_CCITTFAX4      = 0x2000,  // save using CCITT Group 4 fax encoding
543             TIFF_LZW            = 0x4000,   // save using LZW compression
544             TIFF_JPEG           = 0x8000,   // save using JPEG compression
545             WBMP_DEFAULT        = 0,
546             XBM_DEFAULT         = 0,
547             XPM_DEFAULT         = 0;
548
549
550 //version(Windows) {
551     extern(Windows):
552 //}
553 //else {
554 //    extern(C):
555 //}
556
557 // Init / Error routines ----------------------------------------------------
558
559 void FreeImage_Initialise(BOOL load_local_plugins_only = FALSE);
560 void FreeImage_DeInitialise();
561
562 // Version routines ---------------------------------------------------------
563
564 char *FreeImage_GetVersion();
565 char *FreeImage_GetCopyrightMessage();
566
567 // Message output functions -------------------------------------------------
568
569 void FreeImage_OutputMessageProc(int fif, char *fmt, ...);
570
571 alias void function(FREE_IMAGE_FORMAT fif, char *msg) FreeImage_OutputMessageFunction;
572 void FreeImage_SetOutputMessage(FreeImage_OutputMessageFunction omf);
573
574 // Allocate / Clone / Unload routines ---------------------------------------
575
576 FIBITMAP *FreeImage_Allocate(int width, int height, int bpp, unsigned red_mask = 0, unsigned green_mask = 0, unsigned blue_mask = 0);
577 FIBITMAP *FreeImage_AllocateT(FREE_IMAGE_TYPE type, int width, int height, int bpp = 8, unsigned red_mask = 0, unsigned green_mask = 0, unsigned blue_mask = 0);
578 FIBITMAP * FreeImage_Clone(FIBITMAP *dib);
579 void FreeImage_Unload(FIBITMAP *dib);
580
581 // Load / Save routines -----------------------------------------------------
582
583 FIBITMAP *FreeImage_Load(FREE_IMAGE_FORMAT fif, char *filename, int flags = 0);
584 FIBITMAP *FreeImage_LoadU(FREE_IMAGE_FORMAT fif, wchar *filename, int flags = 0);
585 BOOL FreeImage_Save(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, char *filename, int flags = 0);
586 BOOL FreeImage_SaveU(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, wchar *filename, int flags = 0);
587
588 version(FREEIMAGE_IO) {
589
590 FIBITMAP *FreeImage_LoadFromHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flags = 0);
591 BOOL FreeImage_SaveToHandle(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags = 0);
592
593 }
594
595 // Memory I/O stream routines -----------------------------------------------
596
597 version(FREEIMAGE_IO) {
598
599 FIMEMORY *FreeImage_OpenMemory(BYTE *data = 0, DWORD size_in_bytes = 0);
600 void FreeImage_CloseMemory(FIMEMORY *stream);
601 FIBITMAP *FreeImage_LoadFromMemory(FREE_IMAGE_FORMAT fif, FIMEMORY *stream, int flags = 0);
602 BOOL FreeImage_SaveToMemory(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FIMEMORY *stream, int flags = 0);
603 long FreeImage_TellMemory(FIMEMORY *stream);
604 BOOL FreeImage_SeekMemory(FIMEMORY *stream, long offset, int origin);
605 BOOL FreeImage_AcquireMemory(FIMEMORY *stream, BYTE **data, DWORD *size_in_bytes);
606 unsigned FreeImage_ReadMemory(void *buffer, unsigned size, unsigned count, FIMEMORY *stream);
607 unsigned FreeImage_WriteMemory(void *buffer, unsigned size, unsigned count, FIMEMORY *stream);
608 FIMULTIBITMAP *FreeImage_LoadMultiBitmapFromMemory(FREE_IMAGE_FORMAT fif, FIMEMORY *stream, int flags = 0);
609
610 }
611
612 // Plugin Interface ---------------------------------------------------------
613
614 version(PLUGIN) {
615
616 FREE_IMAGE_FORMAT FreeImage_RegisterLocalPlugin(FI_InitProc proc_address, char *format = 0, char *description = 0, char *extension = 0, char *regexpr = 0);
617 FREE_IMAGE_FORMAT FreeImage_RegisterExternalPlugin(char *path, char *format = 0, char *description = 0, char *extension = 0, char *regexpr = 0);
618 int FreeImage_GetFIFCount();
619 int FreeI