fipWinImage Class Reference

A class designed for MS Windows (TM) platforms. More...

`#include <FreeImagePlus.h>`

Inheritance diagram for fipWinImage:

## Public Member Functions

Creation & Destruction
| fipWinImage (FREE_IMAGE_TYPE image_type=FIT_BITMAP, unsigned width=0, unsigned height=0, unsigned bpp=0)
| Constructor. More...
virtual | ~fipWinImage ()
| Destructor. More...
virtual void | clear ()
| Destroy image data. More...
BOOL | isValid () const
| Returns TRUE if the image is allocated, FALSE otherwise. More...
Copying
fipWinImage & | operator= (const fipImage &src)
| Copy constructor. More...
fipWinImage & | operator= (const fipWinImage &src)
| Copy constructor Delete internal _display_dib data and copy tone mapping parameters. More...
HANDLE | copyToHandle () const
| Clone function used for clipboard copy. More...
BOOL | copyFromHandle (HANDLE hMem)
| Copy constructor used for clipboard paste. More...
BOOL | copyFromBitmap (HBITMAP hbmp)
| Copy constructor. More...
Clipboard operations
BOOL | copyToClipboard (HWND hWndNewOwner) const
| Clipboard copy. More...
BOOL | pasteFromClipboard ()
| Retrieves data from the clipboard. More...
Screen capture
BOOL | captureWindow (HWND hWndApplicationWindow, HWND hWndSelectedWindow)
| Capture a window and convert it to an image. More...
Public Member Functions inherited from fipImage
| fipImage (FREE_IMAGE_TYPE image_type=FIT_BITMAP, unsigned width=0, unsigned height=0, unsigned bpp=0)
| Constructor. More...
virtual | ~fipImage ()
| Destructor. More...
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. More...
| fipImage (const fipImage &src)
| Copy constructor. More...
fipImage & | operator= (const fipImage &src)
| Copy constructor. More...
fipImage & | operator= (FIBITMAP *dib)
| Assignement operator Copy the input pointer and manage its destruction More...
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. More...
BOOL | pasteSubImage (fipImage &src, int left, int top, int alpha=256)
BOOL | crop (int left, int top, int right, int bottom)
| Crop a sub part of the current image and update it accordingly. More...
BOOL | createView (fipImage &dynamicView, unsigned left, unsigned top, unsigned right, unsigned bottom)
| Returns a reference (a.k.a. More...
BOOL | load (const char *lpszPathName, int flag=0)
| Loads an image from disk, given its file name and an optional flag. More...
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. More...
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) More...
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) More...
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. More...
BOOL | loadFromMemory (fipMemoryIO &memIO, int flag=0)
| Loads an image using the specified memory stream and an optional flag. More...
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. More...
BOOL | save (const char *lpszPathName, int flag=0)
| Saves an image to disk, given its file name and an optional flag. More...
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. More...
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) More...
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) More...
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. More...
BOOL | saveToMemory (FREE_IMAGE_FORMAT fif, fipMemoryIO &memIO, int flag=0)
| Saves an image using the specified memory stream and an optional flag. More...
FREE_IMAGE_TYPE | getImageType () const
| Returns the data type of the image. More...
FREE_IMAGE_FORMAT | getFIF () const
| Return the original (or last saved) fif format if available, returns FIF_UNKNOWN otherwise. More...
unsigned | getWidth () const
| Returns the image width in pixels. More...
unsigned | getHeight () const
| Returns the image height in pixels. More...
unsigned | getScanWidth () const
| Returns the width of the bitmap in bytes rounded to the nearest DWORD. More...
| operator FIBITMAP * ()
| Returns a pointer to the FIBITMAP data. More...
const BITMAPINFO * | getInfo () const
| Returns a pointer to the bitmap's BITMAPINFO header. More...
const BITMAPINFOHEADER * | getInfoHeader () const
| Returns a pointer to the bitmap's BITMAPINFOHEADER. More...
unsigned | getImageSize () const
| Returns the size of the bitmap in bytes. More...
unsigned | getImageMemorySize () const
| Returns the memory footprint of a bitmap, in bytes. More...
unsigned | getBitsPerPixel () const
| Returns the bitdepth of the bitmap. More...
unsigned | getLine () const
| Returns the width of the bitmap in bytes. More...
double | getHorizontalResolution () const
| Returns the bitmap resolution along the X axis, in pixels / cm. More...
double | getVerticalResolution () const
| Returns the bitmap resolution along the Y axis, in pixels / cm. More...
void | setHorizontalResolution (double value)
| set the bitmap resolution along the X axis, in pixels / cm More...
void | setVerticalResolution (double value)
| set the bitmap resolution along the Y axis, in pixels / cm More...
RGBQUAD * | getPalette () const
| Returns a pointer to the bitmap's palette. More...
unsigned | getPaletteSize () const
| Returns the palette size in bytes. More...
unsigned | getColorsUsed () const
| Retrieves the number of colours used in the bitmap. More...
FREE_IMAGE_COLOR_TYPE | getColorType () const
| Investigates the colour type of the bitmap. More...
BOOL | isGrayscale () const
| Returns TRUE if the bitmap is a 8-bit bitmap with a greyscale palette, FALSE otherwise. More...
BOOL | getThumbnail (fipImage &image) const
| Retrieves a copy the thumbnail possibly attached to the bitmap. More...
BOOL | setThumbnail (const fipImage &image)
| Attach a thumbnail to the bitmap. More...
BOOL | hasThumbnail () const
| Check if the image has an embedded thumbnail. More...
BOOL | clearThumbnail ()
| Clear the thumbnail possibly attached to the bitmap. More...
BYTE * | accessPixels () const
| Returns a pointer to the bitmap bits. More...
BYTE * | getScanLine (unsigned scanline) const
| Returns a pointer to the start of the given scanline in the bitmap’s data-bits. More...
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 (slow access). More...
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 access). More...
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 (slow access). More...
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 access). More...
BOOL | convertToType (FREE_IMAGE_TYPE image_type, BOOL scale_linear=TRUE)
| Converts an image to a type supported by FreeImage. More...
BOOL | threshold (BYTE T)
| Converts the bitmap to 1 bit using a threshold T. More...
BOOL | dither (FREE_IMAGE_DITHER algorithm)
| Converts a 8-bit image to a monochrome 1-bit image using a dithering algorithm. More...
BOOL | convertTo4Bits ()
| Converts the bitmap to 4 bits. More...
BOOL | convertTo8Bits ()
| Converts the bitmap to 8 bits. More...
BOOL | convertToGrayscale ()
| Converts the bitmap to 8 bits. More...
BOOL | colorQuantize (FREE_IMAGE_QUANTIZE algorithm)
| Quantizes a full colour 24-bit bitmap to a palletised 8-bit bitmap. More...
BOOL | convertTo16Bits555 ()
| Converts the bitmap to 16 bits. More...
BOOL | convertTo16Bits565 ()
| Converts the bitmap to 16 bits. More...
BOOL | convertTo24Bits ()
| Converts the bitmap to 24 bits. More...
BOOL | convertTo32Bits ()
| Converts the bitmap to 32 bits. More...
BOOL | convertToFloat ()
| Converts the bitmap to a 32-bit float image. More...
BOOL | convertToRGBF ()
| Converts the bitmap to a 96-bit RGBF image. More...
BOOL | convertToRGBAF ()
| Converts the bitmap to a 128-bit RGBAF image. More...
BOOL | convertToUINT16 ()
| Converts the bitmap to a 16-bit unsigned short image. More...
BOOL | convertToRGB16 ()
| Converts the bitmap to a 48-bit RGB16 image. More...
BOOL | convertToRGBA16 ()
| Converts the bitmap to a 64-bit RGBA16 image. More...
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. More...
BOOL | isTransparent () const
| Returns TRUE if the image is transparent, returns FALSE otherwise. More...
unsigned | getTransparencyCount () const
| 8-bit transparency : get the number of transparent colors. More...
BYTE * | getTransparencyTable () const
| 8-bit transparency : get the bitmap’s transparency table. More...
void | setTransparencyTable (BYTE *table, int count)
| 8-bit transparency : set the bitmap’s transparency table. More...
BOOL | hasFileBkColor () const
| Returns TRUE when the image has a file background color, FALSE otherwise. More...
BOOL | getFileBkColor (RGBQUAD *bkcolor) const
| Retrieves the file background color of an image. More...
BOOL | setFileBkColor (RGBQUAD *bkcolor)
| Set the file background color of an image. More...
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. More...
BOOL | setChannel (fipImage &image, FREE_IMAGE_COLOR_CHANNEL channel)
| Insert a 8-bit dib into a 24- or 32-bit image. More...
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. More...
BOOL | combineChannels (fipImage &red, fipImage &green, fipImage &blue)
| Builds a 24-bit RGB image given its red, green and blue channel. More...
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. More...
BOOL | rotate (double angle, const void *bkcolor=NULL)
| Image rotation by means of three shears. More...
BOOL | flipHorizontal ()
| Flip the image horizontally along the vertical axis. More...
BOOL | flipVertical ()
| Flip the image vertically along the horizontal axis. More...
BOOL | invert ()
| Inverts each pixel data. More...
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 table (LUT). More...
BOOL | adjustGamma (double gamma)
| Performs gamma correction on a 8, 24 or 32-bit image. More...
BOOL | adjustBrightness (double percentage)
| Adjusts the brightness of a 8, 24 or 32-bit image by a certain amount. More...
BOOL | adjustContrast (double percentage)
| Adjusts the contrast of a 8, 24 or 32-bit image by a certain amount. More...
BOOL | adjustBrightnessContrastGamma (double brightness, double contrast, double gamma)
| Adjusts an image's brightness, contrast and gamma within a single operation. More...
BOOL | getHistogram (DWORD *histo, FREE_IMAGE_COLOR_CHANNEL channel=FICC_BLACK) const
| Computes image histogram. More...
BOOL | rescale (unsigned new_width, unsigned new_height, FREE_IMAGE_FILTER filter)
| Rescale the image to a new width / height. More...
BOOL | makeThumbnail (unsigned max_size, BOOL convert=TRUE)
| Creates a thumbnail image keeping aspect ratio. More...
void | setModified (BOOL bStatus=TRUE)
| Set the image status as 'modified'. More...
BOOL | isModified ()
| Get the image status. More...
unsigned | getMetadataCount (FREE_IMAGE_MDMODEL model) const
| Returns the number of tags contained in the model metadata model attached to the dib. More...
BOOL | getMetadata (FREE_IMAGE_MDMODEL model, const char *key, fipTag &tag) const
| Retrieve a metadata attached to the dib. More...
BOOL | setMetadata (FREE_IMAGE_MDMODEL model, const char *key, fipTag &tag)
| Attach a new FreeImage tag to the dib. More...
void | clearMetadata ()
| Clear all metadata contained in the dib. More...
Public Member Functions inherited from fipObject
virtual | ~fipObject ()
| Destructor. More...

