FreeImagePlus  FreeImage 3.18.0
FreeImagePlus.h
1 // ==========================================================
2 // FreeImagePlus 3
3 //
4 // Design and implementation by
5 // - Hervé Drolon (drolon@infonie.fr)
6 //
7 // This file is part of FreeImage 3
8 //
9 // COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
10 // OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
11 // THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
12 // OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
13 // CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
14 // THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
15 // SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
16 // PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
17 // THIS DISCLAIMER.
18 //
19 // Use at your own risk!
20 // ==========================================================
21 
22 #ifndef FREEIMAGEPLUS_H
23 #define FREEIMAGEPLUS_H
24 
25 #ifdef _WIN32
26 #include <windows.h>
27 #endif // _WIN32
28 #include "FreeImage.h"
29 
30 
31 // Compiler options ---------------------------------------------------------
32 
33 #if defined(FREEIMAGE_LIB)
34  #define FIP_API
35  #define FIP_CALLCONV
36 #else
37  #if defined(_WIN32) || defined(__WIN32__)
38  #define WIN32_LEAN_AND_MEAN
39  #define FIP_CALLCONV __stdcall
40  // The following ifdef block is the standard way of creating macros which make exporting
41  // from a DLL simpler. All files within this DLL are compiled with the FIP_EXPORTS
42  // symbol defined on the command line. this symbol should not be defined on any project
43  // that uses this DLL. This way any other project whose source files include this file see
44  // FIP_API functions as being imported from a DLL, wheras this DLL sees symbols
45  // defined with this macro as being exported.
46  #ifdef FIP_EXPORTS
47  #define FIP_API __declspec(dllexport)
48  #else
49  #define FIP_API __declspec(dllimport)
50  #endif // FIP_EXPORTS
51  #else
52  // try the gcc visibility support (see http://gcc.gnu.org/wiki/Visibility)
53  #if defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
54  #ifndef GCC_HASCLASSVISIBILITY
55  #define GCC_HASCLASSVISIBILITY
56  #endif
57  #endif
58  #define FIP_CALLCONV
59  #if defined(GCC_HASCLASSVISIBILITY)
60  #define FIP_API __attribute__ ((visibility("default")))
61  #else
62  #define FIP_API
63  #endif
64  #endif // WIN32 / !WIN32
65 #endif // FREEIMAGE_LIB
66 
68 
69 // ----------------------------------------------------------
70 
76 class FIP_API fipObject
77 {
78 public:
80  virtual ~fipObject(){};
81 
85  virtual BOOL isValid() const = 0;
87 };
88 
89 // ----------------------------------------------------------
90 
91 class fipMemoryIO;
92 class fipMultiPage;
93 class fipTag;
94 
103 class FIP_API fipImage : public fipObject
104 {
105 protected:
107  FIBITMAP *_dib;
109  FREE_IMAGE_FORMAT _fif;
111  mutable BOOL _bHasChanged;
112 
113 public:
114  friend class fipMultiPage;
115 
116 public:
117 
124  fipImage(FREE_IMAGE_TYPE image_type = FIT_BITMAP, unsigned width = 0, unsigned height = 0, unsigned bpp = 0);
126  virtual ~fipImage();
131  BOOL setSize(FREE_IMAGE_TYPE image_type, unsigned width, unsigned height, unsigned bpp, unsigned red_mask = 0, unsigned green_mask = 0, unsigned blue_mask = 0);
133  virtual void clear();
135 
142  fipImage(const fipImage& src);
153  fipImage& operator=(FIBITMAP *dib);
154 
155 
168  BOOL copySubImage(fipImage& dst, int left, int top, int right, int bottom) const;
169 
183  BOOL pasteSubImage(fipImage& src, int left, int top, int alpha = 256);
184 
195  BOOL crop(int left, int top, int right, int bottom);
196 
215  BOOL createView(fipImage& dynamicView, unsigned left, unsigned top, unsigned right, unsigned bottom);
216 
218 
228  static FREE_IMAGE_FORMAT identifyFIF(const char* lpszPathName);
229 
234  static FREE_IMAGE_FORMAT identifyFIFU(const wchar_t* lpszPathName);
235 
243  static FREE_IMAGE_FORMAT identifyFIFFromHandle(FreeImageIO *io, fi_handle handle);
244 
251  static FREE_IMAGE_FORMAT identifyFIFFromMemory(FIMEMORY *hmem);
252 
254 
255 
268  BOOL load(const char* lpszPathName, int flag = 0);
269 
278  BOOL load(FREE_IMAGE_FORMAT fif, const char* lpszPathName, int flag = 0);
279 
284  BOOL loadU(const wchar_t* lpszPathName, int flag = 0);
285 
290  BOOL loadU(FREE_IMAGE_FORMAT fif, const wchar_t* lpszPathName, int flag = 0);
291 
300  BOOL loadFromHandle(FreeImageIO *io, fi_handle handle, int flag = 0);
301 
309  BOOL loadFromMemory(fipMemoryIO& memIO, int flag = 0);
310 
319  BOOL loadFromMemory(FREE_IMAGE_FORMAT fif, fipMemoryIO& memIO, int flag = 0);
320 
329  BOOL save(const char* lpszPathName, int flag = 0);
330 
339  BOOL save(FREE_IMAGE_FORMAT fif, const char* lpszPathName, int flag = 0);
340 
345  BOOL saveU(const wchar_t* lpszPathName, int flag = 0);
346 
351  BOOL saveU(FREE_IMAGE_FORMAT fif, const wchar_t* lpszPathName, int flag = 0);
352 
362  BOOL saveToHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flag = 0);
363 
372  BOOL saveToMemory(FREE_IMAGE_FORMAT fif, fipMemoryIO& memIO, int flag = 0);
373 
375 
380 
385  FREE_IMAGE_TYPE getImageType() const;
386 
390  FREE_IMAGE_FORMAT getFIF() const;
391 
396  unsigned getWidth() const;
397 
402  unsigned getHeight() const;
403 
408  unsigned getScanWidth() const;
409 
422  operator FIBITMAP*() {
423  return _dib;
424  }
425 
427  BOOL isValid() const;
428 
433  const BITMAPINFO* getInfo() const;
434 
440 
446  unsigned getImageSize() const;
447 
452  unsigned getImageMemorySize() const;
453 
459  unsigned getBitsPerPixel() const;
460 
466  unsigned getLine() const;
467 
472  double getHorizontalResolution() const;
473 
478  double getVerticalResolution() const;
479 
484  void setHorizontalResolution(double value);
485 
490  void setVerticalResolution(double value);
491 
493 
500  RGBQUAD* getPalette() const;
501 
506  unsigned getPaletteSize() const;
507 
512  unsigned getColorsUsed() const;
513 
518  FREE_IMAGE_COLOR_TYPE getColorType() const;
519 
524  BOOL isGrayscale() const;
526 
529 
535  BOOL getThumbnail(fipImage& image) const;
536 
542  BOOL setThumbnail(const fipImage& image);
543 
549  BOOL hasThumbnail() const;
550 
557 
559 
562 
571  BYTE* accessPixels() const;
572 
578  BYTE* getScanLine(unsigned scanline) const;
579 
588  BOOL getPixelIndex(unsigned x, unsigned y, BYTE *value) const;
589 
598  BOOL getPixelColor(unsigned x, unsigned y, RGBQUAD *value) const;
599 
608  BOOL setPixelIndex(unsigned x, unsigned y, BYTE *value);
609 
618  BOOL setPixelColor(unsigned x, unsigned y, RGBQUAD *value);
619 
621 
633  BOOL convertToType(FREE_IMAGE_TYPE image_type, BOOL scale_linear = TRUE);
634 
641  BOOL threshold(BYTE T);
642 
649  BOOL dither(FREE_IMAGE_DITHER algorithm);
650 
657 
664 
672 
680  BOOL colorQuantize(FREE_IMAGE_QUANTIZE algorithm);
681 
688 
695 
702 
709 
716 
723 
730 
737 
744 
751 
762  BOOL toneMapping(FREE_IMAGE_TMO tmo, double first_param = 0, double second_param = 0, double third_param = 1, double fourth_param = 0);
763 
765 
768 
773  BOOL isTransparent() const;
774 
780  unsigned getTransparencyCount() const;
781 
787  BYTE* getTransparencyTable() const;
788 
793  void setTransparencyTable(BYTE *table, int count);
794 
799  BOOL hasFileBkColor() const;
800 
809  BOOL getFileBkColor(RGBQUAD *bkcolor) const;
810 
819  BOOL setFileBkColor(RGBQUAD *bkcolor);
821 
830  BOOL getChannel(fipImage& image, FREE_IMAGE_COLOR_CHANNEL channel) const;
831 
839  BOOL setChannel(fipImage& image, FREE_IMAGE_COLOR_CHANNEL channel);
840 
849  BOOL splitChannels(fipImage& RedChannel, fipImage& GreenChannel, fipImage& BlueChannel);
850 
858  BOOL combineChannels(fipImage& red, fipImage& green, fipImage& blue);
860 
874  BOOL rotateEx(double angle, double x_shift, double y_shift, double x_origin, double y_origin, BOOL use_mask);
875 
883  BOOL rotate(double angle, const void *bkcolor = NULL);
884 
890 
895  BOOL flipVertical();
897 
905  BOOL invert();
906 
920  BOOL adjustCurve(BYTE *LUT, FREE_IMAGE_COLOR_CHANNEL channel);
921 
928  BOOL adjustGamma(double gamma);
929 
937  BOOL adjustBrightness(double percentage);
938 
946  BOOL adjustContrast(double percentage);
947 
958  BOOL adjustBrightnessContrastGamma(double brightness, double contrast, double gamma);
959 
970  BOOL getHistogram(DWORD *histo, FREE_IMAGE_COLOR_CHANNEL channel = FICC_BLACK) const;
972 
975 
984  BOOL rescale(unsigned new_width, unsigned new_height, FREE_IMAGE_FILTER filter);
985 
993  BOOL makeThumbnail(unsigned max_size, BOOL convert = TRUE);
995 
1005  void setModified(BOOL bStatus = TRUE) {
1006  _bHasChanged = bStatus;
1007  }
1008 
1014  BOOL isModified() {
1015  return _bHasChanged;
1016  }
1018 
1026  unsigned getMetadataCount(FREE_IMAGE_MDMODEL model) const;
1035  BOOL getMetadata(FREE_IMAGE_MDMODEL model, const char *key, fipTag& tag) const;
1055  BOOL setMetadata(FREE_IMAGE_MDMODEL model, const char *key, fipTag& tag);
1056 
1062 
1063  protected:
1066  BOOL replace(FIBITMAP *new_dib);
1068 
1069 };
1070 
1071 // ----------------------------------------------------------
1072 
1084 #ifdef _WIN32
1085 
1086 class FIP_API fipWinImage : public fipImage
1087 {
1088 public:
1092  fipWinImage(FREE_IMAGE_TYPE image_type = FIT_BITMAP, unsigned width = 0, unsigned height = 0, unsigned bpp = 0);
1093 
1095  virtual ~fipWinImage();
1096 
1098  virtual void clear();
1099 
1101  BOOL isValid() const;
1103 
1106 
1114 
1122 
1129  HANDLE copyToHandle() const;
1130 
1137  BOOL copyFromHandle(HANDLE hMem);
1138 
1143  BOOL copyFromBitmap(HBITMAP hbmp);
1145 
1154  BOOL copyToClipboard(HWND hWndNewOwner) const;
1155 
1162 
1170  BOOL captureWindow(HWND hWndApplicationWindow, HWND hWndSelectedWindow);
1172 
1173 
1176 
1185  void draw(HDC hDC, RECT& rcDest) const {
1186  drawEx(hDC, rcDest, FALSE, NULL, NULL);
1187  }
1188 
1206  void drawEx(HDC hDC, RECT& rcDest, BOOL useFileBkg = FALSE, RGBQUAD *appBkColor = NULL, FIBITMAP *bg = NULL) const;
1207 
1218  void setToneMappingOperator(FREE_IMAGE_TMO tmo, double first_param = 0, double second_param = 0, double third_param = 1, double fourth_param = 0);
1219 
1229  void getToneMappingOperator(FREE_IMAGE_TMO *tmo, double *first_param, double *second_param, double *third_param, double *fourth_param) const;
1230 
1232 
1233 protected:
1235  mutable FIBITMAP *_display_dib;
1237  mutable BOOL _bDeleteMe;
1239  FREE_IMAGE_TMO _tmo;
1248 };
1249 
1250 #endif // _WIN32
1251 
1252 // ----------------------------------------------------------
1253 
1260 class FIP_API fipMemoryIO : public fipObject
1261 {
1262 protected:
1264  FIMEMORY *_hmem;
1265 
1266 public :
1276  fipMemoryIO(BYTE *data = NULL, DWORD size_in_bytes = 0);
1277 
1282  virtual ~fipMemoryIO();
1283 
1288  void close();
1289 
1292  BOOL isValid() const;
1293 
1297  FREE_IMAGE_FORMAT getFileType() const;
1298 
1303  operator FIMEMORY*() {
1304  return _hmem;
1305  }
1306 
1316  FIBITMAP* load(FREE_IMAGE_FORMAT fif, int flags = 0) const;
1324  FIMULTIBITMAP* loadMultiPage(FREE_IMAGE_FORMAT fif, int flags = 0) const;
1333  BOOL save(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, int flags = 0);
1342  BOOL saveMultiPage(FREE_IMAGE_FORMAT fif, FIMULTIBITMAP *bitmap, int flags = 0);
1351  unsigned read(void *buffer, unsigned size, unsigned count) const;
1360  unsigned write(const void *buffer, unsigned size, unsigned count);
1365  long tell() const;
1370  BOOL seek(long offset, int origin);
1377  BOOL acquire(BYTE **data, DWORD *size_in_bytes);
1379 
1380 private:
1382  fipMemoryIO(const fipMemoryIO& src);
1384  fipMemoryIO& operator=(const fipMemoryIO& src);
1385 
1386 };
1387 
1388 // ----------------------------------------------------------
1389 
1395 class FIP_API fipMultiPage : public fipObject
1396 {
1397 protected:
1399  FIMULTIBITMAP *_mpage;
1402 
1403 public:
1408  fipMultiPage(BOOL keep_cache_in_memory = FALSE);
1409 
1414  virtual ~fipMultiPage();
1415 
1417  BOOL isValid() const;
1418 
1423  operator FIMULTIBITMAP*() {
1424  return _mpage;
1425  }
1426 
1436  BOOL open(const char* lpszPathName, BOOL create_new, BOOL read_only, int flags = 0);
1437 
1445  BOOL open(fipMemoryIO& memIO, int flags = 0);
1446 
1455  BOOL open(FreeImageIO *io, fi_handle handle, int flags = 0);
1456 
1463  BOOL close(int flags = 0);
1464 
1474  BOOL saveToHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flags = 0) const;
1475 
1484  BOOL saveToMemory(FREE_IMAGE_FORMAT fif, fipMemoryIO& memIO, int flags = 0) const;
1485 
1490  int getPageCount() const;
1491 
1497  void appendPage(fipImage& image);
1498 
1505  void insertPage(int page, fipImage& image);
1506 
1512  void deletePage(int page);
1513 
1521  BOOL movePage(int target, int source);
1522 
1540  FIBITMAP* lockPage(int page);
1541 
1548  void unlockPage(fipImage& image, BOOL changed);
1549 
1558  BOOL getLockedPageNumbers(int *pages, int *count) const;
1559 };
1560 
1561 // ----------------------------------------------------------
1562 
1568 class FIP_API fipTag : public fipObject
1569 {
1570 protected:
1572  FITAG *_tag;
1573 
1574 public:
1586  virtual ~fipTag();
1595  BOOL setKeyValue(const char *key, const char *value);
1596 
1598 
1605  fipTag(const fipTag& tag);
1610  fipTag& operator=(const fipTag& tag);
1616  fipTag& operator=(FITAG *tag);
1618 
1624  operator FITAG*() {
1625  return _tag;
1626  }
1627 
1629  BOOL isValid() const;
1630 
1637  const char *getKey() const;
1642  const char *getDescription() const;
1647  WORD getID() const;
1652  FREE_IMAGE_MDTYPE getType() const;
1657  DWORD getCount() const;
1662  DWORD getLength() const;
1667  const void *getValue() const;
1673  BOOL setKey(const char *key);
1679  BOOL setDescription(const char *description);
1685  BOOL setID(WORD id);
1691  BOOL setType(FREE_IMAGE_MDTYPE type);
1697  BOOL setCount(DWORD count);
1703  BOOL setLength(DWORD length);
1709  BOOL setValue(const void *value);
1710 
1712 
1718  const char* toString(FREE_IMAGE_MDMODEL model, char *Make = NULL) const;
1719 
1720 };
1721 
1748 class FIP_API fipMetadataFind : public fipObject
1749 {
1750 protected:
1752  FIMETADATA *_mdhandle;
1753 
1754 public:
1756  BOOL isValid() const;
1757 
1764  virtual ~fipMetadataFind();
1774  BOOL findFirstMetadata(FREE_IMAGE_MDMODEL model, fipImage& image, fipTag& tag);
1783 
1784 };
1785 
1786 #endif // FREEIMAGEPLUS_H
A class used to manage all photo related images and all image types used by the library.
Definition: FreeImagePlus.h:104
unsigned getBitsPerPixel() const
Returns the bitdepth of the bitmap.
BOOL hasFileBkColor() const
Returns TRUE when the image has a file background color, FALSE otherwise.
FIBITMAP * _dib
DIB data.
Definition: FreeImagePlus.h:107
const BITMAPINFOHEADER * getInfoHeader() const
Returns a pointer to the bitmap's BITMAPINFOHEADER.
BOOL combineChannels(fipImage &red, fipImage &green, fipImage &blue)
Builds a 24-bit RGB image given its red, green and blue channel.
fipImage(const fipImage &src)
Copy constructor.
unsigned getImageMemorySize() const
Returns the memory footprint of a bitmap, in bytes.
void clearMetadata()
Clear all metadata contained in the dib.
BOOL makeThumbnail(unsigned max_size, BOOL convert=TRUE)
Creates a thumbnail image keeping aspect ratio.
BOOL clearThumbnail()
Clear the thumbnail possibly attached to the bitmap.
BOOL setFileBkColor(RGBQUAD *bkcolor)
Set the file background color of an image.
BOOL save(const char *lpszPathName, int flag=0)
Saves an image to disk, given its file name and an optional flag.
BOOL getFileBkColor(RGBQUAD *bkcolor) const
Retrieves the file background color of an image.
BOOL loadU(FREE_IMAGE_FORMAT fif, const wchar_t *lpszPathName, int flag=0)
UNICODE version of load (this function only works under WIN32 and does nothing on other OS)
BOOL splitChannels(fipImage &RedChannel, fipImage &GreenChannel, fipImage &BlueChannel)
Split a 24-bit RGB image into 3 greyscale images corresponding to the red, green and blue channels.
BYTE * accessPixels() const
Returns a pointer to the bitmap bits.
BOOL dither(FREE_IMAGE_DITHER algorithm)
Converts a 8-bit image to a monochrome 1-bit image using a dithering algorithm.
BOOL getMetadata(FREE_IMAGE_MDMODEL model, const char *key, fipTag &tag) const
Retrieve a metadata attached to the dib.
BOOL getChannel(fipImage &image, FREE_IMAGE_COLOR_CHANNEL channel) const
Retrieves the red, green, blue or alpha channel of a 24- or 32-bit BGR[A] image.
BOOL convertTo32Bits()
Converts the bitmap to 32 bits.
BOOL rescale(unsigned new_width, unsigned new_height, FREE_IMAGE_FILTER filter)
Rescale the image to a new width / height.
const BITMAPINFO * getInfo() const
Returns a pointer to the bitmap's BITMAPINFO header.
unsigned getScanWidth() const
Returns the width of the bitmap in bytes rounded to the nearest DWORD.
unsigned getMetadataCount(FREE_IMAGE_MDMODEL model) const
Returns the number of tags contained in the model metadata model attached to the dib.
BOOL getPixelIndex(unsigned x, unsigned y, BYTE *value) const
Get the pixel index of a 1-, 4- or 8-bit palettized image at position (x, y), including range check (...
FREE_IMAGE_FORMAT getFIF() const
Return the original (or last saved) fif format if available, returns FIF_UNKNOWN otherwise.
static FREE_IMAGE_FORMAT identifyFIFU(const wchar_t *lpszPathName)
UNICODE version of identifyFIF (this function only works under WIN32 and does nothing on other OS)
unsigned getPaletteSize() const
Returns the palette size in bytes.
BOOL convertToUINT16()
Converts the bitmap to a 16-bit unsigned short image.
BOOL loadFromMemory(FREE_IMAGE_FORMAT fif, fipMemoryIO &memIO, int flag=0)
Loads an image using the specified fif and memory stream and an optional flag.
BOOL pasteSubImage(fipImage &src, int left, int top, int alpha=256)
BOOL isGrayscale() const
Returns TRUE if the bitmap is a 8-bit bitmap with a greyscale palette, FALSE otherwise.
BOOL load(const char *lpszPathName, int flag=0)
Loads an image from disk, given its file name and an optional flag.
BOOL save(FREE_IMAGE_FORMAT fif, const char *lpszPathName, int flag=0)
Saves an image to disk, given its format, file name and an optional flag.
BOOL convertTo8Bits()
Converts the bitmap to 8 bits.
BOOL colorQuantize(FREE_IMAGE_QUANTIZE algorithm)
Quantizes a full colour 24-bit bitmap to a palletised 8-bit bitmap.
BOOL isValid() const
Returns TRUE if the image is allocated, FALSE otherwise.
void setHorizontalResolution(double value)
set the bitmap resolution along the X axis, in pixels / cm
BOOL setPixelColor(unsigned x, unsigned y, RGBQUAD *value)
Set the pixel color of a 16-, 24- or 32-bit image at position (x, y), including range check (slow acc...
BOOL crop(int left, int top, int right, int bottom)
Crop a sub part of the current image and update it accordingly.
BOOL toneMapping(FREE_IMAGE_TMO tmo, double first_param=0, double second_param=0, double third_param=1, double fourth_param=0)
Converts a High Dynamic Range image (48-bit RGB or 96-bit RGB Float) to a 24-bit RGB image.
BOOL convertToType(FREE_IMAGE_TYPE image_type, BOOL scale_linear=TRUE)
Converts an image to a type supported by FreeImage.
BOOL flipVertical()
Flip the image vertically along the horizontal axis.
BOOL setThumbnail(const fipImage &image)
Attach a thumbnail to the bitmap.
double getHorizontalResolution() const
Returns the bitmap resolution along the X axis, in pixels / cm.
BOOL loadU(const wchar_t *lpszPathName, int flag=0)
UNICODE version of load (this function only works under WIN32 and does nothing on other OS)
BOOL getHistogram(DWORD *histo, FREE_IMAGE_COLOR_CHANNEL channel=FICC_BLACK) const
Computes image histogram.
BYTE * getTransparencyTable() const
8-bit transparency : get the bitmap’s transparency table.
unsigned getHeight() const
Returns the image height in pixels.
virtual ~fipImage()
Destructor.
BOOL setSize(FREE_IMAGE_TYPE image_type, unsigned width, unsigned height, unsigned bpp, unsigned red_mask=0, unsigned green_mask=0, unsigned blue_mask=0)
Image allocator.
void setTransparencyTable(BYTE *table, int count)
8-bit transparency : set the bitmap’s transparency table.
virtual void clear()
Destroy image data.
static FREE_IMAGE_FORMAT identifyFIFFromMemory(FIMEMORY *hmem)
Identifies an image using the specified memory stream.
FREE_IMAGE_TYPE getImageType() const
Returns the data type of the image.
BOOL setPixelIndex(unsigned x, unsigned y, BYTE *value)
Set the pixel index of a 1-, 4- or 8-bit palettized image at position (x, y), including range check (...
BOOL adjustGamma(double gamma)
Performs gamma correction on a 8, 24 or 32-bit image.
BYTE * getScanLine(unsigned scanline) const
Returns a pointer to the start of the given scanline in the bitmap’s data-bits.
BOOL convertToGrayscale()
Converts the bitmap to 8 bits.
void setVerticalResolution(double value)
set the bitmap resolution along the Y axis, in pixels / cm
BOOL convertTo4Bits()
Converts the bitmap to 4 bits.
BOOL convertToRGBA16()
Converts the bitmap to a 64-bit RGBA16 image.
BOOL hasThumbnail() const
Check if the image has an embedded thumbnail.
BOOL copySubImage(fipImage &dst, int left, int top, int right, int bottom) const
Copy a sub part of the current image and returns it as a fipImage object.
BOOL flipHorizontal()
Flip the image horizontally along the vertical axis.
static FREE_IMAGE_FORMAT identifyFIFFromHandle(FreeImageIO *io, fi_handle handle)
Identifies an image using the specified FreeImageIO struct and fi_handle.
double getVerticalResolution() const
Returns the bitmap resolution along the Y axis, in pixels / cm.
BOOL _bHasChanged
TRUE whenever the display need to be refreshed.
Definition: FreeImagePlus.h:111
unsigned getTransparencyCount() const
8-bit transparency : get the number of transparent colors.
unsigned getImageSize() const
Returns the size of the bitmap in bytes.
BOOL rotate(double angle, const void *bkcolor=NULL)
Image rotation by means of three shears.
BOOL convertToRGBF()
Converts the bitmap to a 96-bit RGBF image.
BOOL threshold(BYTE T)
Converts the bitmap to 1 bit using a threshold T.
void setModified(BOOL bStatus=TRUE)
Set the image status as 'modified'.
Definition: FreeImagePlus.h:1005
fipImage & operator=(FIBITMAP *dib)
Assignement operator Copy the input pointer and manage its destruction
BOOL getPixelColor(unsigned x, unsigned y, RGBQUAD *value) const
Get the pixel color of a 16-, 24- or 32-bit image at position (x, y), including range check (slow acc...
BOOL convertToFloat()
Converts the bitmap to a 32-bit float image.
static FREE_IMAGE_FORMAT identifyFIF(const char *lpszPathName)
Identifies an image from disk, given its file name.
BOOL loadFromHandle(FreeImageIO *io, fi_handle handle, int flag=0)
Loads an image using the specified FreeImageIO struct and fi_handle, and an optional flag.
BOOL adjustBrightnessContrastGamma(double brightness, double contrast, double gamma)
Adjusts an image's brightness, contrast and gamma within a single operation.
FREE_IMAGE_FORMAT _fif
Original (or last saved) fif format if available, FIF_UNKNOWN otherwise.
Definition: FreeImagePlus.h:109
fipImage(FREE_IMAGE_TYPE image_type=FIT_BITMAP, unsigned width=0, unsigned height=0, unsigned bpp=0)
Constructor.
BOOL setMetadata(FREE_IMAGE_MDMODEL model, const char *key, fipTag &tag)
Attach a new FreeImage tag to the dib.
BOOL getThumbnail(fipImage &image) const
Retrieves a copy the thumbnail possibly attached to the bitmap.
FREE_IMAGE_COLOR_TYPE getColorType() const
Investigates the colour type of the bitmap.
BOOL adjustCurve(BYTE *LUT, FREE_IMAGE_COLOR_CHANNEL channel)
Perfoms an histogram transformation on a 8, 24 or 32-bit image according to the values of a lookup ta...
BOOL saveToMemory(FREE_IMAGE_FORMAT fif, fipMemoryIO &memIO, int flag=0)
Saves an image using the specified memory stream and an optional flag.
fipImage & operator=(const fipImage &src)
Copy constructor.
BOOL rotateEx(double angle, double x_shift, double y_shift, double x_origin, double y_origin, BOOL use_mask)
Image translation and rotation using B-Splines.
BOOL convertToRGBAF()
Converts the bitmap to a 128-bit RGBAF image.
BOOL adjustBrightness(double percentage)
Adjusts the brightness of a 8, 24 or 32-bit image by a certain amount.
BOOL isModified()
Get the image status.
Definition: FreeImagePlus.h:1014
BOOL convertTo16Bits555()
Converts the bitmap to 16 bits.
BOOL adjustContrast(double percentage)
Adjusts the contrast of a 8, 24 or 32-bit image by a certain amount.
RGBQUAD * getPalette() const
Returns a pointer to the bitmap's palette.
BOOL convertTo24Bits()
Converts the bitmap to 24 bits.
BOOL load(FREE_IMAGE_FORMAT fif, const char *lpszPathName, int flag=0)
Loads an image from disk, given its format, file name and an optional flag.
unsigned getColorsUsed() const
Retrieves the number of colours used in the bitmap.
unsigned getWidth() const
Returns the image width in pixels.
BOOL convertToRGB16()
Converts the bitmap to a 48-bit RGB16 image.
BOOL createView(fipImage &dynamicView, unsigned left, unsigned top, unsigned right, unsigned bottom)
Returns a reference (a.k.a.
BOOL convertTo16Bits565()
Converts the bitmap to 16 bits.
BOOL saveToHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flag=0)
Saves an image using the specified FreeImageIO struct and fi_handle, and an optional flag.
BOOL isTransparent() const
Returns TRUE if the image is transparent, returns FALSE otherwise.
BOOL setChannel(fipImage &image, FREE_IMAGE_COLOR_CHANNEL channel)
Insert a 8-bit dib into a 24- or 32-bit image.
unsigned getLine() const
Returns the width of the bitmap in bytes.
BOOL invert()
Inverts each pixel data.
BOOL saveU(const wchar_t *lpszPathName, int flag=0)
UNICODE version of save (this function only works under WIN32 and does nothing on other OS)
BOOL saveU(FREE_IMAGE_FORMAT fif, const wchar_t *lpszPathName, int flag=0)
UNICODE version of save (this function only works under WIN32 and does nothing on other OS)
BOOL loadFromMemory(fipMemoryIO &memIO, int flag=0)
Loads an image using the specified memory stream and an optional flag.
Memory handle.
Definition: FreeImagePlus.h:1261
FIMULTIBITMAP * loadMultiPage(FREE_IMAGE_FORMAT fif, int flags=0) const
Loads a multi-page bitmap from a memory stream.
FIMEMORY * _hmem
Pointer to a memory stream.
Definition: FreeImagePlus.h:1264
BOOL seek(long offset, int origin)
Moves the memory pointer to a specified location.
virtual ~fipMemoryIO()
Destructor.
FREE_IMAGE_FORMAT getFileType() const
Returns the buffer image format.
unsigned read(void *buffer, unsigned size, unsigned count) const
Reads data from a memory stream.
BOOL isValid() const
Returns TRUE if the internal memory buffer is a valid buffer, returns FALSE otherwise.
void close()
Destructor.
long tell() const
Gets the current position of a memory pointer.
BOOL save(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, int flags=0)
Saves a dib to a memory stream.
unsigned write(const void *buffer, unsigned size, unsigned count)
Writes data to a memory stream.
BOOL saveMultiPage(FREE_IMAGE_FORMAT fif, FIMULTIBITMAP *bitmap, int flags=0)
Saves a multi-page bitmap to a memory stream.
FIBITMAP * load(FREE_IMAGE_FORMAT fif, int flags=0) const
Loads a dib from a memory stream.
fipMemoryIO(BYTE *data=NULL, DWORD size_in_bytes=0)
Constructor.
BOOL acquire(BYTE **data, DWORD *size_in_bytes)
Provides a direct buffer access to a memory stream.
Metadata iterator.
Definition: FreeImagePlus.h:1749
virtual ~fipMetadataFind()
Destructor.
BOOL findNextMetadata(fipTag &tag)
Find the next tag, if any, that matches the metadata model argument in a previous call to findFirstMe...
FIMETADATA * _mdhandle
Pointer to a search handle.
Definition: FreeImagePlus.h:1752
fipMetadataFind()
Constructor.
BOOL findFirstMetadata(FREE_IMAGE_MDMODEL model, fipImage &image, fipTag &tag)
Provides information about the first instance of a tag that matches the metadata model specified in t...
BOOL isValid() const
Returns TRUE if the search handle is allocated, FALSE otherwise.
Multi-page file stream.
Definition: FreeImagePlus.h:1396
void unlockPage(fipImage &image, BOOL changed)
Unlocks a previously locked page and gives it back to the multi-page engine.
BOOL saveToMemory(FREE_IMAGE_FORMAT fif, fipMemoryIO &memIO, int flags=0) const
Saves a multi-page image using the specified memory stream and an optional flag.
BOOL open(FreeImageIO *io, fi_handle handle, int flags=0)
Open a multi-page image as read/write, using the specified FreeImageIO struct and fi_handle,...
FIBITMAP * lockPage(int page)
Locks a page in memory for editing.
void appendPage(fipImage &image)
Appends a new page to the end of the bitmap.
BOOL open(fipMemoryIO &memIO, int flags=0)
Open a multi-page memory stream as read/write.
virtual ~fipMultiPage()
Destructor Close the file stream if not already done.
void deletePage(int page)
Deletes the page on the given position.
BOOL saveToHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flags=0) const
Saves a multi-page image using the specified FreeImageIO struct and fi_handle, and an optional flag.
fipMultiPage(BOOL keep_cache_in_memory=FALSE)
Constructor.
BOOL close(int flags=0)
Close a file stream.
BOOL _bMemoryCache
TRUE when using a memory cache, FALSE otherwise.
Definition: FreeImagePlus.h:1401
int getPageCount() const
Returns the number of pages currently available in the multi-paged bitmap.
BOOL getLockedPageNumbers(int *pages, int *count) const
Returns an array of page-numbers that are currently locked in memory.
BOOL isValid() const
Returns TRUE if the multi-page stream is opened.
BOOL open(const char *lpszPathName, BOOL create_new, BOOL read_only, int flags=0)
Open a multi-page file stream.
BOOL movePage(int target, int source)
Moves the source page to the position of the target page.
FIMULTIBITMAP * _mpage
Pointer to a multi-page file stream.
Definition: FreeImagePlus.h:1399
void insertPage(int page, fipImage &image)
Inserts a new page before the given position in the bitmap.
Abstract base class for all objects used by the library.
Definition: FreeImagePlus.h:77
virtual BOOL isValid() const =0
Returns TRUE if the object is allocated, FALSE otherwise.
virtual ~fipObject()
Destructor.
Definition: FreeImagePlus.h:80
FreeImage Tag.
Definition: FreeImagePlus.h:1569
virtual ~fipTag()
Destructor.
BOOL setType(FREE_IMAGE_MDTYPE type)
Set the tag data type.
DWORD getLength() const
Returns the length of the tag value in bytes.
WORD getID() const
Returns the tag ID if available, returns 0 otherwise.
const char * getKey() const
Returns the tag field name (unique inside a metadata model).
BOOL setDescription(const char *description)
Set the (usually optional) tag description.
BOOL setKeyValue(const char *key, const char *value)
Construct a FIDT_ASCII tag (ASCII string).
fipTag()
Constructor.
FITAG * _tag
Pointer to a FreeImage tag.
Definition: FreeImagePlus.h:1572
const char * getDescription() const
Returns the tag description if available, returns NULL otherwise.
fipTag & operator=(const fipTag &tag)
Copy constructor.
BOOL setID(WORD id)
Set the (usually optional) tad ID.
BOOL setKey(const char *key)
Set the tag field name.
fipTag & operator=(FITAG *tag)
Assignement operator Copy the input pointer and manage its destruction
fipTag(const fipTag &tag)
Copy constructor.
BOOL setValue(const void *value)
Set the tag value.
BOOL setLength(DWORD length)
Set the length of the tag value, in bytes.
const void * getValue() const
Returns the tag value.
BOOL setCount(DWORD count)
Set the number of data in the tag.
FREE_IMAGE_MDTYPE getType() const
Returns the tag data type.
BOOL isValid() const
Returns TRUE if the tag is allocated, FALSE otherwise.
DWORD getCount() const
Returns the number of components in the tag (in tag type units)
const char * toString(FREE_IMAGE_MDMODEL model, char *Make=NULL) const
Converts a FreeImage tag structure to a string that represents the interpreted tag value.
A class designed for MS Windows (TM) platforms.
Definition: FreeImagePlus.h:1087
FIBITMAP * _display_dib
DIB used for display (this allow to display non-standard bitmaps)
Definition: FreeImagePlus.h:1235
void drawEx(HDC hDC, RECT &rcDest, BOOL useFileBkg=FALSE, RGBQUAD *appBkColor=NULL, FIBITMAP *bg=NULL) const
Draw (stretch) the image on a HDC, using StretchDIBits.
virtual void clear()
Destroy image data.
void getToneMappingOperator(FREE_IMAGE_TMO *tmo, double *first_param, double *second_param, double *third_param, double *fourth_param) const
Get the tone mapping algorithm used for drawing, with its parameters.
fipWinImage & operator=(const fipImage &src)
Copy constructor.
virtual ~fipWinImage()
Destructor.
double _tmo_param_3
third tone mapping algorithm parameter
Definition: FreeImagePlus.h:1245
void draw(HDC hDC, RECT &rcDest) const
Draw (stretch) the image on a HDC, using StretchDIBits.
Definition: FreeImagePlus.h:1185
FREE_IMAGE_TMO _tmo
tone mapping operator
Definition: FreeImagePlus.h:1239
double _tmo_param_2
second tone mapping algorithm parameter
Definition: FreeImagePlus.h:1243
BOOL copyFromBitmap(HBITMAP hbmp)
Copy constructor.
HANDLE copyToHandle() const
Clone function used for clipboard copy.
double _tmo_param_1
first tone mapping algorithm parameter
Definition: FreeImagePlus.h:1241
BOOL captureWindow(HWND hWndApplicationWindow, HWND hWndSelectedWindow)
Capture a window and convert it to an image.
double _tmo_param_4
fourth tone mapping algorithm parameter
Definition: FreeImagePlus.h:1247
BOOL copyToClipboard(HWND hWndNewOwner) const
Clipboard copy.
BOOL _bDeleteMe
remember to delete _display_dib
Definition: FreeImagePlus.h:1237
BOOL pasteFromClipboard()
Retrieves data from the clipboard.
BOOL copyFromHandle(HANDLE hMem)
Copy constructor used for clipboard paste.
BOOL isValid() const
Returns TRUE if the image is allocated, FALSE otherwise.
fipWinImage(FREE_IMAGE_TYPE image_type=FIT_BITMAP, unsigned width=0, unsigned height=0, unsigned bpp=0)
Constructor.
void setToneMappingOperator(FREE_IMAGE_TMO tmo, double first_param=0, double second_param=0, double third_param=1, double fourth_param=0)
Select a tone mapping algorithm used for drawing and set the image as modified so that the display wi...
fipWinImage & operator=(const fipWinImage &src)
Copy constructor Delete internal _display_dib data and copy tone mapping parameters.
Definition: FreeImage.h:210
Definition: FreeImage.h:224
Definition: FreeImage.h:179