FreeImage.h
1 // ==========================================================
2 // FreeImage 3
3 //
4 // Design and implementation by
5 // - Floris van den Berg (flvdberg@wxs.nl)
6 // - Hervé Drolon (drolon@infonie.fr)
7 //
8 // Contributors:
9 // - Adam Gates (radad@xoasis.com)
10 // - Alex Kwak
11 // - Alexander Dymerets (sashad@te.net.ua)
12 // - Detlev Vendt (detlev.vendt@brillit.de)
13 // - Jan L. Nauta (jln@magentammt.com)
14 // - Jani Kajala (janik@remedy.fi)
15 // - Juergen Riecker (j.riecker@gmx.de)
16 // - Karl-Heinz Bussian (khbussian@moss.de)
17 // - Laurent Rocher (rocherl@club-internet.fr)
18 // - Luca Piergentili (l.pierge@terra.es)
19 // - Machiel ten Brinke (brinkem@uni-one.nl)
20 // - Markus Loibl (markus.loibl@epost.de)
21 // - Martin Weber (martweb@gmx.net)
22 // - Matthias Wandel (mwandel@rim.net)
23 // - Michal Novotny (michal@etc.cz)
24 // - Petr Pytelka (pyta@lightcomp.com)
25 // - Riley McNiff (rmcniff@marexgroup.com)
26 // - Ryan Rubley (ryan@lostreality.org)
27 // - Volker Gärtner (volkerg@gmx.at)
28 //
29 // This file is part of FreeImage 3
30 //
31 // COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
32 // OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
33 // THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
34 // OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
35 // CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
36 // THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
37 // SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
38 // PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
39 // THIS DISCLAIMER.
40 //
41 // Use at your own risk!
42 // ==========================================================
43 
44 #ifndef FREEIMAGE_H
45 #define FREEIMAGE_H
46 
47 // Version information ------------------------------------------------------
48 
49 #define FREEIMAGE_MAJOR_VERSION 3
50 #define FREEIMAGE_MINOR_VERSION 10
51 #define FREEIMAGE_RELEASE_SERIAL 0
52 
53 // Compiler options ---------------------------------------------------------
54 
55 #include <wchar.h> // needed for UNICODE functions
56 
57 #if defined(FREEIMAGE_LIB)
58  #define DLL_API
59  #define DLL_CALLCONV
60 #else
61  #if defined(_WIN32) || defined(__WIN32__)
62  #define DLL_CALLCONV __stdcall
63  // The following ifdef block is the standard way of creating macros which make exporting
64  // from a DLL simpler. All files within this DLL are compiled with the FREEIMAGE_EXPORTS
65  // symbol defined on the command line. this symbol should not be defined on any project
66  // that uses this DLL. This way any other project whose source files include this file see
67  // DLL_API functions as being imported from a DLL, wheras this DLL sees symbols
68  // defined with this macro as being exported.
69  #ifdef FREEIMAGE_EXPORTS
70  #define DLL_API __declspec(dllexport)
71  #else
72  #define DLL_API __declspec(dllimport)
73  #endif // FREEIMAGE_EXPORTS
74  #else
75  // try the gcc visibility support (see http://gcc.gnu.org/wiki/Visibility)
76  #if defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
77  #ifndef GCC_HASCLASSVISIBILITY
78  #define GCC_HASCLASSVISIBILITY
79  #endif
80  #endif // __GNUC__
81  #define DLL_CALLCONV
82  #if defined(GCC_HASCLASSVISIBILITY)
83  #define DLL_API __attribute__ ((visibility("default")))
84  #else
85  #define DLL_API
86  #endif
87  #endif // WIN32 / !WIN32
88 #endif // FREEIMAGE_LIB
89 
90 // Some versions of gcc may have BYTE_ORDER or __BYTE_ORDER defined
91 // If your big endian system isn't being detected, add an OS specific check
92 #if (defined(BYTE_ORDER) && BYTE_ORDER==BIG_ENDIAN) || \
93  (defined(__BYTE_ORDER) && __BYTE_ORDER==__BIG_ENDIAN) || \
94  defined(__BIG_ENDIAN__)
95 #define FREEIMAGE_BIGENDIAN
96 #endif // BYTE_ORDER
97 
98 // This really only affects 24 and 32 bit formats, the rest are always RGB order.
99 #define FREEIMAGE_COLORORDER_BGR 0
100 #define FREEIMAGE_COLORORDER_RGB 1
101 #if defined(__APPLE__) || defined(FREEIMAGE_BIGENDIAN)
102 #define FREEIMAGE_COLORORDER FREEIMAGE_COLORORDER_RGB
103 #else
104 #define FREEIMAGE_COLORORDER FREEIMAGE_COLORORDER_BGR
105 #endif
106 
107 // Ensure 4-byte enums if we're using Borland C++ compilers
108 #if defined(__BORLANDC__)
109 #pragma option push -b
110 #endif
111 
112 // For C compatibility --------------------------------------------------------
113 
114 #ifdef __cplusplus
115 #define FI_DEFAULT(x) = x
116 #define FI_ENUM(x) enum x
117 #define FI_STRUCT(x) struct x
118 #else
119 #define FI_DEFAULT(x)
120 #define FI_ENUM(x) typedef int x; enum x
121 #define FI_STRUCT(x) typedef struct x x; struct x
122 #endif
123 
124 // Bitmap types -------------------------------------------------------------
125 
126 FI_STRUCT (FIBITMAP) { void *data; };
127 FI_STRUCT (FIMULTIBITMAP) { void *data; };
128 
129 // Types used in the library (directly copied from Windows) -----------------
130 
131 #ifndef _WINDOWS_
132 #define _WINDOWS_
133 
134 #ifndef FALSE
135 #define FALSE 0
136 #endif
137 #ifndef TRUE
138 #define TRUE 1
139 #endif
140 #ifndef NULL
141 #define NULL 0
142 #endif
143 
144 #ifndef SEEK_SET
145 #define SEEK_SET 0
146 #define SEEK_CUR 1
147 #define SEEK_END 2
148 #endif
149 
150 #ifndef _MSC_VER
151 // define portable types for 32-bit / 64-bit OS
152 #include <inttypes.h>
153 typedef int32_t BOOL;
154 typedef uint8_t BYTE;
155 typedef uint16_t WORD;
156 typedef uint32_t DWORD;
157 typedef int32_t LONG;
158 #else
159 // MS is not C99 ISO compliant
160 typedef long BOOL;
161 typedef unsigned char BYTE;
162 typedef unsigned short WORD;
163 typedef unsigned long DWORD;
164 typedef long LONG;
165 #endif // _MSC_VER
166 
167 #if (defined(_WIN32) || defined(__WIN32__))
168 #pragma pack(push, 1)
169 #else
170 #pragma pack(1)
171 #endif // WIN32
172 
173 typedef struct tagRGBQUAD {
174 #if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR
175  BYTE rgbBlue;
176  BYTE rgbGreen;
177  BYTE rgbRed;
178 #else
179  BYTE rgbRed;
180  BYTE rgbGreen;
181  BYTE rgbBlue;
182 #endif // FREEIMAGE_COLORORDER
183  BYTE rgbReserved;
184 } RGBQUAD;
185 
186 typedef struct tagRGBTRIPLE {
187 #if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR
188  BYTE rgbtBlue;
189  BYTE rgbtGreen;
190  BYTE rgbtRed;
191 #else
192  BYTE rgbtRed;
193  BYTE rgbtGreen;
194  BYTE rgbtBlue;
195 #endif // FREEIMAGE_COLORORDER
196 } RGBTRIPLE;
197 
198 #if (defined(_WIN32) || defined(__WIN32__))
199 #pragma pack(pop)
200 #else
201 #pragma pack()
202 #endif // WIN32
203 
204 typedef struct tagBITMAPINFOHEADER{
205  DWORD biSize;
206  LONG biWidth;
207  LONG biHeight;
208  WORD biPlanes;
209  WORD biBitCount;
210  DWORD biCompression;
211  DWORD biSizeImage;
212  LONG biXPelsPerMeter;
213  LONG biYPelsPerMeter;
214  DWORD biClrUsed;
215  DWORD biClrImportant;
217 
218 typedef struct tagBITMAPINFO {
219  BITMAPINFOHEADER bmiHeader;
220  RGBQUAD bmiColors[1];
222 
223 #endif // _WINDOWS_
224 
225 // Types used in the library (specific to FreeImage) ------------------------
226 
227 #if (defined(_WIN32) || defined(__WIN32__))
228 #pragma pack(push, 1)
229 #else
230 #pragma pack(1)
231 #endif // WIN32
232 
235 typedef struct tagFIRGB16 {
236  WORD red;
237  WORD green;
238  WORD blue;
239 } FIRGB16;
240 
243 typedef struct tagFIRGBA16 {
244  WORD red;
245  WORD green;
246  WORD blue;
247  WORD alpha;
248 } FIRGBA16;
249 
252 typedef struct tagFIRGBF {
253  float red;
254  float green;
255  float blue;
256 } FIRGBF;
257 
260 typedef struct tagFIRGBAF {
261  float red;
262  float green;
263  float blue;
264  float alpha;
265 } FIRGBAF;
266 
269 typedef struct tagFICOMPLEX {
271  double r;
273  double i;
274 } FICOMPLEX;
275 
276 #if (defined(_WIN32) || defined(__WIN32__))
277 #pragma pack(pop)
278 #else
279 #pragma pack()
280 #endif // WIN32
281 
282 // Indexes for byte arrays, masks and shifts for treating pixels as words ---
283 // These coincide with the order of RGBQUAD and RGBTRIPLE -------------------
284 
285 #ifndef FREEIMAGE_BIGENDIAN
286 #if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR
287 // Little Endian (x86 / MS Windows, Linux) : BGR(A) order
288 #define FI_RGBA_RED 2
289 #define FI_RGBA_GREEN 1
290 #define FI_RGBA_BLUE 0
291 #define FI_RGBA_ALPHA 3
292 #define FI_RGBA_RED_MASK 0x00FF0000
293 #define FI_RGBA_GREEN_MASK 0x0000FF00
294 #define FI_RGBA_BLUE_MASK 0x000000FF
295 #define FI_RGBA_ALPHA_MASK 0xFF000000
296 #define FI_RGBA_RED_SHIFT 16
297 #define FI_RGBA_GREEN_SHIFT 8
298 #define FI_RGBA_BLUE_SHIFT 0
299 #define FI_RGBA_ALPHA_SHIFT 24
300 #else
301 // Little Endian (x86 / MaxOSX) : RGB(A) order
302 #define FI_RGBA_RED 0
303 #define FI_RGBA_GREEN 1
304 #define FI_RGBA_BLUE 2
305 #define FI_RGBA_ALPHA 3
306 #define FI_RGBA_RED_MASK 0x000000FF
307 #define FI_RGBA_GREEN_MASK 0x0000FF00
308 #define FI_RGBA_BLUE_MASK 0x00FF0000
309 #define FI_RGBA_ALPHA_MASK 0xFF000000
310 #define FI_RGBA_RED_SHIFT 0
311 #define FI_RGBA_GREEN_SHIFT 8
312 #define FI_RGBA_BLUE_SHIFT 16
313 #define FI_RGBA_ALPHA_SHIFT 24
314 #endif // FREEIMAGE_COLORORDER
315 #else
316 #if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR
317 // Big Endian (PPC / none) : BGR(A) order
318 #define FI_RGBA_RED 2
319 #define FI_RGBA_GREEN 1
320 #define FI_RGBA_BLUE 0
321 #define FI_RGBA_ALPHA 3
322 #define FI_RGBA_RED_MASK 0x0000FF00
323 #define FI_RGBA_GREEN_MASK 0x00FF0000
324 #define FI_RGBA_BLUE_MASK 0xFF000000
325 #define FI_RGBA_ALPHA_MASK 0x000000FF
326 #define FI_RGBA_RED_SHIFT 8
327 #define FI_RGBA_GREEN_SHIFT 16
328 #define FI_RGBA_BLUE_SHIFT 24
329 #define FI_RGBA_ALPHA_SHIFT 0
330 #else
331 // Big Endian (PPC / Linux, MaxOSX) : RGB(A) order
332 #define FI_RGBA_RED 0
333 #define FI_RGBA_GREEN 1
334 #define FI_RGBA_BLUE 2
335 #define FI_RGBA_ALPHA 3
336 #define FI_RGBA_RED_MASK 0xFF000000
337 #define FI_RGBA_GREEN_MASK 0x00FF0000
338 #define FI_RGBA_BLUE_MASK 0x0000FF00
339 #define FI_RGBA_ALPHA_MASK 0x000000FF
340 #define FI_RGBA_RED_SHIFT 24
341 #define FI_RGBA_GREEN_SHIFT 16
342 #define FI_RGBA_BLUE_SHIFT 8
343 #define FI_RGBA_ALPHA_SHIFT 0
344 #endif // FREEIMAGE_COLORORDER
345 #endif // FREEIMAGE_BIGENDIAN
346 
347 #define FI_RGBA_RGB_MASK (FI_RGBA_RED_MASK|FI_RGBA_GREEN_MASK|FI_RGBA_BLUE_MASK)
348 
349 // The 16bit macros only include masks and shifts, since each color element is not byte aligned
350 
351 #define FI16_555_RED_MASK 0x7C00
352 #define FI16_555_GREEN_MASK 0x03E0
353 #define FI16_555_BLUE_MASK 0x001F
354 #define FI16_555_RED_SHIFT 10
355 #define FI16_555_GREEN_SHIFT 5
356 #define FI16_555_BLUE_SHIFT 0
357 #define FI16_565_RED_MASK 0xF800
358 #define FI16_565_GREEN_MASK 0x07E0
359 #define FI16_565_BLUE_MASK 0x001F
360 #define FI16_565_RED_SHIFT 11
361 #define FI16_565_GREEN_SHIFT 5
362 #define FI16_565_BLUE_SHIFT 0
363 
364 // ICC profile support ------------------------------------------------------
365 
366 #define FIICC_DEFAULT 0x00
367 #define FIICC_COLOR_IS_CMYK 0x01
368 
369 FI_STRUCT (FIICCPROFILE) {
370  WORD flags; // info flag
371  DWORD size; // profile's size measured in bytes
372  void *data; // points to a block of contiguous memory containing the profile
373 };
374 
375 // Important enums ----------------------------------------------------------
376 
379 FI_ENUM(FREE_IMAGE_FORMAT) {
380  FIF_UNKNOWN = -1,
381  FIF_BMP = 0,
382  FIF_ICO = 1,
383  FIF_JPEG = 2,
384  FIF_JNG = 3,
385  FIF_KOALA = 4,
386  FIF_LBM = 5,
387  FIF_IFF = FIF_LBM,
388  FIF_MNG = 6,
389  FIF_PBM = 7,
390  FIF_PBMRAW = 8,
391  FIF_PCD = 9,
392  FIF_PCX = 10,
393  FIF_PGM = 11,
394  FIF_PGMRAW = 12,
395  FIF_PNG = 13,
396  FIF_PPM = 14,
397  FIF_PPMRAW = 15,
398  FIF_RAS = 16,
399  FIF_TARGA = 17,
400  FIF_TIFF = 18,
401  FIF_WBMP = 19,
402  FIF_PSD = 20,
403  FIF_CUT = 21,
404  FIF_XBM = 22,
405  FIF_XPM = 23,
406  FIF_DDS = 24,
407  FIF_GIF = 25,
408  FIF_HDR = 26,
409 /* The G3 fax format plugin is deliberately disabled in the Fedora build of
410  FreeImage as it requires that FreeImage uses a private copy of libtiff
411  which is a no no because of security reasons */
412 #if 0
413  FIF_FAXG3 = 27,
414 #endif
415  FIF_SGI = 28,
416  FIF_EXR = 29,
417  FIF_J2K = 30,
418  FIF_JP2 = 31
419 };
420 
423 FI_ENUM(FREE_IMAGE_TYPE) {
424  FIT_UNKNOWN = 0, // unknown type
425  FIT_BITMAP = 1, // standard image : 1-, 4-, 8-, 16-, 24-, 32-bit
426  FIT_UINT16 = 2, // array of unsigned short : unsigned 16-bit
427  FIT_INT16 = 3, // array of short : signed 16-bit
428  FIT_UINT32 = 4, // array of unsigned long : unsigned 32-bit
429  FIT_INT32 = 5, // array of long : signed 32-bit
430  FIT_FLOAT = 6, // array of float : 32-bit IEEE floating point
431  FIT_DOUBLE = 7, // array of double : 64-bit IEEE floating point
432  FIT_COMPLEX = 8, // array of FICOMPLEX : 2 x 64-bit IEEE floating point
433  FIT_RGB16 = 9, // 48-bit RGB image : 3 x 16-bit
434  FIT_RGBA16 = 10, // 64-bit RGBA image : 4 x 16-bit
435  FIT_RGBF = 11, // 96-bit RGB float image : 3 x 32-bit IEEE floating point
436  FIT_RGBAF = 12 // 128-bit RGBA float image : 4 x 32-bit IEEE floating point
437 };
438 
441 FI_ENUM(FREE_IMAGE_COLOR_TYPE) {
442  FIC_MINISWHITE = 0, // min value is white
443  FIC_MINISBLACK = 1, // min value is black
444  FIC_RGB = 2, // RGB color model
445  FIC_PALETTE = 3, // color map indexed
446  FIC_RGBALPHA = 4, // RGB color model with alpha channel
447  FIC_CMYK = 5 // CMYK color model
448 };
449 
453 FI_ENUM(FREE_IMAGE_QUANTIZE) {
454  FIQ_WUQUANT = 0, // Xiaolin Wu color quantization algorithm
455  FIQ_NNQUANT = 1 // NeuQuant neural-net quantization algorithm by Anthony Dekker
456 };
457 
461 FI_ENUM(FREE_IMAGE_DITHER) {
462  FID_FS = 0, // Floyd & Steinberg error diffusion
463  FID_BAYER4x4 = 1, // Bayer ordered dispersed dot dithering (order 2 dithering matrix)
464  FID_BAYER8x8 = 2, // Bayer ordered dispersed dot dithering (order 3 dithering matrix)
465  FID_CLUSTER6x6 = 3, // Ordered clustered dot dithering (order 3 - 6x6 matrix)
466  FID_CLUSTER8x8 = 4, // Ordered clustered dot dithering (order 4 - 8x8 matrix)
467  FID_CLUSTER16x16= 5, // Ordered clustered dot dithering (order 8 - 16x16 matrix)
468  FID_BAYER16x16 = 6 // Bayer ordered dispersed dot dithering (order 4 dithering matrix)
469 };
470 
471 /* The FreeImage_JPEGTransform functions are deliberately disabled in the
472  Fedora build of FreeImage as they require that FreeImage uses a private copy
473  of libjpeg which is a no no because of security reasons */
474 #if 0
475 
479 FI_ENUM(FREE_IMAGE_JPEG_OPERATION) {
480  FIJPEG_OP_NONE = 0, // no transformation
481  FIJPEG_OP_FLIP_H = 1, // horizontal flip
482  FIJPEG_OP_FLIP_V = 2, // vertical flip
483  FIJPEG_OP_TRANSPOSE = 3, // transpose across UL-to-LR axis
484  FIJPEG_OP_TRANSVERSE = 4, // transpose across UR-to-LL axis
485  FIJPEG_OP_ROTATE_90 = 5, // 90-degree clockwise rotation
486  FIJPEG_OP_ROTATE_180 = 6, // 180-degree rotation
487  FIJPEG_OP_ROTATE_270 = 7 // 270-degree clockwise (or 90 ccw)
488 };
489 
490 #endif
491 
495 FI_ENUM(FREE_IMAGE_TMO) {
496  FITMO_DRAGO03 = 0, // Adaptive logarithmic mapping (F. Drago, 2003)
497  FITMO_REINHARD05 = 1, // Dynamic range reduction inspired by photoreceptor physiology (E. Reinhard, 2005)
498  FITMO_FATTAL02 = 2 // Gradient domain high dynamic range compression (R. Fattal, 2002)
499 };
500 
504 FI_ENUM(FREE_IMAGE_FILTER) {
505  FILTER_BOX = 0, // Box, pulse, Fourier window, 1st order (constant) b-spline
506  FILTER_BICUBIC = 1, // Mitchell & Netravali's two-param cubic filter
507  FILTER_BILINEAR = 2, // Bilinear filter
508  FILTER_BSPLINE = 3, // 4th order (cubic) b-spline
509  FILTER_CATMULLROM = 4, // Catmull-Rom spline, Overhauser spline
510  FILTER_LANCZOS3 = 5 // Lanczos3 filter
511 };
512 
516 FI_ENUM(FREE_IMAGE_COLOR_CHANNEL) {
517  FICC_RGB = 0, // Use red, green and blue channels
518  FICC_RED = 1, // Use red channel
519  FICC_GREEN = 2, // Use green channel
520  FICC_BLUE = 3, // Use blue channel
521  FICC_ALPHA = 4, // Use alpha channel
522  FICC_BLACK = 5, // Use black channel
523  FICC_REAL = 6, // Complex images: use real part
524  FICC_IMAG = 7, // Complex images: use imaginary part
525  FICC_MAG = 8, // Complex images: use magnitude
526  FICC_PHASE = 9 // Complex images: use phase
527 };
528 
529 // Metadata support ---------------------------------------------------------
530 
536 FI_ENUM(FREE_IMAGE_MDTYPE) {
537  FIDT_NOTYPE = 0, // placeholder
538  FIDT_BYTE = 1, // 8-bit unsigned integer
539  FIDT_ASCII = 2, // 8-bit bytes w/ last byte null
540  FIDT_SHORT = 3, // 16-bit unsigned integer
541  FIDT_LONG = 4, // 32-bit unsigned integer
542  FIDT_RATIONAL = 5, // 64-bit unsigned fraction
543  FIDT_SBYTE = 6, // 8-bit signed integer
544  FIDT_UNDEFINED = 7, // 8-bit untyped data
545  FIDT_SSHORT = 8, // 16-bit signed integer
546  FIDT_SLONG = 9, // 32-bit signed integer
547  FIDT_SRATIONAL = 10, // 64-bit signed fraction
548  FIDT_FLOAT = 11, // 32-bit IEEE floating point
549  FIDT_DOUBLE = 12, // 64-bit IEEE floating point
550  FIDT_IFD = 13, // 32-bit unsigned integer (offset)
551  FIDT_PALETTE = 14 // 32-bit RGBQUAD
552 };
553 
557 FI_ENUM(FREE_IMAGE_MDMODEL) {
558  FIMD_NODATA = -1,
559  FIMD_COMMENTS = 0, // single comment or keywords
560  FIMD_EXIF_MAIN = 1, // Exif-TIFF metadata
561  FIMD_EXIF_EXIF = 2, // Exif-specific metadata
562  FIMD_EXIF_GPS = 3, // Exif GPS metadata
563  FIMD_EXIF_MAKERNOTE = 4, // Exif maker note metadata
564  FIMD_EXIF_INTEROP = 5, // Exif interoperability metadata
565  FIMD_IPTC = 6, // IPTC/NAA metadata
566  FIMD_XMP = 7, // Abobe XMP metadata
567  FIMD_GEOTIFF = 8, // GeoTIFF metadata
568  FIMD_ANIMATION = 9, // Animation metadata
569  FIMD_CUSTOM = 10 // Used to attach other metadata types to a dib
570 };
571 
575 FI_STRUCT (FIMETADATA) { void *data; };
576 
580 FI_STRUCT (FITAG) { void *data; };
581 
582 // File IO routines ---------------------------------------------------------
583 
584 #ifndef FREEIMAGE_IO
585 #define FREEIMAGE_IO
586 
587 typedef void* fi_handle;
588 typedef unsigned (DLL_CALLCONV *FI_ReadProc) (void *buffer, unsigned size, unsigned count, fi_handle handle);
589 typedef unsigned (DLL_CALLCONV *FI_WriteProc) (void *buffer, unsigned size, unsigned count, fi_handle handle);
590 typedef int (DLL_CALLCONV *FI_SeekProc) (fi_handle handle, long offset, int origin);
591 typedef long (DLL_CALLCONV *FI_TellProc) (fi_handle handle);
592 
593 #if (defined(_WIN32) || defined(__WIN32__))
594 #pragma pack(push, 1)
595 #else
596 #pragma pack(1)
597 #endif // WIN32
598 
599 FI_STRUCT(FreeImageIO) {
600  FI_ReadProc read_proc; // pointer to the function used to read data
601  FI_WriteProc write_proc; // pointer to the function used to write data
602  FI_SeekProc seek_proc; // pointer to the function used to seek
603  FI_TellProc tell_proc; // pointer to the function used to aquire the current position
604 };
605 
606 #if (defined(_WIN32) || defined(__WIN32__))
607 #pragma pack(pop)
608 #else
609 #pragma pack()
610 #endif // WIN32
611 
615 FI_STRUCT (FIMEMORY) { void *data; };
616 
617 #endif // FREEIMAGE_IO
618 
619 // Plugin routines ----------------------------------------------------------
620 
621 #ifndef PLUGINS
622 #define PLUGINS
623 
624 typedef const char *(DLL_CALLCONV *FI_FormatProc) ();
625 typedef const char *(DLL_CALLCONV *FI_DescriptionProc) ();
626 typedef const char *(DLL_CALLCONV *FI_ExtensionListProc) ();
627 typedef const char *(DLL_CALLCONV *FI_RegExprProc) ();
628 typedef void *(DLL_CALLCONV *FI_OpenProc)(FreeImageIO *io, fi_handle handle, BOOL read);
629 typedef void (DLL_CALLCONV *FI_CloseProc)(FreeImageIO *io, fi_handle handle, void *data);
630 typedef int (DLL_CALLCONV *FI_PageCountProc)(FreeImageIO *io, fi_handle handle, void *data);
631 typedef int (DLL_CALLCONV *FI_PageCapabilityProc)(FreeImageIO *io, fi_handle handle, void *data);
632 typedef FIBITMAP *(DLL_CALLCONV *FI_LoadProc)(FreeImageIO *io, fi_handle handle, int page, int flags, void *data);
633 typedef BOOL (DLL_CALLCONV *FI_SaveProc)(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data);
634 typedef BOOL (DLL_CALLCONV *FI_ValidateProc)(FreeImageIO *io, fi_handle handle);
635 typedef const char *(DLL_CALLCONV *FI_MimeProc) ();
636 typedef BOOL (DLL_CALLCONV *FI_SupportsExportBPPProc)(int bpp);
637 typedef BOOL (DLL_CALLCONV *FI_SupportsExportTypeProc)(FREE_IMAGE_TYPE type);
638 typedef BOOL (DLL_CALLCONV *FI_SupportsICCProfilesProc)();
639 
640 FI_STRUCT (Plugin) {
641  FI_FormatProc format_proc;
642  FI_DescriptionProc description_proc;
643  FI_ExtensionListProc extension_proc;
644  FI_RegExprProc regexpr_proc;
645  FI_OpenProc open_proc;
646  FI_CloseProc close_proc;
647  FI_PageCountProc pagecount_proc;
648  FI_PageCapabilityProc pagecapability_proc;
649  FI_LoadProc load_proc;
650  FI_SaveProc save_proc;
651  FI_ValidateProc validate_proc;
652  FI_MimeProc mime_proc;
653  FI_SupportsExportBPPProc supports_export_bpp_proc;
654  FI_SupportsExportTypeProc supports_export_type_proc;
655  FI_SupportsICCProfilesProc supports_icc_profiles_proc;
656 };
657 
658 typedef void (DLL_CALLCONV *FI_InitProc)(Plugin *plugin, int format_id);
659 
660 #endif // PLUGINS
661 
662 
663 // Load / Save flag constants -----------------------------------------------
664 
665 #define BMP_DEFAULT 0
666 #define BMP_SAVE_RLE 1
667 #define CUT_DEFAULT 0
668 #define DDS_DEFAULT 0
669 #define EXR_DEFAULT 0 // save data as half with piz-based wavelet compression
670 #define EXR_FLOAT 0x0001 // save data as float instead of as half (not recommended)
671 #define EXR_NONE 0x0002 // save with no compression
672 #define EXR_ZIP 0x0004 // save with zlib compression, in blocks of 16 scan lines
673 #define EXR_PIZ 0x0008 // save with piz-based wavelet compression
674 #define EXR_PXR24 0x0010 // save with lossy 24-bit float compression
675 #define EXR_B44 0x0020 // save with lossy 44% float compression - goes to 22% when combined with EXR_LC
676 #define EXR_LC 0x0040 // save images with one luminance and two chroma channels, rather than as RGB (lossy compression)
677 #define FAXG3_DEFAULT 0
678 #define GIF_DEFAULT 0
679 #define GIF_LOAD256 1 // Load the image as a 256 color image with ununsed palette entries, if it's 16 or 2 color
680 #define GIF_PLAYBACK 2 // 'Play' the GIF to generate each frame (as 32bpp) instead of returning raw frame data when loading
681 #define HDR_DEFAULT 0
682 #define ICO_DEFAULT 0
683 #define ICO_MAKEALPHA 1 // convert to 32bpp and create an alpha channel from the AND-mask when loading
684 #define IFF_DEFAULT 0
685 #define J2K_DEFAULT 0 // save with a 16:1 rate
686 #define JP2_DEFAULT 0 // save with a 16:1 rate
687 #define JPEG_DEFAULT 0 // loading (see JPEG_FAST); saving (see JPEG_QUALITYGOOD)
688 #define JPEG_FAST 0x0001 // load the file as fast as possible, sacrificing some quality
689 #define JPEG_ACCURATE 0x0002 // load the file with the best quality, sacrificing some speed
690 #define JPEG_CMYK 0x0004 // load separated CMYK "as is" (use | to combine with other load flags)
691 #define JPEG_QUALITYSUPERB 0x80 // save with superb quality (100:1)
692 #define JPEG_QUALITYGOOD 0x0100 // save with good quality (75:1)
693 #define JPEG_QUALITYNORMAL 0x0200 // save with normal quality (50:1)
694 #define JPEG_QUALITYAVERAGE 0x0400 // save with average quality (25:1)
695 #define JPEG_QUALITYBAD 0x0800 // save with bad quality (10:1)
696 #define JPEG_PROGRESSIVE 0x2000 // save as a progressive-JPEG (use | to combine with other save flags)
697 #define KOALA_DEFAULT 0
698 #define LBM_DEFAULT 0
699 #define MNG_DEFAULT 0
700 #define PCD_DEFAULT 0
701 #define PCD_BASE 1 // load the bitmap sized 768 x 512
702 #define PCD_BASEDIV4 2 // load the bitmap sized 384 x 256
703 #define PCD_BASEDIV16 3 // load the bitmap sized 192 x 128
704 #define PCX_DEFAULT 0
705 #define PNG_DEFAULT 0
706 #define PNG_IGNOREGAMMA 1 // avoid gamma correction
707 #define PNM_DEFAULT 0
708 #define PNM_SAVE_RAW 0 // If set the writer saves in RAW format (i.e. P4, P5 or P6)
709 #define PNM_SAVE_ASCII 1 // If set the writer saves in ASCII format (i.e. P1, P2 or P3)
710 #define PSD_DEFAULT 0
711 #define RAS_DEFAULT 0
712 #define SGI_DEFAULT 0
713 #define TARGA_DEFAULT 0
714 #define TARGA_LOAD_RGB888 1 // If set the loader converts RGB555 and ARGB8888 -> RGB888.
715 #define TIFF_DEFAULT 0
716 #define TIFF_CMYK 0x0001 // reads/stores tags for separated CMYK (use | to combine with compression flags)
717 #define TIFF_PACKBITS 0x0100 // save using PACKBITS compression
718 #define TIFF_DEFLATE 0x0200 // save using DEFLATE compression (a.k.a. ZLIB compression)
719 #define TIFF_ADOBE_DEFLATE 0x0400 // save using ADOBE DEFLATE compression
720 #define TIFF_NONE 0x0800 // save without any compression
721 #define TIFF_CCITTFAX3 0x1000 // save using CCITT Group 3 fax encoding
722 #define TIFF_CCITTFAX4 0x2000 // save using CCITT Group 4 fax encoding
723 #define TIFF_LZW 0x4000 // save using LZW compression
724 #define TIFF_JPEG 0x8000 // save using JPEG compression
725 #define WBMP_DEFAULT 0
726 #define XBM_DEFAULT 0
727 #define XPM_DEFAULT 0
728 
729 
730 #ifdef __cplusplus
731 extern "C" {
732 #endif
733 
734 // Init / Error routines ----------------------------------------------------
735 
736 DLL_API void DLL_CALLCONV FreeImage_Initialise(BOOL load_local_plugins_only FI_DEFAULT(FALSE));
737 DLL_API void DLL_CALLCONV FreeImage_DeInitialise(void);
738 
739 // Version routines ---------------------------------------------------------
740 
741 DLL_API const char *DLL_CALLCONV FreeImage_GetVersion(void);
742 DLL_API const char *DLL_CALLCONV FreeImage_GetCopyrightMessage(void);
743 
744 // Message output functions -------------------------------------------------
745 
746 typedef void (*FreeImage_OutputMessageFunction)(FREE_IMAGE_FORMAT fif, const char *msg);
747 typedef void (DLL_CALLCONV *FreeImage_OutputMessageFunctionStdCall)(FREE_IMAGE_FORMAT fif, const char *msg);
748 
749 DLL_API void DLL_CALLCONV FreeImage_SetOutputMessageStdCall(FreeImage_OutputMessageFunctionStdCall omf);
750 DLL_API void DLL_CALLCONV FreeImage_SetOutputMessage(FreeImage_OutputMessageFunction omf);
751 DLL_API void DLL_CALLCONV FreeImage_OutputMessageProc(int fif, const char *fmt, ...);
752 
753 // Allocate / Clone / Unload routines ---------------------------------------
754 
755 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Allocate(int width, int height, int bpp, unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0));
756 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_AllocateT(FREE_IMAGE_TYPE type, int width, int height, int bpp FI_DEFAULT(8), unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0));
757 DLL_API FIBITMAP * DLL_CALLCONV FreeImage_Clone(FIBITMAP *dib);
758 DLL_API void DLL_CALLCONV FreeImage_Unload(FIBITMAP *dib);
759 
760 // Load / Save routines -----------------------------------------------------
761 
762 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Load(FREE_IMAGE_FORMAT fif, const char *filename, int flags FI_DEFAULT(0));
763 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadU(FREE_IMAGE_FORMAT fif, const wchar_t *filename, int flags FI_DEFAULT(0));
764 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadFromHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0));
765 DLL_API BOOL DLL_CALLCONV FreeImage_Save(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, const char *filename, int flags FI_DEFAULT(0));
766 DLL_API BOOL DLL_CALLCONV FreeImage_SaveU(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, const wchar_t *filename, int flags FI_DEFAULT(0));
767 DLL_API BOOL DLL_CALLCONV FreeImage_SaveToHandle(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0));
768 
769 // Memory I/O stream routines -----------------------------------------------
770 
771 DLL_API FIMEMORY *DLL_CALLCONV FreeImage_OpenMemory(BYTE *data FI_DEFAULT(0), DWORD size_in_bytes FI_DEFAULT(0));
772 DLL_API void DLL_CALLCONV FreeImage_CloseMemory(FIMEMORY *stream);
773 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadFromMemory(FREE_IMAGE_FORMAT fif, FIMEMORY *stream, int flags FI_DEFAULT(0));
774 DLL_API BOOL DLL_CALLCONV FreeImage_SaveToMemory(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FIMEMORY *stream, int flags FI_DEFAULT(0));
775 DLL_API long DLL_CALLCONV FreeImage_TellMemory(FIMEMORY *stream);
776 DLL_API BOOL DLL_CALLCONV FreeImage_SeekMemory(FIMEMORY *stream, long offset, int origin);
777 DLL_API BOOL DLL_CALLCONV FreeImage_AcquireMemory(FIMEMORY *stream, BYTE **data, DWORD *size_in_bytes);
778 DLL_API unsigned DLL_CALLCONV FreeImage_ReadMemory(void *buffer, unsigned size, unsigned count, FIMEMORY *stream);
779 DLL_API unsigned DLL_CALLCONV FreeImage_WriteMemory(const void *buffer, unsigned size, unsigned count, FIMEMORY *stream);
780 DLL_API FIMULTIBITMAP *DLL_CALLCONV FreeImage_LoadMultiBitmapFromMemory(FREE_IMAGE_FORMAT fif, FIMEMORY *stream, int flags FI_DEFAULT(0));
781 
782 // Plugin Interface ---------------------------------------------------------
783 
784 DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_RegisterLocalPlugin(FI_InitProc proc_address, const char *format FI_DEFAULT(0), const char *description FI_DEFAULT(0), const char *extension FI_DEFAULT(0), const char *regexpr FI_DEFAULT(0));
785 DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_RegisterExternalPlugin(const char *path, const char *format FI_DEFAULT(0), const char *description FI_DEFAULT(0), const char *extension FI_DEFAULT(0), const char *regexpr FI_DEFAULT(0));
786 DLL_API int DLL_CALLCONV FreeImage_GetFIFCount(void);
787 DLL_API int DLL_CALLCONV FreeImage_SetPluginEnabled(FREE_IMAGE_FORMAT fif, BOOL enable);
788 DLL_API int DLL_CALLCONV FreeImage_IsPluginEnabled(FREE_IMAGE_FORMAT fif);
789 DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFIFFromFormat(const char *format);
790 DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFIFFromMime(const char *mime);
791 DLL_API const char *DLL_CALLCONV FreeImage_GetFormatFromFIF(FREE_IMAGE_FORMAT fif);
792 DLL_API const char *DLL_CALLCONV FreeImage_GetFIFExtensionList(FREE_IMAGE_FORMAT fif);
793 DLL_API const char *DLL_CALLCONV FreeImage_GetFIFDescription(FREE_IMAGE_FORMAT fif);
794 DLL_API const char *DLL_CALLCONV FreeImage_GetFIFRegExpr(FREE_IMAGE_FORMAT fif);
795 DLL_API const char *DLL_CALLCONV FreeImage_GetFIFMimeType(FREE_IMAGE_FORMAT fif);
796 DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFIFFromFilename(const char *filename);
797 DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFIFFromFilenameU(const wchar_t *filename);
798 DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsReading(FREE_IMAGE_FORMAT fif);
799 DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsWriting(FREE_IMAGE_FORMAT fif);
800 DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsExportBPP(FREE_IMAGE_FORMAT fif, int bpp);
801 DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsExportType(FREE_IMAGE_FORMAT fif, FREE_IMAGE_TYPE type);
802 DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsICCProfiles(FREE_IMAGE_FORMAT fif);
803 
804 // Multipaging interface ----------------------------------------------------
805 
806 DLL_API FIMULTIBITMAP * DLL_CALLCONV FreeImage_OpenMultiBitmap(FREE_IMAGE_FORMAT fif, const char *filename, BOOL create_new, BOOL read_only, BOOL keep_cache_in_memory FI_DEFAULT(FALSE), int flags FI_DEFAULT(0));
807 DLL_API BOOL DLL_CALLCONV FreeImage_CloseMultiBitmap(FIMULTIBITMAP *bitmap, int flags FI_DEFAULT(0));
808 DLL_API int DLL_CALLCONV FreeImage_GetPageCount(FIMULTIBITMAP *bitmap);
809 DLL_API void DLL_CALLCONV FreeImage_AppendPage(FIMULTIBITMAP *bitmap, FIBITMAP *data);
810 DLL_API void DLL_CALLCONV FreeImage_InsertPage(FIMULTIBITMAP *bitmap, int page, FIBITMAP *data);
811 DLL_API void DLL_CALLCONV FreeImage_DeletePage(FIMULTIBITMAP *bitmap, int page);
812 DLL_API FIBITMAP * DLL_CALLCONV FreeImage_LockPage(FIMULTIBITMAP *bitmap, int page);
813 DLL_API void DLL_CALLCONV FreeImage_UnlockPage(FIMULTIBITMAP *bitmap, FIBITMAP *data, BOOL changed);
814 DLL_API BOOL DLL_CALLCONV FreeImage_MovePage(FIMULTIBITMAP *bitmap, int target, int source);
815 DLL_API BOOL DLL_CALLCONV FreeImage_GetLockedPageNumbers(FIMULTIBITMAP *bitmap, int *pages, int *count);
816 
817 // Filetype request routines ------------------------------------------------
818 
819 DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileType(const char *filename, int size FI_DEFAULT(0));
820 DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileTypeU(const wchar_t *filename, int size FI_DEFAULT(0));
821 DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileTypeFromHandle(FreeImageIO *io, fi_handle handle, int size FI_DEFAULT(0));
822 DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileTypeFromMemory(FIMEMORY *stream, int size FI_DEFAULT(0));
823 
824 // Image type request routine -----------------------------------------------
825 
826 DLL_API FREE_IMAGE_TYPE DLL_CALLCONV FreeImage_GetImageType(FIBITMAP *dib);
827 
828 // FreeImage helper routines ------------------------------------------------
829 
830 DLL_API BOOL DLL_CALLCONV FreeImage_IsLittleEndian(void);
831 DLL_API BOOL DLL_CALLCONV FreeImage_LookupX11Color(const char *szColor, BYTE *nRed, BYTE *nGreen, BYTE *nBlue);
832 DLL_API BOOL DLL_CALLCONV FreeImage_LookupSVGColor(const char *szColor, BYTE *nRed, BYTE *nGreen, BYTE *nBlue);
833 
834 
835 // Pixel access routines ----------------------------------------------------
836 
837 DLL_API BYTE *DLL_CALLCONV FreeImage_GetBits(FIBITMAP *dib);
838 DLL_API BYTE *DLL_CALLCONV FreeImage_GetScanLine(FIBITMAP *dib, int scanline);
839 
840 DLL_API BOOL DLL_CALLCONV FreeImage_GetPixelIndex(FIBITMAP *dib, unsigned x, unsigned y, BYTE *value);
841 DLL_API BOOL DLL_CALLCONV FreeImage_GetPixelColor(FIBITMAP *dib, unsigned x, unsigned y, RGBQUAD *value);
842 DLL_API BOOL DLL_CALLCONV FreeImage_SetPixelIndex(FIBITMAP *dib, unsigned x, unsigned y, BYTE *value);
843 DLL_API BOOL DLL_CALLCONV FreeImage_SetPixelColor(FIBITMAP *dib, unsigned x, unsigned y, RGBQUAD *value);
844 
845 // DIB info routines --------------------------------------------------------
846 
847 DLL_API unsigned DLL_CALLCONV FreeImage_GetColorsUsed(FIBITMAP *dib);
848 DLL_API unsigned DLL_CALLCONV FreeImage_GetBPP(FIBITMAP *dib);
849 DLL_API unsigned DLL_CALLCONV FreeImage_GetWidth(FIBITMAP *dib);
850 DLL_API unsigned DLL_CALLCONV FreeImage_GetHeight(FIBITMAP *dib);
851 DLL_API unsigned DLL_CALLCONV FreeImage_GetLine(FIBITMAP *dib);
852 DLL_API unsigned DLL_CALLCONV FreeImage_GetPitch(FIBITMAP *dib);
853 DLL_API unsigned DLL_CALLCONV FreeImage_GetDIBSize(FIBITMAP *dib);
854 DLL_API RGBQUAD *DLL_CALLCONV FreeImage_GetPalette(FIBITMAP *dib);
855 
856 DLL_API unsigned DLL_CALLCONV FreeImage_GetDotsPerMeterX(FIBITMAP *dib);
857 DLL_API unsigned DLL_CALLCONV FreeImage_GetDotsPerMeterY(FIBITMAP *dib);
858 DLL_API void DLL_CALLCONV FreeImage_SetDotsPerMeterX(FIBITMAP *dib, unsigned res);
859 DLL_API void DLL_CALLCONV FreeImage_SetDotsPerMeterY(FIBITMAP *dib, unsigned res);
860 
861 DLL_API BITMAPINFOHEADER *DLL_CALLCONV FreeImage_GetInfoHeader(FIBITMAP *dib);
862 DLL_API BITMAPINFO *DLL_CALLCONV FreeImage_GetInfo(FIBITMAP *dib);
863 DLL_API FREE_IMAGE_COLOR_TYPE DLL_CALLCONV FreeImage_GetColorType(FIBITMAP *dib);
864 
865 DLL_API unsigned DLL_CALLCONV FreeImage_GetRedMask(FIBITMAP *dib);
866 DLL_API unsigned DLL_CALLCONV FreeImage_GetGreenMask(FIBITMAP *dib);
867 DLL_API unsigned DLL_CALLCONV FreeImage_GetBlueMask(FIBITMAP *dib);
868 
869 DLL_API unsigned DLL_CALLCONV FreeImage_GetTransparencyCount(FIBITMAP *dib);
870 DLL_API BYTE * DLL_CALLCONV FreeImage_GetTransparencyTable(FIBITMAP *dib);
871 DLL_API void DLL_CALLCONV FreeImage_SetTransparent(FIBITMAP *dib, BOOL enabled);
872 DLL_API void DLL_CALLCONV FreeImage_SetTransparencyTable(FIBITMAP *dib, BYTE *table, int count);
873 DLL_API BOOL DLL_CALLCONV FreeImage_IsTransparent(FIBITMAP *dib);
874 DLL_API void DLL_CALLCONV FreeImage_SetTransparentIndex(FIBITMAP *dib, int index);
875 DLL_API int DLL_CALLCONV FreeImage_GetTransparentIndex(FIBITMAP *dib);
876 
877 DLL_API BOOL DLL_CALLCONV FreeImage_HasBackgroundColor(FIBITMAP *dib);
878 DLL_API BOOL DLL_CALLCONV FreeImage_GetBackgroundColor(FIBITMAP *dib, RGBQUAD *bkcolor);
879 DLL_API BOOL DLL_CALLCONV FreeImage_SetBackgroundColor(FIBITMAP *dib, RGBQUAD *bkcolor);
880 
881 
882 // ICC profile routines -----------------------------------------------------
883 
884 DLL_API FIICCPROFILE *DLL_CALLCONV FreeImage_GetICCProfile(FIBITMAP *dib);
885 DLL_API FIICCPROFILE *DLL_CALLCONV FreeImage_CreateICCProfile(FIBITMAP *dib, void *data, long size);
886 DLL_API void DLL_CALLCONV FreeImage_DestroyICCProfile(FIBITMAP *dib);
887 
888 // Line conversion routines -------------------------------------------------
889 
890 DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To4(BYTE *target, BYTE *source, int width_in_pixels);
891 DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To4(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette);
892 DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To4_555(BYTE *target, BYTE *source, int width_in_pixels);
893 DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To4_565(BYTE *target, BYTE *source, int width_in_pixels);
894 DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To4(BYTE *target, BYTE *source, int width_in_pixels);
895 DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To4(BYTE *target, BYTE *source, int width_in_pixels);
896 DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To8(BYTE *target, BYTE *source, int width_in_pixels);
897 DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To8(BYTE *target, BYTE *source, int width_in_pixels);
898 DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To8_555(BYTE *target, BYTE *source, int width_in_pixels);
899 DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To8_565(BYTE *target, BYTE *source, int width_in_pixels);
900 DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To8(BYTE *target, BYTE *source, int width_in_pixels);
901 DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To8(BYTE *target, BYTE *source, int width_in_pixels);
902 DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To16_555(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette);
903 DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To16_555(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette);
904 DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To16_555(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette);
905 DLL_API void DLL_CALLCONV FreeImage_ConvertLine16_565_To16_555(BYTE *target, BYTE *source, int width_in_pixels);
906 DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To16_555(BYTE *target, BYTE *source, int width_in_pixels);
907 DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To16_555(BYTE *target, BYTE *source, int width_in_pixels);
908 DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To16_565(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette);
909 DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To16_565(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette);
910 DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To16_565(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette);
911 DLL_API void DLL_CALLCONV FreeImage_ConvertLine16_555_To16_565(BYTE *target, BYTE *source, int width_in_pixels);
912 DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To16_565(BYTE *target, BYTE *source, int width_in_pixels);
913 DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To16_565(BYTE *target, BYTE *source, int width_in_pixels);
914 DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To24(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette);
915 DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To24(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette);
916 DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To24(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette);
917 DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To24_555(BYTE *target, BYTE *source, int width_in_pixels);
918 DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To24_565(BYTE *target, BYTE *source, int width_in_pixels);
919 DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To24(BYTE *target, BYTE *source, int width_in_pixels);
920 DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To32(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette);
921 DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To32(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette);
922 DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To32(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette);
923 DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To32_555(BYTE *target, BYTE *source, int width_in_pixels);
924 DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To32_565(BYTE *target, BYTE *source, int width_in_pixels);
925 DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To32(BYTE *target, BYTE *source, int width_in_pixels);
926 
927 // Smart conversion routines ------------------------------------------------
928 
929 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo4Bits(FIBITMAP *dib);
930 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo8Bits(FIBITMAP *dib);
931 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToGreyscale(FIBITMAP *dib);
932 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo16Bits555(FIBITMAP *dib);
933 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo16Bits565(FIBITMAP *dib);
934 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo24Bits(FIBITMAP *dib);
935 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo32Bits(FIBITMAP *dib);
936 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ColorQuantize(FIBITMAP *dib, FREE_IMAGE_QUANTIZE quantize);
937 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ColorQuantizeEx(FIBITMAP *dib, FREE_IMAGE_QUANTIZE quantize FI_DEFAULT(FIQ_WUQUANT), int PaletteSize FI_DEFAULT(256), int ReserveSize FI_DEFAULT(0), RGBQUAD *ReservePalette FI_DEFAULT(NULL));
938 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Threshold(FIBITMAP *dib, BYTE T);
939 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Dither(FIBITMAP *dib, FREE_IMAGE_DITHER algorithm);
940 
941 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertFromRawBits(BYTE *bits, int width, int height, int pitch, unsigned bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask, BOOL topdown FI_DEFAULT(FALSE));
942 DLL_API void DLL_CALLCONV FreeImage_ConvertToRawBits(BYTE *bits, FIBITMAP *dib, int pitch, unsigned bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask, BOOL topdown FI_DEFAULT(FALSE));
943 
944 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToRGBF(FIBITMAP *dib);
945 
946 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToStandardType(FIBITMAP *src, BOOL scale_linear FI_DEFAULT(TRUE));
947 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToType(FIBITMAP *src, FREE_IMAGE_TYPE dst_type, BOOL scale_linear FI_DEFAULT(TRUE));
948 
949 // tone mapping operators
950 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ToneMapping(FIBITMAP *dib, FREE_IMAGE_TMO tmo, double first_param FI_DEFAULT(0), double second_param FI_DEFAULT(0));
951 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_TmoDrago03(FIBITMAP *src, double gamma FI_DEFAULT(2.2), double exposure FI_DEFAULT(0));
952 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_TmoReinhard05(FIBITMAP *src, double intensity FI_DEFAULT(0), double contrast FI_DEFAULT(0));
953 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_TmoFattal02(FIBITMAP *src, double color_saturation FI_DEFAULT(0.5), double attenuation FI_DEFAULT(0.85));
954 
955 // ZLib interface -----------------------------------------------------------
956 
957 DLL_API DWORD DLL_CALLCONV FreeImage_ZLibCompress(BYTE *target, DWORD target_size, BYTE *source, DWORD source_size);
958 DLL_API DWORD DLL_CALLCONV FreeImage_ZLibUncompress(BYTE *target, DWORD target_size, BYTE *source, DWORD source_size);
959 DLL_API DWORD DLL_CALLCONV FreeImage_ZLibGZip(BYTE *target, DWORD target_size, BYTE *source, DWORD source_size);
960 DLL_API DWORD DLL_CALLCONV FreeImage_ZLibGUnzip(BYTE *target, DWORD target_size, BYTE *source, DWORD source_size);
961 DLL_API DWORD DLL_CALLCONV FreeImage_ZLibCRC32(DWORD crc, BYTE *source, DWORD source_size);
962 
963 // --------------------------------------------------------------------------
964 // Metadata routines --------------------------------------------------------
965 // --------------------------------------------------------------------------
966 
967 // tag creation / destruction
968 DLL_API FITAG *DLL_CALLCONV FreeImage_CreateTag();
969 DLL_API void DLL_CALLCONV FreeImage_DeleteTag(FITAG *tag);
970 DLL_API FITAG *DLL_CALLCONV FreeImage_CloneTag(FITAG *tag);
971 
972 // tag getters and setters
973 DLL_API const char *DLL_CALLCONV FreeImage_GetTagKey(FITAG *tag);
974 DLL_API const char *DLL_CALLCONV FreeImage_GetTagDescription(FITAG *tag);
975 DLL_API WORD DLL_CALLCONV FreeImage_GetTagID(FITAG *tag);
976 DLL_API FREE_IMAGE_MDTYPE DLL_CALLCONV FreeImage_GetTagType(FITAG *tag);
977 DLL_API DWORD DLL_CALLCONV FreeImage_GetTagCount(FITAG *tag);
978 DLL_API DWORD DLL_CALLCONV FreeImage_GetTagLength(FITAG *tag);
979 DLL_API const void *DLL_CALLCONV FreeImage_GetTagValue(FITAG *tag);
980 
981 DLL_API BOOL DLL_CALLCONV FreeImage_SetTagKey(FITAG *tag, const char *key);
982 DLL_API BOOL DLL_CALLCONV FreeImage_SetTagDescription(FITAG *tag, const char *description);
983 DLL_API BOOL DLL_CALLCONV FreeImage_SetTagID(FITAG *tag, WORD id);
984 DLL_API BOOL DLL_CALLCONV FreeImage_SetTagType(FITAG *tag, FREE_IMAGE_MDTYPE type);
985 DLL_API BOOL DLL_CALLCONV FreeImage_SetTagCount(FITAG *tag, DWORD count);
986 DLL_API BOOL DLL_CALLCONV FreeImage_SetTagLength(FITAG *tag, DWORD length);
987 DLL_API BOOL DLL_CALLCONV FreeImage_SetTagValue(FITAG *tag, const void *value);
988 
989 // iterator
990 DLL_API FIMETADATA *DLL_CALLCONV FreeImage_FindFirstMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, FITAG **tag);
991 DLL_API BOOL DLL_CALLCONV FreeImage_FindNextMetadata(FIMETADATA *mdhandle, FITAG **tag);
992 DLL_API void DLL_CALLCONV FreeImage_FindCloseMetadata(FIMETADATA *mdhandle);
993 
994 // metadata setter and getter
995 DLL_API BOOL DLL_CALLCONV FreeImage_SetMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, const char *key, FITAG *tag);
996 DLL_API BOOL DLL_CALLCONV FreeImage_GetMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, const char *key, FITAG **tag);
997 
998 // helpers
999 DLL_API unsigned DLL_CALLCONV FreeImage_GetMetadataCount(FREE_IMAGE_MDMODEL model, FIBITMAP *dib);
1000 
1001 // tag to C string conversion
1002 DLL_API const char* DLL_CALLCONV FreeImage_TagToString(FREE_IMAGE_MDMODEL model, FITAG *tag, char *Make FI_DEFAULT(NULL));
1003 
1004 // --------------------------------------------------------------------------
1005 // Image manipulation toolkit -----------------------------------------------
1006 // --------------------------------------------------------------------------
1007 
1008 // rotation and flipping
1009 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_RotateClassic(FIBITMAP *dib, double angle);
1010 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_RotateEx(FIBITMAP *dib, double angle, double x_shift, double y_shift, double x_origin, double y_origin, BOOL use_mask);
1011 DLL_API BOOL DLL_CALLCONV FreeImage_FlipHorizontal(FIBITMAP *dib);
1012 DLL_API BOOL DLL_CALLCONV FreeImage_FlipVertical(FIBITMAP *dib);
1013 /* The FreeImage_JPEGTransform functions are deliberately disabled in the
1014  Fedora build of FreeImage as they require that FreeImage uses a private copy
1015  of libjpeg which is a no no because of security reasons */
1016 #if 0
1017 DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransform(const char *src_file, const char *dst_file, FREE_IMAGE_JPEG_OPERATION operation, BOOL perfect FI_DEFAULT(FALSE));
1018 #endif
1019 
1020 // upsampling / downsampling
1021 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Rescale(FIBITMAP *dib, int dst_width, int dst_height, FREE_IMAGE_FILTER filter);
1022 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_MakeThumbnail(FIBITMAP *dib, int max_pixel_size, BOOL convert FI_DEFAULT(TRUE));
1023 
1024 // color manipulation routines (point operations)
1025 DLL_API BOOL DLL_CALLCONV FreeImage_AdjustCurve(FIBITMAP *dib, BYTE *LUT, FREE_IMAGE_COLOR_CHANNEL channel);
1026 DLL_API BOOL DLL_CALLCONV FreeImage_AdjustGamma(FIBITMAP *dib, double gamma);
1027 DLL_API BOOL DLL_CALLCONV FreeImage_AdjustBrightness(FIBITMAP *dib, double percentage);
1028 DLL_API BOOL DLL_CALLCONV FreeImage_AdjustContrast(FIBITMAP *dib, double percentage);
1029 DLL_API BOOL DLL_CALLCONV FreeImage_Invert(FIBITMAP *dib);
1030 DLL_API BOOL DLL_CALLCONV FreeImage_GetHistogram(FIBITMAP *dib, DWORD *histo, FREE_IMAGE_COLOR_CHANNEL channel FI_DEFAULT(FICC_BLACK));
1031 DLL_API int DLL_CALLCONV FreeImage_GetAdjustColorsLookupTable(BYTE *LUT, double brightness, double contrast, double gamma, BOOL invert);
1032 DLL_API BOOL DLL_CALLCONV FreeImage_AdjustColors(FIBITMAP *dib, double brightness, double contrast, double gamma, BOOL invert FI_DEFAULT(FALSE));
1033 DLL_API unsigned DLL_CALLCONV FreeImage_ApplyColorMapping(FIBITMAP *dib, RGBQUAD *srccolors, RGBQUAD *dstcolors, unsigned count, BOOL ignore_alpha, BOOL swap);
1034 DLL_API unsigned DLL_CALLCONV FreeImage_SwapColors(FIBITMAP *dib, RGBQUAD *color_a, RGBQUAD *color_b, BOOL ignore_alpha);
1035 DLL_API unsigned DLL_CALLCONV FreeImage_ApplyPaletteIndexMapping(FIBITMAP *dib, BYTE *srcindices, BYTE *dstindices, unsigned count, BOOL swap);
1036 DLL_API unsigned DLL_CALLCONV FreeImage_SwapPaletteIndices(FIBITMAP *dib, BYTE *index_a, BYTE *index_b);
1037 
1038 // channel processing routines
1039 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_GetChannel(FIBITMAP *dib, FREE_IMAGE_COLOR_CHANNEL channel);
1040 DLL_API BOOL DLL_CALLCONV FreeImage_SetChannel(FIBITMAP *dib, FIBITMAP *dib8, FREE_IMAGE_COLOR_CHANNEL channel);
1041 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_GetComplexChannel(FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel);
1042 DLL_API BOOL DLL_CALLCONV FreeImage_SetComplexChannel(FIBITMAP *dst, FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel);
1043 
1044 // copy / paste / composite routines
1045 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Copy(FIBITMAP *dib, int left, int top, int right, int bottom);
1046 DLL_API BOOL DLL_CALLCONV FreeImage_Paste(FIBITMAP *dst, FIBITMAP *src, int left, int top, int alpha);
1047 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Composite(FIBITMAP *fg, BOOL useFileBkg FI_DEFAULT(FALSE), RGBQUAD *appBkColor FI_DEFAULT(NULL), FIBITMAP *bg FI_DEFAULT(NULL));
1048 /* The FreeImage_JPEGTransform functions are deliberately disabled in the
1049  Fedora build of FreeImage as they require that FreeImage uses a private copy
1050  of libjpeg which is a no no because of security reasons */
1051 #if 0
1052 DLL_API BOOL DLL_CALLCONV FreeImage_JPEGCrop(const char *src_file, const char *dst_file, int left, int top, int right, int bottom);
1053 #endif
1054 DLL_API BOOL DLL_CALLCONV FreeImage_PreMultiplyWithAlpha(FIBITMAP *dib);
1055 
1056 // miscellaneous algorithms
1057 DLL_API FIBITMAP *DLL_CALLCONV FreeImage_MultigridPoissonSolver(FIBITMAP *Laplacian, int ncycle FI_DEFAULT(3));
1058 
1059 // restore the borland-specific enum size option
1060 #if defined(__BORLANDC__)
1061 #pragma option pop
1062 #endif
1063 
1064 #ifdef __cplusplus
1065 }
1066 #endif
1067 
1068 #endif // FREEIMAGE_H
Data structure for COMPLEX type (complex number)
Definition: FreeImage.h:269
double r
real part
Definition: FreeImage.h:271
96-bit RGB Float
Definition: FreeImage.h:252
Definition: FreeImage.h:173
128-bit RGBA Float
Definition: FreeImage.h:260
64-bit RGBA
Definition: FreeImage.h:243
double i
imaginary part
Definition: FreeImage.h:273
Definition: FreeImage.h:204
48-bit RGB
Definition: FreeImage.h:235
Definition: FreeImage.h:186
Definition: FreeImage.h:218