## Painting operations

FIBITMAP * | _display_dib
| DIB used for display (this allow to display non-standard bitmaps) More...
BOOL | _bDeleteMe
| remember to delete _display_dib More...
FREE_IMAGE_TMO | _tmo
| tone mapping operator More...
double | _tmo_param_1
| first tone mapping algorithm parameter More...
double | _tmo_param_2
| second tone mapping algorithm parameter More...
double | _tmo_param_3
| third tone mapping algorithm parameter More...
double | _tmo_param_4
| fourth tone mapping algorithm parameter More...
void | draw (HDC hDC, RECT &rcDest) const
| Draw (stretch) the image on a HDC, using StretchDIBits. More...
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. More...
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 will be refreshed. More...
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. More...

## Additional Inherited Members

Static Public Member Functions inherited from fipImage
static FREE_IMAGE_FORMAT | identifyFIF (const char *lpszPathName)
| Identifies an image from disk, given its file name. More...
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) More...
static FREE_IMAGE_FORMAT | identifyFIFFromHandle (FreeImageIO *io, fi_handle handle)
| Identifies an image using the specified FreeImageIO struct and fi_handle. More...
static FREE_IMAGE_FORMAT | identifyFIFFromMemory (FIMEMORY *hmem)
| Identifies an image using the specified memory stream. More...
Protected Member Functions inherited from fipImage
BOOL | replace (FIBITMAP *new_dib)
Protected Attributes inherited from fipImage
FIBITMAP * | _dib
| DIB data. More...
FREE_IMAGE_FORMAT | _fif
| Original (or last saved) fif format if available, FIF_UNKNOWN otherwise. More...
BOOL | _bHasChanged
| TRUE whenever the display need to be refreshed. More...

