Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

fipImage Class Reference

#include <FreeImagePlus.h>

Inheritance diagram for fipImage:

fipGenericImage fipWinImage List of all members.

Detailed Description

A class used to manage all photo related images.

fipImage encapsulates the FIBITMAP format. It relies on the FreeImage library, especially for loading / saving images and for bit depth conversion.

Version:
FreeImage 3.0
Author:
Hervé Drolon


Public Member Functions

Creation & Destruction
 fipImage (WORD width=0, WORD height=0, WORD bpp=0)
 Constructor.

 ~fipImage ()
 Destructor.

BOOL setSize (WORD width, WORD height, WORD bpp)
 Image allocator.

Copying
 fipImage (const fipImage &src)
 Copy constructor.

 fipImage (const FIBITMAP *dib)
 Copy constructor.

fipImageoperator= (const fipImage &src)
 Copy constructor.

fipImageoperator= (FIBITMAP *dib)
 Assignement operator.

BOOL copySubImage (fipImage &dst, int left, int top, int right, int bottom)
 The bit depth of the bitmap must be equal to 1, 4, 8, 16, 24 or 32.

BOOL pasteSubImage (fipImage &src, int left, int top, int alpha=256)
 Alpha blend or combine a sub part image with the current image.

Loading & Saving
Loading and saving is handled by the FreeImage library.

BOOL load (const char *lpszPathName, int flag=0)
BOOL loadFromHandle (FreeImageIO *io, fi_handle handle, int flag=0)
BOOL save (const char *lpszPathName, int flag=0)
BOOL saveToHandle (FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flag=0)
Information functions
Accessors to the DIB BITMAPINFO structure.

FIBITMAP * getFIBITMAP ()
 Returns a pointer to the FIBITMAP data. Used for direct access from FREEIMAGE functions.

BOOL isValid ()
 Returns TRUE if the image is allocated, FALSE otherwise.

BITMAPINFO * getInfo ()
 Returns a pointer to the bitmap's BITMAPINFO header.

BITMAPINFOHEADER * getInfoHeader ()
 Returns a pointer to the bitmap's BITMAPINFOHEADER.

LONG getImageSize ()
 Returns the size of the bitmap in bytes. The size of the bitmap is the BITMAPINFOHEADER + the size of the palette + the size of the bitmap data.

WORD getBitsPerPixel ()
 Returns the bitdepth of the bitmap.

WORD getLine ()
 Returns the width of the bitmap in bytes.

WORD getHorizontalResolution ()
 Returns the bitmap resolution along the X axis, in pixels / cm.

WORD getVerticalResolution ()
 Returns the bitmap resolution along the Y axis, in pixels / cm.

void setHorizontalResolution (LONG value)
 set the bitmap resolution along the X axis, in pixels / cm

void setVerticalResolution (LONG value)
 set the bitmap resolution along the Y axis, in pixels / cm

Palette operations
RGBQUAD * getPalette ()
 Returns a pointer to the bitmap's palette. If the bitmap doesn't have a palette, getPalette returns NULL.

WORD getPaletteSize ()
 Returns the palette size in bytes.

WORD getColorsUsed ()
 Retrieves the number of colours used in the bitmap. If the bitmap is non-palletised, 0 is returned.

FREE_IMAGE_COLOR_TYPE getColorType ()
 Investigates the colour type of the bitmap.

BOOL isGrayscale ()
 Returns TRUE if the bitmap is a 8-bit bitmap with a greyscale palette, FALSE otherwise.

Pixel access
BYTE * accessPixels ()
 Returns a pointer to the bitmap bits.

BYTE * getScanLine (int scanline)
 Returns a pointer to the start of the given scanline in the bitmap’s data-bits.

Conversion routines
Bitmaps are always loaded in their default bit depth.

If you want the bitmap to be stored in another bit depth, the class provides several conversion functions.

BOOL threshold (BYTE T)
 Converts the bitmap to 1 bit using a threshold T.

BOOL convertTo8Bits ()
 Converts the bitmap to 8 bits. If the bitmap is 24 or 32-bit RGB, the colour values are converted to greyscale.

BOOL convertTo16Bits555 ()
 Converts the bitmap to 16 bits. The resulting bitmap has a layout of 5 bits red, 5 bits green, 5 bits blue and 1 unused bit.

