Public Member Functions | Protected Member Functions
imagen::iImage Class Reference

Master image class. More...

#include <iImage.h>

Inheritance diagram for imagen::iImage:
imagen::iAbstractImage

List of all members.

Public Member Functions

 iImage ()
 Constructs a null image.
 iImage (const iImage &img)
 Copy constructor.
 iImage (const iAbstractImage &img)
 iAbstractImage copy constructor.
 iImage (int w, int h, iImageFormat f)
 Constructs an image with the given size and format.
 iImage (Iubyte *d, int w, int h, iImageFormat f, int b)
 Constructs an image using an existing memory buffer.
 iImage (const char *filename)
 Loads an image file from disk.
 iImage (const char *filename, iImageType tp)
 Loads an image file of the given type from disk.
 iImage (Iubyte *buf, int len)
 Loads an image from an existing memory buffer.
 iImage (Iubyte *buf, int len, iImageType tp)
 Loads an image of the given type from an existing memory buffer.
 iImage (iDataStream *s)
 Loads an image using an existing data stream.
 iImage (iDataStream *s, iImageType tp)
 Loads an image of the given type using an existing data stream.
 ~iImage ()
 Destructor.
bool load (const char *filename)
 Loads an image file from disk.
bool load (const char *filename, iImageType tp)
 Loads an image file with the given type from disk.
bool load (Iubyte *buf, int len)
 Loads an image from an existing memory buffer.
bool load (Iubyte *buf, int len, iImageType tp)
 Loads an image with the given type from an existing memory buffer.
bool load (iDataStream *s)
 Loads an image using an existing data stream.
bool load (iDataStream *s, iImageType tp)
 Loads an image using an existing data stream.
bool save (const char *filename)
 Writes an image file to disk.
bool save (const char *filename, iImageType tp)
 Writes an image file with the given type to disk.
bool save (Iubyte *buf, int len)
 Writes an image to an existing memory buffer.
bool save (Iubyte *buf, int len, iImageType tp)
 Writes an image with the given type to an existing memory buffer.
bool save (iDataStream *s)
 Writes an image using an existing data stream.
bool save (iDataStream *s, iImageType tp)
 Writes an image with the given type using an existing data stream.
void clear ()
 Detaches this image from the image data and resets all data members to their initial values.
bool isFormatSupported (iImageFormat fmt) const
 Checks whether or not a given image color format is supported by this image type.
iImageoperator= (const iAbstractImage &img)

Protected Member Functions

void init ()
bool loadImage ()
bool saveImage ()

Detailed Description

Master image class.

iImage is capable of reading and writing all supported image types, and is most likely the class you will want to use in most cases.
The only shortcoming is that it can't offer any services specific to any particular image file format; if you need to manipulate data specific to a particular image file format, you should create an instance of class iTGA or iPNG, for example.

The standard load() and save() functions have been overloaded specifically for this class, and they behave a little differently than the way the other image classes use them:


Constructor & Destructor Documentation

Constructs a null image.

imagen::iImage::iImage ( const iImage img)

Copy constructor.

This copies all image attributes, and attaches itself to img's shared data.

iAbstractImage copy constructor.

imagen::iImage::iImage ( int  w,
int  h,
iImageFormat  f 
)

Constructs an image with the given size and format.

The image data will be allocated, but not initialized.

Parameters:
w: Image width.
h: Image height.
f: Image format.
imagen::iImage::iImage ( Iubyte d,
int  w,
int  h,
iImageFormat  f,
int  b 
)

Constructs an image using an existing memory buffer.

The memory buffer will not be deleted at destruction.

See also:
loadData()
imagen::iImage::iImage ( const char *  filename)

Loads an image file from disk.

See also:
load( const char *filename )
imagen::iImage::iImage ( const char *  filename,
iImageType  tp 
)

Loads an image file of the given type from disk.

See also:
load( const char *filename, iImageType tp )
imagen::iImage::iImage ( Iubyte buf,
int  len 
)

Loads an image from an existing memory buffer.

See also:
load( Iubyte *buf, int len )
imagen::iImage::iImage ( Iubyte buf,
int  len,
iImageType  tp 
)

Loads an image of the given type from an existing memory buffer.

See also:
load( Iubyte *buf, int len, iImageType tp )

Loads an image using an existing data stream.

See also:
load( iDataStream *s )

Loads an image of the given type using an existing data stream.

See also:
load( iDataStream *s )

Destructor.


Member Function Documentation

bool imagen::iImage::load ( const char *  filename)

Loads an image file from disk.