## Detailed Description

A class designed for MS Windows (TM) platforms.

fipWinImage provides methods used to :

- Display a DIB on the screen
- Copy / Paste a DIB to/from Windows devices (HANDLE, HBITMAP, Clipboard)
- Capture a window (HWND) and convert it to an image

Version
  FreeImage 3

Author
  Hervé Drolon

## Constructor & Destructor Documentation

## fipWinImage()

fipWinImage::fipWinImage | ( | FREE_IMAGE_TYPE | image_type = `FIT_BITMAP`,
|  | unsigned | width = `0`,
|  | unsigned | height = `0`,
|  | unsigned | bpp = `0`
| ) |  |

Constructor.

## ~fipWinImage()

virtual fipWinImage::~fipWinImage | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

## captureWindow()

BOOL fipWinImage::captureWindow | ( | HWND | hWndApplicationWindow,
|  | HWND | hWndSelectedWindow
| ) |  |

Capture a window and convert it to an image.

Parameters

  hWndApplicationWindow | Handle to the application main window
  hWndSelectedWindow | Handle to the window to be captured

Returns
  Returns TRUE if successful, returns FALSE otherwise

## clear()

virtual void fipWinImage::clear | ( |  | ) |

virtual

Destroy image data.

Reimplemented from fipImage.