BOOL convertTo16Bits565 ()
 Converts the bitmap to 16 bits. The resulting bitmap has a layout of 5 bits red, 6 bits green and 5 bits blue.

BOOL convertTo24Bits ()
 Converts the bitmap to 24 bits.

BOOL convertTo32Bits ()
 Converts the bitmap to 32 bits.

BOOL convertToGrayscale ()
 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 dither (FREE_IMAGE_DITHER algorithm)
 Converts a 8-bit image to a monochrome image using a dithering algorithm.

Channel processing support
BOOL getChannel (fipImage &image, FREE_IMAGE_COLOR_CHANNEL channel)
 Retrieves the red, green, blue or alpha channel of a 24- or 32-bit BGR[A] image.

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.

BOOL getRedChannel (fipImage &red)
 Retrieves the red channel of a 24-bit RGB image.

BOOL getGreenChannel (fipImage &green)
 Retrieves the green channel of a 24-bit RGB image.

BOOL getBlueChannel (fipImage &blue)
 Retrieves the blue channel of a 24-bit RGB image.

BOOL getAlphaChannel (fipImage &alpha)
 Retrieves the alpha channel of a 32-bit RGB image.

BOOL setAlphaChannel (fipImage &alpha)
 Set the alpha channel of a 32-bit RGB image.

BOOL combineChannels (fipImage &red, fipImage &green, fipImage &blue)
 Builds a 24-bit RGB image given its red, green and blue channel.

Rotation and flipping
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 rotate (double angle)
 Image rotation by means of three shears.

BOOL flipHorizontal ()
 Flip the image horizontally along the vertical axis.

BOOL flipVertical ()
 Flip the image vertically along the horizontal axis.

Color manipulation routines
BOOL invert ()
 Inverts each pixel data.

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).

BOOL adjustGamma (double gamma)
 Performs gamma correction on a 8, 24 or 32-bit image.

BOOL adjustBrightness (double percentage)
 Adjusts the brightness of a 8, 24 or 32-bit image by a certain amount.

BOOL adjustContrast (double percentage)
 Adjusts the contrast of a 8, 24 or 32-bit image by a certain amount.

BOOL getHistogram (DWORD *histo, FREE_IMAGE_COLOR_CHANNEL channel=FICC_BLACK)
 Computes image histogram.

Upsampling / downsampling
BOOL rescale (WORD new_width, WORD new_height, FREE_IMAGE_FILTER filter)
 Rescale the image to a new width / height.


Protected Member Functions

Internal use
void updateInfo ()
BOOL replace (FIBITMAP *new_dib)
BOOL replace (fipImage &img)

Protected Attributes

FIBITMAP * m_dib
 DIB data.

BYTE * m_bits
 Pointer to DIB pixels.


Constructor & Destructor Documentation

fipImage::fipImage WORD  width = 0,
WORD  height = 0,
WORD  bpp = 0
 

Constructor.

fipImage::~fipImage  ) 
 

Destructor.

fipImage::fipImage const fipImage src  ) 
 

Copy constructor.

fipImage::fipImage const FIBITMAP *  dib  ) 
 

Copy constructor.


Member Function Documentation

BYTE* fipImage::accessPixels  ) 
 

Returns a pointer to the bitmap bits.

It is up to you to interpret these bytes correctly, according to the results of FreeImage_GetBPP and GetRedMask, FreeImage_GetGreenMask and FreeImage_GetBlueMask.

See also:
FreeImage_GetBits

BOOL fipImage::adjustBrightness double  percentage  ) 
 

Adjusts the brightness of a 8, 24 or 32-bit image by a certain amount.

Parameters:
percentage Where -100 <= percentage <= 100
A value 0 means no change, less than 0 will make the image darker and greater than 0 will make the image brighter.
Returns:
Returns TRUE if the operation was succesful, FALSE otherwise
See also:
adjustCurve

BOOL fipImage::adjustContrast double  percentage  ) 
 

Adjusts the contrast of a 8, 24 or 32-bit image by a certain amount.

Parameters:
percentage Where -100 <= percentage <= 100
A value 0 means no change, less than 0 will decrease the contrast and greater than 0 will increase the contrast of the image.
Returns:
Returns TRUE if the operation was succesfull, FALSE otherwise
See also:
adjustCurve

BOOL fipImage::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).