An image reader will be chosen based on the extension given in filename.
For example, in "mygraphic.png", the extension is "png", which means the image type is iTypePNG, so an iPNG reader will be used.

Parameters:
filename: The name of the image to load.
Returns:
True if successful, else false.
See also:
load( const char *filename, iImageType tp )

Reimplemented from imagen::iAbstractImage.

bool imagen::iImage::load ( const char *  filename,
iImageType  tp 
)

Loads an image file with the given type from disk.

Just because image loading doesn't work, doesn't mean there's something wrong with the image; you may be trying to load it with the wrong type.
If you want the image type to be automatically determined based on the extension in filename, use load( const char *filename ).

Parameters:
filename: The name of the image to load.
tp: Image type of the image to be read.
Returns:
True if successful, else false.
bool imagen::iImage::load ( Iubyte buf,
int  len 
)

Loads an image from an existing memory buffer.

This function will attempt to read the image by arbitrarily calling the function isValid() for each supported image type. If the image type is recognizable, it will be loaded with the appropriate image reader.

Parameters:
buf: Pointer to a memory buffer.
len: Size of the memory buffer.
Returns:
True if successful, else false.

Reimplemented from imagen::iAbstractImage.

bool imagen::iImage::load ( Iubyte buf,
int  len,
iImageType  tp 
)

Loads an image with the given type from an existing memory buffer.

This function won't attempt to identify the image type. It will load the buffer as the image type you specify, and give up if unsuccessful.

Parameters:
buf: Pointer to a memory buffer.
len: Size of the memory buffer.
tp: Image type of the image to be read.
Returns:
True if successful, else false.

Loads an image using an existing data stream.

This function will not open nor close the stream. It is the user's responsibility to make sure the stream is properly opened and closed.

Returns:
True if successful, else false.

Reimplemented from imagen::iAbstractImage.

Loads an image using an existing data stream.

This function will not open nor close the stream. It is the user's responsibility to make sure the stream is properly opened and closed.

Returns:
True if successful, else false.
bool imagen::iImage::save ( const char *  filename)

Writes an image file to disk.

An image writer will be chosen based on the extension given in filename.
For example, in "mygraphic.tga", the extension is "tga", which means the image type is iTypeTGA, so an iTGA writer will be used.

Parameters:
filename: The name to save the image as.
Returns:
True if successful, else false.

Reimplemented from imagen::iAbstractImage.

bool imagen::iImage::save ( const char *  filename,
iImageType  tp 
)

Writes an image file with the given type to disk.

Parameters:
filename: The name to save the image as.
tp: Image type to save the image as.
Returns:
True if successful, else false.
bool imagen::iImage::save ( Iubyte buf,
int  len 
)

Writes an image to an existing memory buffer.

In this function, there is no way to determine what image type the user wants to save the image as. To avoid ambiguity, this function does nothing.
Use save( Iubyte *buf, int len, iImageType tp ) instead.

Parameters:
buf: Pointer to a memory buffer.
len: Size of the memory buffer.
Returns:
True if successful, else false.

Reimplemented from imagen::iAbstractImage.

bool imagen::iImage::save ( Iubyte buf,
int  len,
iImageType  tp 
)

Writes an image with the given type to an existing memory buffer.

Parameters:
buf: Pointer to a memory buffer.
len: Size of the memory buffer.
tp: Image type to save the image as.
Returns:
True if successful, else false.

Writes an image using an existing data stream.

This function will not open nor close the stream. It is the user's responsibility to make sure the stream is properly opened and closed.

Returns:
True if successful, else false.

Reimplemented from imagen::iAbstractImage.

Writes an image with the given type using an existing data stream.

This function will not open nor close the stream. It is the user's responsibility to make sure the stream is properly opened and closed.

Returns:
True if successful, else false.
void imagen::iImage::clear ( ) [virtual]

Detaches this image from the image data and resets all data members to their initial values.

Reimplemented from imagen::iAbstractImage.

bool imagen::iImage::isFormatSupported ( iImageFormat  fmt) const [inline, virtual]

Checks whether or not a given image color format is supported by this image type.

Returns:
True if the format is supported, else false.

Implements imagen::iAbstractImage.

iImage& imagen::iImage::operator= ( const iAbstractImage img)

Reimplemented from imagen::iAbstractImage.

void imagen::iImage::init ( ) [protected]

Reimplemented from imagen::iAbstractImage.

bool imagen::iImage::loadImage ( ) [protected, virtual]
bool imagen::iImage::saveImage ( ) [protected, virtual]

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