Simple++
Powerfull and lightning fast C++ Library
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Graphic::FreeImage Class Reference

#include <FreeImage.h>

Inheritance diagram for Graphic::FreeImage:
BasicLoadable

Public Types

enum  Format { Format::UNDEFINED, Format::R, Format::RGB, Format::RGBA }
 
enum  LoadingType { LoadingType::EMPTY, LoadingType::FILE }
 
enum  SavingFormat { SavingFormat::PNG = FIF_PNG, SavingFormat::JPG = FIF_JPEG, SavingFormat::BMP = FIF_BMP, SavingFormat::TGA = FIF_TARGA }
 
enum  Filter {
  Filter::Box = FILTER_BOX, Filter::Bilinear = FILTER_BILINEAR, Filter::Bspline = FILTER_BSPLINE, Filter::Bicubic = FILTER_BICUBIC,
  Filter::Catmullrom = FILTER_CATMULLROM, Filter::Lanczos3 = FILTER_LANCZOS3
}
 

Public Member Functions

 FreeImage ()
 Empty constructor, it will generate an NULL image. More...
 
 FreeImage (const WString &fileName, Format format=Format::UNDEFINED, bool invertY=false, const Math::Vec2< Size > &size=Math::Vec2< Size >::null)
 Create a new Image using a file stored on the HD, the format can be specified if all the colors aren't usefully. More...
 
 FreeImage (const FreeImage &freeImage, const Math::Vec2< Size > &newSize, Filter resampleFilter=Filter::Bilinear)
 Create a new Image, a copy from an another one existing but resize it directly. More...
 
 FreeImage (const FreeImage &freeImage)
 Create a new Image, a copy from an another one existing. More...
 
 FreeImage (FreeImage &&freeImage)
 Move constructor. More...
 
 ~FreeImage (void)
 destructor More...
 
FreeImageoperator= (const FreeImage &image)
 Copy operator. More...
 
FreeImageoperator= (FreeImage &&image)
 Move operator. More...
 
void setFile (const WString &fileName, Format format=Format::UNDEFINED, bool invertY=false, const Math::Vec2< Size > &size=Math::Vec2< Size >::null)
 define a new file to be this image. This object will be automatically reloaded if already loaded. More...
 
void loadFromDatas (unsigned char *datas, const Math::Vec2< Size > &size, Format format, bool datasInvertY=false)
 load this object using raw datas More...
 
Math::vec4 getPixelf (Size x, Size y) const
 return a pixel as a Math::vec4 object. Value will be between 0.0f and 0.1f. More...
 
void setFormat (Format format)
 Set the actual format of each pixel stored, it will change the BPP. More...
 
Format getFormat () const
 Retrieve the actual image format. More...
 
FIBITMAP * getFreeImage ()
 Retrieve the inside FreeImage format object (not advised) More...
 
unsigned int getBPP () const
 Retrieve the actual BPP of this image. More...
 
unsigned char * getDatas () const
 Retrieve datas has BGRA format. More...
 
size_t getStride () const
 Retrieve the stride (width of one line in bytes) More...
 
bool saveToFile (const WString &fileName, SavingFormat savingFormat, unsigned int quality=100)
 Save the image to a file, the quality is only for JPG from 0 to 100. More...
 
void resize (const Math::Vec2< Size > &newSize, Filter resampleFilter=Filter::Bilinear)
 Resize the image to the specified size using the specified Filter. More...
 
const Math::Vec2< Size > & getSize () const
 Retrieve this image size. More...
 
bool isYFlipped () const
 Get if the Y is flipped or not. More...
 
void setFlipY (bool value)
 Set if the image should be Y flipped. More...
 
const WStringgetFileName () const
 Retrieve the fileName. More...
 
void clear ()
 Create a new image full black. More...
 
FreeImagecopy ()
 Create a copy of this image. More...
 
BITMAPINFO * getInfos ()
 
LoadingType getLoadingType () const
 Get the loading type. More...
 
- Public Member Functions inherited from BasicLoadable
 BasicLoadable ()
 Empty constructor initialized at NOT loaded and NOT loading. More...
 
 BasicLoadable (const BasicLoadable &loadable)
 copy constructor More...
 
 ~BasicLoadable ()
 
void load ()
 load the object (this function may not be overloaded) More...
 
void unload ()
 unload this object (this function may not be overloaded) More...
 
bool isLoaded () const
 get if the current object is loaded or not More...
 
void reload ()
 if the current object is loaded, unload it and then call load again, if not, this do nothing. More...
 
bool isLoading () const
 get if the current object is currently loading More...
 
void lock ()
 lock the current object to ensure no parallelization of the loading state. More...
 
void unlock ()
 unlock the current object to permit parallelization of the loading state. More...
 
BasicLoadableoperator= (const BasicLoadable &loadable)
 copy operator More...
 

Static Public Member Functions

static unsigned int getBitsFromFormat (Format format)
 Retrieve the number of bits from a specified format. More...
 

Protected Member Functions

void onLoad ()
 function to be overloaded to add action during the loading process. More...
 
void onUnload ()
 function to be overloaded to add action during the unloading process. More...
 