## copyFromBitmap()

BOOL fipWinImage::copyFromBitmap | ( | HBITMAP | hbmp | ) |

Copy constructor.

Converts a HBITMAP object to a FIBITMAP.

Returns
  Returns TRUE if successful, returns FALSE otherwise

## copyFromHandle()

BOOL fipWinImage::copyFromHandle | ( | HANDLE | hMem | ) |

Copy constructor used for clipboard paste.

Converts a global object to a FIBITMAP. The clipboard format must be CF_DIB.
When the BITMAPINFOHEADER->biCompression field is set to 0xFF + [one of the predefined FREE_IMAGE_TYPE], the bitmap is recognized as non standard and correctly copied.

Returns
  Returns TRUE if successful, returns FALSE otherwise

## copyToClipboard()

BOOL fipWinImage::copyToClipboard | ( | HWND | hWndNewOwner | ) | const

Clipboard copy.

Parameters

  hWndNewOwner | Handle to the window to be associated with the open clipboard. In MFC, you can use AfxGetApp()->m_pMainWnd->GetSafeHwnd().

Returns
  Returns TRUE if successful, returns FALSE otherwise

## copyToHandle()

HANDLE fipWinImage::copyToHandle | ( |  | ) | const

Clone function used for clipboard copy.

Convert the FIBITMAP image to a DIB, and transfer the DIB in a global bitmap handle.
For non standard bitmaps, the BITMAPINFOHEADER->biCompression field is set to 0xFF + FreeImage_GetImageType(_dib), in order to recognize the bitmap as non standard.

## draw()

void fipWinImage::draw | ( | HDC | hDC,
|  | RECT & | rcDest
| ) |  | const