The transformation is done as follows.
Image 8-bit : if the image has a color palette, the LUT is applied to this palette, otherwise, it is applied to the grey values.
Image 24-bit & 32-bit : if channel == IPL_CC_RGB, the same LUT is applied to each color plane (R,G, and B). Otherwise, the LUT is applied to the specified channel only.

Parameters:
LUT Lookup table. The size of 'LUT' is assumed to be 256.
channel The color channel to be processed (only used with 24 & 32-bit DIB).
Returns:
Returns TRUE if the operation was successful, FALSE otherwise
See also:
FREE_IMAGE_COLOR_CHANNEL

BOOL fipImage::adjustGamma double  gamma  ) 
 

Performs gamma correction on a 8, 24 or 32-bit image.

Parameters:
gamma Gamma value to use. A value of 1.0 leaves the image alone, less than one darkens it, and greater than one lightens it.
Returns:
Returns TRUE if the operation was successful, FALSE otherwise
See also:
adjustCurve

BOOL fipImage::colorQuantize FREE_IMAGE_QUANTIZE  algorithm  ) 
 

Quantizes a full colour 24-bit bitmap to a palletised 8-bit bitmap.

The quantize parameter specifies which colour reduction algorithm should be used.

Parameters:
algorithm Color quantization algorithm to use.
Returns:
Returns TRUE if successfull, FALSE otherwise.
See also:
FREE_IMAGE_QUANTIZE

BOOL fipImage::combineChannels fipImage red,
fipImage green,
fipImage blue
 

Builds a 24-bit RGB image given its red, green and blue channel.

Parameters:
RedChannel Input red channel.
GreenChannel Input green channel.
BlueChannel Input blue channel.
Returns:
Returns FALSE if the dib can't be allocated, if the input channels are not 8-bit images. Returns TRUE otherwise.

BOOL fipImage::convertTo16Bits555  ) 
 

Converts the bitmap to 16 bits. The resulting bitmap has a layout of 5 bits red, 5 bits green, 5 bits blue and 1 unused bit.

Returns:
Returns TRUE if successfull, FALSE otherwise.

BOOL fipImage::convertTo16Bits565  ) 
 

Converts the bitmap to 16 bits. The resulting bitmap has a layout of 5 bits red, 6 bits green and 5 bits blue.

Returns:
Returns TRUE if successfull, FALSE otherwise.

BOOL fipImage::convertTo24Bits  ) 
 

Converts the bitmap to 24 bits.

Returns:
Returns TRUE if successfull, FALSE otherwise.

BOOL fipImage::convertTo32Bits  ) 
 

Converts the bitmap to 32 bits.

Returns:
Returns TRUE if successfull, FALSE otherwise.

BOOL fipImage::convertTo8Bits  ) 
 

Converts the bitmap to 8 bits. If the bitmap is 24 or 32-bit RGB, the colour values are converted to greyscale.

Returns:
Returns TRUE if successfull, FALSE otherwise.

BOOL fipImage::convertToGrayscale  ) 
 

Converts the bitmap to 8 bits.

For palletized bitmaps, the color map is converted to a greyscale ramp.

See also:
convertTo8Bits
Returns:
Returns TRUE if successfull, FALSE otherwise.

BOOL fipImage::copySubImage fipImage dst,
int  left,
int  top,
int  right,
int  bottom
 

The bit depth of the bitmap must be equal to 1, 4, 8, 16, 24 or 32.

Parameters:
dst Output subimage
left Specifies the left position of the cropped rectangle.
top Specifies the top position of the cropped rectangle.
right Specifies the right position of the cropped rectangle.
bottom Specifies the bottom position of the cropped rectangle.
Returns:
Returns TRUE if successful, FALSE otherwise.

BOOL fipImage::dither FREE_IMAGE_DITHER  algorithm  ) 
 

Converts a 8-bit image to a monochrome image using a dithering algorithm.

Parameters:
algorithm Dithering algorithm to use.
Returns:
Returns TRUE if successfull, FALSE otherwise.
See also:
FREE_IMAGE_DITHER

BOOL fipImage::flipHorizontal  ) 
 

Flip the image horizontally along the vertical axis.

BOOL fipImage::flipVertical  ) 
 

Flip the image vertically along the horizontal axis.

BOOL fipImage::getAlphaChannel fipImage alpha  ) 
 

Retrieves the alpha channel of a 32-bit RGB image.