- Protected Member Functions inherited from BasicLoadable
void setLoaded (bool loaded)
 set if the current object is loaded or not. (use with caution) More...
 
void setLoading (bool isLoading)
 set if the current object is currently loading (use with caution) More...
 

Member Enumeration Documentation

Enumerator
Box 
Bilinear 
Bspline 
Bicubic 
Catmullrom 
Lanczos3 
Enumerator
UNDEFINED 
RGB 
RGBA 
Enumerator
EMPTY 
FILE 
Enumerator
PNG 
JPG 
BMP 
TGA 

Constructor & Destructor Documentation

FreeImage::FreeImage ( )

Empty constructor, it will generate an NULL image.

FreeImage::FreeImage ( const WString fileName,
Format  format = Format::UNDEFINED,
bool  invertY = false,
const Math::Vec2< Size > &  size = Math::Vec2<Size>::null 
)

Create a new Image using a file stored on the HD, the format can be specified if all the colors aren't usefully.

Parameters
fileNamePath to the image to be opened. Has to be in UTF16
formatFormat of the image (Format::UNDEFINED meens automatic detection. The file will be converted instead.)
invertYSpecify if the image has to be flipped vertically when loaded.
sizethe size the image will have. (Math::Vec2<Size>::null meens the original one).
FreeImage::FreeImage ( const FreeImage freeImage,
const Math::Vec2< Size > &  newSize,
Filter  resampleFilter = Filter::Bilinear 
)

Create a new Image, a copy from an another one existing but resize it directly.

Parameters
freeImagethe image to be copied.
newSizethe new size to be applied to the copied version
resampleFilterthe re sample filter to be used during the resizing.
FreeImage::FreeImage ( const FreeImage freeImage)

Create a new Image, a copy from an another one existing.

Parameters
freeImagethe image to be copied.
FreeImage::FreeImage ( FreeImage &&  freeImage)

Move constructor.

FreeImage::~FreeImage ( void  )

destructor

Member Function Documentation

void FreeImage::clear ( )

Create a new image full black.

FreeImage * FreeImage::copy ( )

Create a copy of this image.

unsigned int FreeImage::getBitsFromFormat ( Format  format)
static

Retrieve the number of bits from a specified format.

unsigned int FreeImage::getBPP ( ) const

Retrieve the actual BPP of this image.

unsigned char * FreeImage::getDatas ( ) const

Retrieve datas has BGRA format.

const WString & FreeImage::getFileName ( ) const

Retrieve the fileName.

FreeImage::Format FreeImage::getFormat ( ) const

Retrieve the actual image format.

FIBITMAP * FreeImage::getFreeImage ( )

Retrieve the inside FreeImage format object (not advised)

BITMAPINFO * FreeImage::getInfos ( )
FreeImage::LoadingType FreeImage::getLoadingType ( ) const

Get the loading type.

Math::vec4 FreeImage::getPixelf ( Size  x,
Size  y 
) const

return a pixel as a Math::vec4 object. Value will be between 0.0f and 0.1f.

const Math::Vec2< Size > & FreeImage::getSize ( ) const

Retrieve this image size.

size_t FreeImage::getStride ( ) const

Retrieve the stride (width of one line in bytes)

Returns
stride
bool FreeImage::isYFlipped ( ) const

Get if the Y is flipped or not.

void FreeImage::loadFromDatas ( unsigned char *  datas,
const Math::Vec2< Size > &  size,
Format  format,
bool  datasInvertY = false 
)

load this object using raw datas

Parameters
datasThe datas buffer to be used during the loading.
sizethe size of the image.
formatthe loading format of this image.
datasInvertYif we have to flip the image vertically or not.
void FreeImage::onLoad ( )
protectedvirtual

function to be overloaded to add action during the loading process.

Reimplemented from BasicLoadable.

void FreeImage::onUnload ( )
protectedvirtual

function to be overloaded to add action during the unloading process.

Reimplemented from BasicLoadable.

FreeImage & FreeImage::operator= ( const FreeImage image)

Copy operator.

FreeImage & FreeImage::operator= ( FreeImage &&  image)

Move operator.

void FreeImage::resize ( const Math::Vec2< Size > &  newSize,
Filter  resampleFilter = Filter::Bilinear 
)

Resize the image to the specified size using the specified Filter.

bool FreeImage::saveToFile ( const WString fileName,
SavingFormat  savingFormat,
unsigned int  quality = 100 
)

Save the image to a file, the quality is only for JPG from 0 to 100.

void FreeImage::setFile ( const WString fileName,
Format  format = Format::UNDEFINED,
bool  invertY = false,
const Math::Vec2< Size > &  size = Math::Vec2<Size>::null 
)

define a new file to be this image. This object will be automatically reloaded if already loaded.

Parameters
fileNamenew file Path to be opened in UTF16
formatloading format to be used if every components are not useful. (Format::UNDEFINED will use the file's one.)
invertYif we have to flip the image vertically.
sizethe new size of the loaded image (Math::Vec2<Size>::null mean full image resolution).
void FreeImage::setFlipY ( bool  value)

Set if the image should be Y flipped.

void FreeImage::setFormat ( Format  format)

Set the actual format of each pixel stored, it will change the BPP.


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