#include <FreeImagePlus.h>
Inheritance diagram for fipImage:
fipImage encapsulates the FIBITMAP format. It relies on the FreeImage library, especially for loading / saving images and for bit depth conversion.
Public Member Functions | |
Creation & Destruction | |
fipImage (FREE_IMAGE_TYPE image_type=FIT_BITMAP, WORD width=0, WORD height=0, WORD bpp=0) | |
Constructor. | |
~fipImage () | |
Destructor. | |
BOOL | setSize (FREE_IMAGE_TYPE image_type, WORD width, WORD height, WORD bpp, unsigned red_mask=0, unsigned green_mask=0, unsigned blue_mask=0) |
Image allocator. | |
virtual void | clear () |
Destroy image data. | |
Copying | |
fipImage (const fipImage &src) | |
Copy constructor. | |
fipImage & | operator= (const fipImage &src) |
Copy constructor. | |
fipImage & | operator= (FIBITMAP *dib) |
Assignement operator Copy the input pointer and manage its destruction | |
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 | pasteSubImage (fipImage &src, int left, int top, int alpha=256) |
Alpha blend or combine a sub part image with the current image. | |
BOOL | crop (int left, int top, int right, int bottom) |
Crop a sub part of the current image and update it accordingly. | |
Loading & Saving | |
Loading and saving is handled by the FreeImage library. | |
BOOL | load (const char *lpszPathName, int flag=0) |
Loads an image from disk, given its file name and an optional flag. | |
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 | 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 | loadFromMemory (fipMemoryIO &memIO, int flag=0) |
Loads an image using the specified memory stream and an optional flag. | |
BOOL | save (const char *lpszPathName, int flag=0) const |
Saves an image to disk, given its file name and an optional flag. | |
BOOL | saveU (const wchar_t *lpszPathName, int flag=0) const |
UNICODE version of save (this function only works under WIN32 and does nothing on other OS). | |
BOOL | saveToHandle (FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flag=0) const |
Saves an image using the specified FreeImageIO struct and fi_handle, and an optional flag. | |
BOOL | saveToMemory (FREE_IMAGE_FORMAT fif, fipMemoryIO &memIO, int flag=0) const |
Saves an image using the specified memory stream and an optional flag. | |
Information functions | |
Accessors to the DIB BITMAPINFO structure. | |
FREE_IMAGE_TYPE | getImageType () const |
Returns the data type of the image. | |
WORD | getWidth () const |
Returns the image width in pixels. | |
WORD | getHeight () const |
Returns the image height in pixels. | |
WORD | getScanWidth () const |
Returns the width of the bitmap in bytes rounded to the nearest DWORD. | |
operator FIBITMAP * () | |
Returns a pointer to the FIBITMAP data. | |
BOOL | isValid () const |
Returns TRUE if the image is allocated, FALSE otherwise. | |
BITMAPINFO * | getInfo () const |
Returns a pointer to the bitmap's BITMAPINFO header. | |
BITMAPINFOHEADER * | getInfoHeader () const |
Returns a pointer to the bitmap's BITMAPINFOHEADER. | |
LONG | getImageSize () const |
Returns the size of the bitmap in bytes. | |
WORD | getBitsPerPixel () const |
Returns the bitdepth of the bitmap. | |
WORD | getLine () const |
Returns the width of the bitmap in bytes. | |
double | getHorizontalResolution () const |
Returns the bitmap resolution along the X axis, in pixels / cm. | |
double | getVerticalResolution () const |
Returns the bitmap resolution along the Y axis, in pixels / cm. | |
void | setHorizontalResolution (double value) |
set the bitmap resolution along the X axis, in pixels / cm | |
void | setVerticalResolution (double value) |
set the bitmap resolution along the Y axis, in pixels / cm | |
Palette operations | |
RGBQUAD * | getPalette () const |
Returns a pointer to the bitmap's palette. | |
WORD | getPaletteSize () const |
Returns the palette size in bytes. | |
WORD | getColorsUsed () const |
Retrieves the number of colours used in the bitmap. | |
FREE_IMAGE_COLOR_TYPE | getColorType () const |
Investigates the colour type of the bitmap. | |
BOOL | isGrayscale () const |
Returns TRUE if the bitmap is a 8-bit bitmap with a greyscale palette, FALSE otherwise. | |
Pixel access | |
BYTE * | accessPixels () const |
Returns a pointer to the bitmap bits. | |
BYTE * | getScanLine (WORD scanline) const |
Returns a pointer to the start of the given scanline in the bitmap’s data-bits. | |
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). | |
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). | |
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). | |
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). | |
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 | convertToType (FREE_IMAGE_TYPE image_type, BOOL scale_linear=TRUE) |
Converts an image to a type supported by FreeImage. | |
BOOL | threshold (BYTE T) |
Converts the bitmap to 1 bit using a threshold T. | |
BOOL | dither (FREE_IMAGE_DITHER algorithm) |
Converts a 8-bit image to a monochrome 1-bit image using a dithering algorithm. | |
BOOL | convertTo4Bits () |
Converts the bitmap to 4 bits. | |
BOOL | convertTo8Bits () |
Converts the bitmap to 8 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 | convertTo16Bits555 () |
Converts the bitmap to 16 bits. | |
BOOL | convertTo16Bits565 () |
Converts the bitmap to 16 bits. | |
BOOL | convertTo24Bits () |
Converts the bitmap to 24 bits. | |
BOOL | convertTo32Bits () |
Converts the bitmap to 32 bits. | |
BOOL | convertToRGBF () |
Converts the bitmap to a 96-bit RGBF image. | |
BOOL | toneMapping (FREE_IMAGE_TMO tmo, double first_param=0, double second_param=0) |
Converts a High Dynamic Range image (48-bit RGB or 96-bit RGB Float) to a 24-bit RGB image. | |
Transparency support: background colour and alpha channel | |
BOOL | isTransparent () const |
Returns TRUE if the image is transparent, returns FALSE otherwise. | |
unsigned | getTransparencyCount () const |
8-bit transparency : get the number of transparent colors. | |
BYTE * | getTransparencyTable () const |
8-bit transparency : get the bitmap’s transparency table. | |
void | setTransparencyTable (BYTE *table, int count) |
8-bit transparency : set the bitmap’s transparency table. | |
BOOL | hasFileBkColor () const |
Returns TRUE when the image has a file background color, FALSE otherwise. | |
BOOL | getFileBkColor (RGBQUAD *bkcolor) const |
Retrieves the file background color of an image. | |
BOOL | setFileBkColor (RGBQUAD *bkcolor) |
Set the file background color of an image. | |
Channel processing support | |
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 | setChannel (fipImage &image, FREE_IMAGE_COLOR_CHANNEL channel) |
Insert a 8-bit dib into a 24- or 32-bit 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 | 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) const |
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. | |
BOOL | makeThumbnail (WORD max_size, BOOL convert=TRUE) |
Creates a thumbnail image keeping aspect ratio. | |
Image status | |
void | setModified (BOOL bStatus=TRUE) |
Set the image status as 'modified'. | |
BOOL | isModified () |
Get the image status. | |
Metadata | |
unsigned | getMetadataCount (FREE_IMAGE_MDMODEL model) const |
Returns the number of tags contained in the model metadata model attached to the dib. | |
BOOL | getMetadata (FREE_IMAGE_MDMODEL model, const char *key, fipTag &tag) const |
Retrieve a metadata attached to the dib. | |
BOOL | setMetadata (FREE_IMAGE_MDMODEL model, const char *key, fipTag &tag) |
Attach a new FreeImage tag to the dib. | |
Protected Member Functions | |
Internal use | |
BOOL | replace (FIBITMAP *new_dib) |
Protected Attributes | |
FIBITMAP * | _dib |
DIB data. | |
BOOL | _bHasChanged |
TRUE whenever the display need to be refreshed. | |
Friends | |
class | fipMultiPage |
|
Constructor.
|
|
Destructor.
|
|
Copy constructor.
|
|
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.
|
|
Adjusts the brightness of a 8, 24 or 32-bit image by a certain amount.
|
|
Adjusts the contrast of a 8, 24 or 32-bit image by a certain amount.
|
|
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.
|
|
Performs gamma correction on a 8, 24 or 32-bit image.
|
|
Destroy image data.
Reimplemented in fipWinImage. |
|
Quantizes a full colour 24-bit bitmap to a palletised 8-bit bitmap.
|
|
Builds a 24-bit RGB image given its red, green and blue channel.
|
|
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.
|
|
Converts the bitmap to 16 bits. The resulting bitmap has a layout of 5 bits red, 6 bits green and 5 bits blue.
|
|
Converts the bitmap to 24 bits.
|
|
Converts the bitmap to 32 bits.
|
|
Converts the bitmap to 4 bits. Unless the bitmap is a 1-bit palettized bitmap, colour values are converted to greyscale.
|
|
Converts the bitmap to 8 bits. If the bitmap is 24 or 32-bit RGB, the colour values are converted to greyscale.
|
|
Converts the bitmap to 8 bits.
|
|
Converts the bitmap to a 96-bit RGBF image.
|
|
Converts an image to a type supported by FreeImage.
|
|
Copy a sub part of the current image and returns it as a fipImage object. This method works with any bitmap type.
|
|
Crop a sub part of the current image and update it accordingly. This method works with any bitmap type.
|
|
Converts a 8-bit image to a monochrome 1-bit image using a dithering algorithm.
|
|
Flip the image horizontally along the vertical axis.
|
|
Flip the image vertically along the horizontal axis.
|
|
Returns the bitdepth of the bitmap.
|
|
Retrieves the red, green, blue or alpha channel of a 24- or 32-bit BGR[A] image.
|
|
Retrieves the number of colours used in the bitmap. If the bitmap is non-palletised, 0 is returned.
|
|
Investigates the colour type of the bitmap.
|
|
Retrieves the file background color of an image. For 8-bit images, the color index in the palette is returned in the rgbReserved member of the bkcolor parameter.
|
|
Returns the image height in pixels.
|
|
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.
|
|
Returns the bitmap resolution along the X axis, in pixels / cm.
|
|
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.
|
|
Returns the data type of the image.
|
|
Returns a pointer to the bitmap's BITMAPINFO header.
|
|
Returns a pointer to the bitmap's BITMAPINFOHEADER.
|
|
Returns the width of the bitmap in bytes.
|
|
Retrieve a metadata attached to the dib.
|
|
Returns the number of tags contained in the model metadata model attached to the dib.
|
|
Returns a pointer to the bitmap's palette. If the bitmap doesn't have a palette, getPalette returns NULL.
|
|
Returns the palette size in bytes.
|
|
Get the pixel color of a 16-, 24- or 32-bit image at position (x, y), including range check (slow access).
|
|
Get the pixel index of a 1-, 4- or 8-bit palettized image at position (x, y), including range check (slow access).
|
|
Returns a pointer to the start of the given scanline in the bitmap’s data-bits.
This pointer can be cast according to the result returned by getImageType.
|
|
Returns the width of the bitmap in bytes rounded to the nearest DWORD.
|
|
8-bit transparency : get the number of transparent colors.
|
|
8-bit transparency : get the bitmap’s transparency table.
|
|
Returns the bitmap resolution along the Y axis, in pixels / cm.
|
|
Returns the image width in pixels.
|
|
Returns TRUE when the image has a file background color, FALSE otherwise.
|
|
Inverts each pixel data.
|
|
Returns TRUE if the bitmap is a 8-bit bitmap with a greyscale palette, FALSE otherwise.
|
|
Get the image status.
|
|
Returns TRUE if the image is transparent, returns FALSE otherwise.
|
|
Returns TRUE if the image is allocated, FALSE otherwise.
Implements fipObject. Reimplemented in fipWinImage. |
|
Loads an image from disk, given its file name and an optional flag.
|
|
Loads an image using the specified FreeImageIO struct and fi_handle, and an optional flag.
|
|
Loads an image using the specified memory stream and an optional flag.
|
|
UNICODE version of load (this function only works under WIN32 and does nothing on other OS).
|
|
Creates a thumbnail image keeping aspect ratio.
|
|
Returns a pointer to the FIBITMAP data.
Used for direct access from FREEIMAGE functions or from your own low level C functions. fipImage src, dst; src.load("test.png"); dst = FreeImage_ConvertTo8Bits(src); FreeImage_Save(FIF_TIFF, dst, "test.tif", 0);
|
|
Assignement operator
|
|
Copy constructor.
Reimplemented in fipWinImage. |
|
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 4, 8, 16, 24 or 32.
|
|
Rescale the image to a new width / height.
|
|
Image rotation by means of three shears.
|
|
Image translation and rotation using B-Splines.
|
|
Saves an image to disk, given its file name and an optional flag.
|
|
Saves an image using the specified FreeImageIO struct and fi_handle, and an optional flag.
|
|
Saves an image using the specified memory stream and an optional flag.
|
|
UNICODE version of save (this function only works under WIN32 and does nothing on other OS).
|
|
Insert a 8-bit dib into a 24- or 32-bit image.
|
|
Set the file background color of an image. When saving an image to PNG, this background color is transparently saved to the PNG file. When the bkcolor parameter is NULL, the background color is removed from the image.
|
|
set the bitmap resolution along the X axis, in pixels / cm
|
|
Attach a new FreeImage tag to the dib.
|
|
Set the image status as 'modified'.
|
|
Set the pixel color of a 16-, 24- or 32-bit image at position (x, y), including range check (slow access).
|
|
Set the pixel index of a 1-, 4- or 8-bit palettized image at position (x, y), including range check (slow access).
|
|
Image allocator.
|
|
8-bit transparency : set the bitmap’s transparency table.
|
|
set the bitmap resolution along the Y axis, in pixels / cm
|
|
Split a 24-bit RGB image into 3 greyscale images corresponding to the red, green and blue channels.
|
|
Converts the bitmap to 1 bit using a threshold T.
|
|
Converts a High Dynamic Range image (48-bit RGB or 96-bit RGB Float) to a 24-bit RGB image.
|
|
TRUE whenever the display need to be refreshed.
|
|
DIB data.
|