Parameters:
alpha Output alpha channel.
Returns:
Returns TRUE if successful, FALSE otherwise.

WORD fipImage::getBitsPerPixel  ) 
 

Returns the bitdepth of the bitmap.


Valid bitdepth can be 1, 4, 8, 16, 24 or 32.

BOOL fipImage::getBlueChannel fipImage blue  ) 
 

Retrieves the blue channel of a 24-bit RGB image.

Parameters:
blue Output blue channel.
Returns:
Returns TRUE if successful, FALSE otherwise.

BOOL fipImage::getChannel fipImage image,
FREE_IMAGE_COLOR_CHANNEL  channel
 

Retrieves the red, green, blue or alpha channel of a 24- or 32-bit BGR[A] image.

Parameters:
image Output image to be extracted
channel Color channel to extract
Returns:
Returns TRUE if successful, FALSE otherwise.
See also:
FREE_IMAGE_COLOR_CHANNEL

WORD fipImage::getColorsUsed  ) 
 

Retrieves the number of colours used in the bitmap. If the bitmap is non-palletised, 0 is returned.

FREE_IMAGE_COLOR_TYPE fipImage::getColorType  ) 
 

Investigates the colour type of the bitmap.

See also:
FREE_IMAGE_COLOR_TYPE

FIBITMAP* fipImage::getFIBITMAP  ) 
 

Returns a pointer to the FIBITMAP data. Used for direct access from FREEIMAGE functions.

BOOL fipImage::getGreenChannel fipImage green  ) 
 

Retrieves the green channel of a 24-bit RGB image.

Parameters:
green Output green channel.
Returns:
Returns TRUE if successful, FALSE otherwise.

BOOL fipImage::getHistogram DWORD *  histo,
FREE_IMAGE_COLOR_CHANNEL  channel = FICC_BLACK
 

Computes image histogram.

For 24-bit and 32-bit images, histogram can be computed from red, green, blue and black channels. For 8-bit images, histogram is computed from the black channel. Other bit depth is not supported.

Parameters:
histo pointer to an histogram array. Size of this array is assumed to be 256.
channel Color channel to use
Returns:
Returns TRUE if the operation was succesfull, FALSE otherwise

WORD fipImage::getHorizontalResolution  ) 
 

Returns the bitmap resolution along the X axis, in pixels / cm.

LONG fipImage::getImageSize  ) 
 

Returns the size of the bitmap in bytes. The size of the bitmap is the BITMAPINFOHEADER + the size of the palette + the size of the bitmap data.

BITMAPINFO* fipImage::getInfo  ) 
 

Returns a pointer to the bitmap's BITMAPINFO header.

BITMAPINFOHEADER* fipImage::getInfoHeader  ) 
 

Returns a pointer to the bitmap's BITMAPINFOHEADER.

WORD fipImage::getLine  ) 
 

Returns the width of the bitmap in bytes.

RGBQUAD* fipImage::getPalette  ) 
 

Returns a pointer to the bitmap's palette. If the bitmap doesn't have a palette, getPalette returns NULL.

WORD fipImage::getPaletteSize  ) 
 

Returns the palette size in bytes.

BOOL fipImage::getRedChannel fipImage red  ) 
 

Retrieves the red channel of a 24-bit RGB image.

Parameters:
red Output red channel.
Returns:
Returns TRUE if successful, FALSE otherwise.

BYTE* fipImage::getScanLine int  scanline  ) 
 

Returns a pointer to the start of the given scanline in the bitmap’s data-bits.

See also:
FreeImage_GetScanLine

WORD fipImage::getVerticalResolution  ) 
 

Returns the bitmap resolution along the Y axis, in pixels / cm.

BOOL fipImage::invert  ) 
 

Inverts each pixel data.

Returns:
Returns TRUE if successful, FALSE otherwise.

BOOL fipImage::isGrayscale  ) 
 

Returns TRUE if the bitmap is a 8-bit bitmap with a greyscale palette, FALSE otherwise.

BOOL fipImage::isValid  )  [virtual]
 

Returns TRUE if the image is allocated, FALSE otherwise.

Implements fipGenericImage.

BOOL fipImage::load const char *  lpszPathName,
int  flag = 0
 

Parameters:
lpszPathName Path and file name of the image to load.
flag The signification of this flag depends on the image to be read.
Returns:
Returns TRUE if successful, FALSE otherwise.
See also:
FreeImage.h, FreeImage documentation