inline

Draw (stretch) the image on a HDC, using StretchDIBits.

When the image is transparent or has a file background, this function composite the foreground image against a checkerboard background image.

Parameters

  hDC | Handle to the device context
  rcDest | Destination rectangle

See also
  FreeImage_Composite

## drawEx()

void fipWinImage::drawEx | ( | HDC | hDC,
|  | RECT & | rcDest,
|  | BOOL | useFileBkg = `FALSE`,
|  | RGBQUAD * | appBkColor = `NULL`,
|  | FIBITMAP * | bg = `NULL`
| ) |  | const

Draw (stretch) the image on a HDC, using StretchDIBits.

When the image is transparent or has a file background, this function can composite the foreground image against a checkerboard background image, against a single background color or against a user background image.
When the image is a High Dynamic Range image (48-bit or RGB float), this function will apply a tone mapping operator before drawing the image.
The original image (located in the fipImage class) will not be affected by any of the operations that could be done in order to display it.

Parameters

  hDC | Handle to the device context
  rcDest | Destination rectangle
  useFileBkg | When set to TRUE, the function uses the file color background if there is one
  appBkColor | When a color is given, the function uses it as the background color
  bg | When a FIBITMAP is given, the function uses it as the background image

See also
  FreeImage_Composite
  setToneMappingOperator

## getToneMappingOperator()

void fipWinImage::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.

Parameters

  tmo | Tone mapping operator
  first_param | First tone mapping algorithm parameter
  second_param | Second tone mapping algorithm parameter
  third_param | Third tone mapping algorithm parameter
  fourth_param | Fourth tone mapping algorithm parameter

See also
  FreeImage_ToneMapping

## isValid()

BOOL fipWinImage::isValid | ( |  | ) | const

virtual

Returns TRUE if the image is allocated, FALSE otherwise.

Reimplemented from fipImage.

## operator=() [1/2]

fipWinImage & fipWinImage::operator= | ( | const fipImage & | src | ) |

Copy constructor.

Delete internal _display_dib data and copy the base class image data. Tone mapping parameters are left unchanged.

See also
  FreeImage_Clone

## operator=() [2/2]

fipWinImage & fipWinImage::operator= | ( | const fipWinImage & | src | ) |

Copy constructor Delete internal _display_dib data and copy tone mapping parameters.

Copy also the base class image data.

See also
  FreeImage_Clone

## pasteFromClipboard()

BOOL fipWinImage::pasteFromClipboard | ( |  | ) |

Retrieves data from the clipboard.

The clipboard format must be CF_DIB.

Returns
  Returns TRUE if successful, returns FALSE otherwise

## setToneMappingOperator()

void fipWinImage::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 will be refreshed.

Parameters

  tmo | Tone mapping operator
  first_param | First tone mapping algorithm parameter
  second_param | Second tone mapping algorithm parameter
  third_param | Third tone mapping algorithm parameter
  fourth_param | Fourth tone mapping algorithm parameter

See also
  FreeImage_ToneMapping

## Member Data Documentation

## _bDeleteMe

BOOL fipWinImage::_bDeleteMe

mutable protected

remember to delete _display_dib

## _display_dib

FIBITMAP* fipWinImage::_display_dib

mutable protected

DIB used for display (this allow to display non-standard bitmaps)

## _tmo

FREE_IMAGE_TMO fipWinImage::_tmo

protected

tone mapping operator

## _tmo_param_1

double fipWinImage::_tmo_param_1

protected

first tone mapping algorithm parameter

## _tmo_param_2

double fipWinImage::_tmo_param_2

protected

second tone mapping algorithm parameter

## _tmo_param_3

double fipWinImage::_tmo_param_3

protected

third tone mapping algorithm parameter

## _tmo_param_4

double fipWinImage::_tmo_param_4

protected

fourth tone mapping algorithm parameter

The documentation for this class was generated from the following file:

- FreeImagePlus.h