BOOL fipImage::loadFromHandle FreeImageIO *  io,
fi_handle  handle,
int  flag = 0
 

Parameters:
io FreeImageIO structure
handle FreeImage fi_handle
flag The signification of this flag depends on the image to be read.
Returns:
Returns TRUE if successful, FALSE otherwise.
See also:
FreeImage.h, FreeImage documentation

fipImage& fipImage::operator= FIBITMAP *  dib  ) 
 

Assignement operator.

fipImage& fipImage::operator= const fipImage src  ) 
 

Copy constructor.

BOOL fipImage::pasteSubImage fipImage src,
int  left,
int  top,
int  alpha = 256
 

Alpha blend or combine a sub part image with the current image.

The bit depth of dst bitmap must be greater than or equal to the bit depth of src. Upper promotion of src is done internally. Supported bit depth equals to 8, 16, 24 or 32.

Parameters:
src Source subimage
left Specifies the left position of the sub image.
top Specifies the top position of the sub image.
alpha Alpha blend factor. The source and destination images are alpha blended if alpha = 0..255. If alpha > 255, then the source image is combined to the destination image.
Returns:
Returns TRUE if successful, FALSE otherwise.

BOOL fipImage::rescale WORD  new_width,
WORD  new_height,
FREE_IMAGE_FILTER  filter
 

Rescale the image to a new width / height.

Parameters:
new_width New image width
new_height New image height
filter The filter parameter specifies which resampling filter should be used.
Returns:
Returns TRUE if the operation was successful, FALSE otherwise
See also:
FREE_IMAGE_FILTER

BOOL fipImage::rotate double  angle  ) 
 

Image rotation by means of three shears.

Parameters:
angle Image rotation angle, in degree
Returns:
Returns the translated & rotated dib if successful, returns NULL otherwise

BOOL fipImage::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.

Parameters:
angle Image rotation angle, in degree
x_shift Image horizontal shift
y_shift Image vertical shift
x_origin Origin of the x-axis
y_origin Origin of the y-axis
spline_degree Degree of the B-spline model
use_mask Whether or not to mask the image. Image mirroring is applied when use_mask is set to FALSE
Returns:
Returns the translated & rotated dib if successful, returns NULL otherwise

BOOL fipImage::save const char *  lpszPathName,
int  flag = 0
 

Parameters:
lpszPathName Path and file name of the image to save.
flag The signification of this flag depends on the image to be saved.
Returns:
Returns TRUE if successful, FALSE otherwise.
See also:
FreeImage.h, FreeImage documentation

BOOL fipImage::saveToHandle FREE_IMAGE_FORMAT  fif,
FreeImageIO *  io,
fi_handle  handle,
int  flag = 0
 

Parameters:
fif Format identifier (FreeImage format)
io FreeImageIO structure
handle FreeImage fi_handle
flag The signification of this flag depends on the image to be saved.
Returns:
Returns TRUE if successful, FALSE otherwise.
See also:
FreeImage.h, FreeImage documentation

BOOL fipImage::setAlphaChannel fipImage alpha  ) 
 

Set the alpha channel of a 32-bit RGB image.

Parameters:
alpha Input alpha channel.
Returns:
Returns TRUE if successful, FALSE otherwise.

void fipImage::setHorizontalResolution LONG  value  ) 
 

set the bitmap resolution along the X axis, in pixels / cm

BOOL fipImage::setSize WORD  width,
WORD  height,
WORD  bpp
 

Image allocator.

void fipImage::setVerticalResolution LONG  value  ) 
 

set the bitmap resolution along the Y axis, in pixels / cm

BOOL fipImage::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.

Parameters:
RedChannel Output red channel.
GreenChannel Output green channel.
BlueChannel Output blue channel.
Returns:
Returns FALSE if the dib isn't a valid image, if it's not a 24-bit image or if one of the output channel can't be allocated. Returns TRUE otherwise.

BOOL fipImage::threshold BYTE  T  ) 
 

Converts the bitmap to 1 bit using a threshold T.

Parameters:
T Threshold value in [0..255]
Returns:
Returns TRUE if successfull, FALSE otherwise.


Member Data Documentation

BYTE* fipImage::m_bits [protected]
 

Pointer to DIB pixels.

FIBITMAP* fipImage::m_dib [protected]
 

DIB data.


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