Public Member Functions | Protected Member Functions | Protected Attributes
imagen::iAbstractImage Class Reference

Abstract image class. More...

#include <iAbstractImage.h>

Inheritance diagram for imagen::iAbstractImage:
imagen::iBMP imagen::iImage imagen::iJPEG imagen::iPNG imagen::iRawImage imagen::iTGA

List of all members.

Public Member Functions

 iAbstractImage ()
 Constructs a null image.
 iAbstractImage (const iAbstractImage &img)
 Copy constructor.
 iAbstractImage (int w, int h, iImageFormat f)
 Constructs an image with the given size and format.
 iAbstractImage (Iubyte *d, int w, int h, iImageFormat f, int b)
 Constructs an image using an existing memory buffer.
virtual ~iAbstractImage ()
 Destructor.
bool load (const char *filename)
 Loads an image file from disk.
bool load (Iubyte *buf, int len)
 Loads an image from an existing memory buffer.
bool load (iDataStream *s)
 Loads an image using an existing data stream.
bool save (const char *filename)
 Writes an image file to disk.
bool save (Iubyte *buf, int len)
 Writes an image to an existing memory buffer.
bool save (iDataStream *s)
 Writes an image using an existing data stream.
void loadData (Iubyte *d, int w, int h, iImageFormat f, int b)
 Loads image data from an existing memory buffer.
virtual void clear ()
 Detaches this image from the image data and resets all data members to their initial values.
void detachData ()
 Detaches this image from the image data.
void flipVertical ()
 Flips the image data vertically.
void flipHorizontal ()
 Flips the image data horizontally.
void rotateLeft ()
 Rotates the image counterclockwise 90 degrees.
void rotateRight ()
 Rotates the image clockwise 90 degrees.
void rotate180 ()
 Rotates the image 180 degrees.
void fill (const iColor &col)
 Fills the entire image with a given color.
bool pad (int top, int left, int bottom, int right, iWrapMode mode)
 Pads the image data.
bool resize (int w, int h, int x, int y)
 Resizes the image data.
void swapRGB ()
 Swaps the red and blue components of all pixels.
void convertFormat (iImageFormat fmt, int alpha=255)
 Converts the image to the specified format.
int imageSize () const
 Returns the number of bytes occupied by the image data.
bool isNull () const
 Checks whether or not the image is empty.
virtual bool isFormatSupported (iImageFormat fmt) const =0
 Checks whether or not a given image color format is supported by this image type.
IubytegetData ()
 Returns a pointer to the first byte of the image.
const IubytegetData () const
 Returns a const pointer to the first byte of the image.
int getWidth () const
 Gets the width of the image.
int getHeight () const
 Gets the height of the image.
iImageFormat getFormat () const
 Gets the image format.
int getBpp () const
 Gets the pixel depth of the image (bytes per pixel).
iImageType getType () const
 Gets the image type.
void setXOffset (int x)
 Sets the image's X offset.
void setYOffset (int y)
 Sets the image's Y offset.
int getXOffset () const
 Gets the image's X offset.
int getYOffset () const
 Gets the image's Y offset.
void setUnitType (iUnitType unit)
 Sets the image's physical unit type.
iUnitType getUnitType () const
 Gets the image's physical unit type.
void setXRes (int x)
 Sets the image's X resolution.
void setYRes (int y)
 Sets the image's Y resolution.
int getXRes () const
 Gets the image's X resolution.
int getYRes () const
 Gets the image's Y resolution.
void setOrigin (iImageOrigin org)
 Sets the origin of the image data.
iImageOrigin getOrigin () const
 Gets the origin of the image data.
void setWriteOrigin (iImageOrigin org)
 Sets the origin of the image data when writing an image.
iImageOrigin getWriteOrigin () const
 Gets the origin of the image data when writing an image.
void setCreationTime (const iDateTime &dt)
 Sets the image's creation time.
iDateTime getCreationTime () const
 Gets the image's creation time.
void updateCreationTime (bool bup)
 Sets whether or not the creation time should be updated when saving an image.
void setJobTime (const iJobTime &jt)
 Sets the amount of time invested in the image.
iJobTime getJobTime () const
 Gets the amount of time invested in the image.
void setAuthor (const char *name)
 Sets the author's name.
const char * getAuthor () const
 Returns a pointer to the author's name.
void setComment (const char *comm)
 Sets a comment for the image.
const char * getComment () const
 Returns a pointer to the image's comment.
void setClearCol (iColor col)
 Sets the image's clear color.
iColor getClearCol () const
 Gets the image's clear color.
bool hasPalette () const
 Checks whether or not this image contains color palette data.
iPalette setPalette (const iPalette &pal)
 Sets the color palette for this image.
iPalette getPalette () const
 Returns a copy of this image's color palette.
bool hasAlpha () const
 Checks whether or not the image contains an alpha channel.
iColor getPixel (int x, int y) const
 Gets the color of the pixel at the given coordinates.
iColor getPixel (int index) const
 Gets the color of the pixel at the given pixel index.
void setPixel (int x, int y, const iColor &col)
 Sets the color of the pixel at the given coordinates.
void setPixel (int index, const iColor &col)
 Sets the color of the pixel at the given pixel index.
int getPixelIndex (int x, int y) const
 Gets the index of the pixel at the given coordinates.
void setReadFunc (iReadCallback func)
 Sets the function that will be called whenever a row of image data is read.
void setWriteFunc (iWriteCallback func)
 Sets the function that will be called whenever a row of image data is written.
iAbstractImageoperator= (const iAbstractImage &img)

Protected Member Functions

void init ()
virtual bool loadImage ()=0
virtual bool saveImage ()=0

Protected Attributes

iSharedDatadata
 Shared image data.
int width
 Image width.
int height
 Image height.
iImageFormat format
 Image format.
int bpp
 Bytes per pixel.
int xoffset
 X offset.
int yoffset
 Y offset.
iColor clrcol
 Clear color.
iImageType type
 Image type.
iImageOrigin origin
 Image origin.
iImageOrigin worigin
 Image origin (when writing)
iPalette palette
 Color palette.
iUnitType unitType
 Unit density.
int XResolution
 X resolution.
int YResolution
 Y resolution.
iDateTime createTime
 Creation time.
bool updateTime
 Update creation time?
iJobTime jobTime
 Job time.
const char * author
 Author string.
const char * comment
 Comment string.
iDataStreamstream
 Data stream pointer.
iReadCallback readFunc
 Read row callback function pointer.
iWriteCallback writeFunc
 Write row callback function pointer.

Detailed Description

Abstract image class.

imagen uses implicit data sharing (commonly known as copy-on-write). You don't have to worry about freeing memory or inadvertently dirtying image data that belongs to other objects; it is all managed internally. When using the operator= or copy constructor, the image data is shared between the objects until one of them modifies it, at which point a new copy of the image data will be made.
All allocated image data will be automatically deleted when there are no more users attached to it.


Constructor & Destructor Documentation

Constructs a null image.

Copy constructor.

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

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::iAbstractImage::iAbstractImage ( 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()

Destructor.

Detaches itself from the image data, and deletes it if there are no other users attached to it.


Member Function Documentation

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

Loads an image file from disk.

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

Reimplemented in imagen::iImage.

bool imagen::iAbstractImage::load ( Iubyte buf,
int  len 
)

Loads an image from an existing memory buffer.

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

Reimplemented in imagen::iImage.

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 in imagen::iImage.

bool imagen::iAbstractImage::save ( const char *  filename)

Writes an image file to disk.

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

Reimplemented in imagen::iImage.

bool imagen::iAbstractImage::save ( Iubyte buf,
int  len 
)

Writes an image to an existing memory buffer.

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

Reimplemented in imagen::iImage.

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 in imagen::iImage.

void imagen::iAbstractImage::loadData ( Iubyte d,
int  w,
int  h,
iImageFormat  f,
int  b 
)

Loads image data from an existing memory buffer.

The memory buffer will not be deleted at destruction.

Parameters:
d: Memory buffer this image will point to.
w: Image width.
h: Image height.
f: Image format.
b: Bytes per pixel.
virtual void imagen::iAbstractImage::clear ( ) [virtual]

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

Reimplemented in imagen::iTGA, imagen::iBMP, imagen::iImage, imagen::iJPEG, imagen::iPNG, and imagen::iRawImage.

Detaches this image from the image data.

If there are no more users of the image data, it will be deleted.

Flips the image data vertically.

Flips the image data horizontally.

Rotates the image counterclockwise 90 degrees.

Warning:
This function doesn't work yet.

Rotates the image clockwise 90 degrees.

Warning:
This function doesn't work yet.

Rotates the image 180 degrees.

void imagen::iAbstractImage::fill ( const iColor col)

Fills the entire image with a given color.

bool imagen::iAbstractImage::pad ( int  top,
int  left,
int  bottom,
int  right,
iWrapMode  mode 
)

Pads the image data.

Returns:
True if successful, else false.
bool imagen::iAbstractImage::resize ( int  w,
int  h,
int  x,
int  y 
)

Resizes the image data.

This will resize the image to the dimensions given in w and h, and copy the original image to the pixel location given in x and y.
It does not rescale the source image.

Parameters:
w: New image width.
h: New image height.
x: X offset of source image.
y: Y offset of source image.
Returns:
True if successful, else false.

Swaps the red and blue components of all pixels.

void imagen::iAbstractImage::convertFormat ( iImageFormat  fmt,
int  alpha = 255 
)

Converts the image to the specified format.

Not all formats are supported yet. You can't convert from/to iMono or iRGB16, and you can't convert to iIndex.

Parameters:
fmt: The format to convert to.
alpha: The alpha value to use when converting from a format without an alpha channel to a format with an alpha channel.
int imagen::iAbstractImage::imageSize ( ) const [inline]

Returns the number of bytes occupied by the image data.

Checks whether or not the image is empty.

virtual bool imagen::iAbstractImage::isFormatSupported ( iImageFormat  fmt) const [pure 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.

Implemented in imagen::iTGA, imagen::iBMP, imagen::iImage, imagen::iJPEG, imagen::iPNG, and imagen::iRawImage.

Returns a pointer to the first byte of the image.

const Iubyte* imagen::iAbstractImage::getData ( ) const [inline]

Returns a const pointer to the first byte of the image.

int imagen::iAbstractImage::getWidth ( ) const [inline]

Gets the width of the image.

int imagen::iAbstractImage::getHeight ( ) const [inline]

Gets the height of the image.

Gets the image format.

int imagen::iAbstractImage::getBpp ( ) const [inline]

Gets the pixel depth of the image (bytes per pixel).

Gets the image type.

void imagen::iAbstractImage::setXOffset ( int  x) [inline]

Sets the image's X offset.

void imagen::iAbstractImage::setYOffset ( int  y) [inline]

Sets the image's Y offset.

int imagen::iAbstractImage::getXOffset ( ) const [inline]

Gets the image's X offset.

int imagen::iAbstractImage::getYOffset ( ) const [inline]

Gets the image's Y offset.

Sets the image's physical unit type.

Gets the image's physical unit type.

void imagen::iAbstractImage::setXRes ( int  x) [inline]

Sets the image's X resolution.

void imagen::iAbstractImage::setYRes ( int  y) [inline]

Sets the image's Y resolution.

int imagen::iAbstractImage::getXRes ( ) const [inline]

Gets the image's X resolution.

int imagen::iAbstractImage::getYRes ( ) const [inline]

Gets the image's Y resolution.

Sets the origin of the image data.

Gets the origin of the image data.

Sets the origin of the image data when writing an image.

Gets the origin of the image data when writing an image.

void imagen::iAbstractImage::setCreationTime ( const iDateTime dt) [inline]

Sets the image's creation time.

Gets the image's creation time.

void imagen::iAbstractImage::updateCreationTime ( bool  bup) [inline]

Sets whether or not the creation time should be updated when saving an image.

Choosing false means that when an image is written, the original creation time, if any, will be written to the image file; otherwise, the current time will be used.
For example, if you've loaded an image, and simply want to convert it to a different format rather than actually modifying the image, you may want to retain the original creation time of the image by setting this to false.
This is set to true by default.

void imagen::iAbstractImage::setJobTime ( const iJobTime jt) [inline]

Sets the amount of time invested in the image.

Gets the amount of time invested in the image.

void imagen::iAbstractImage::setAuthor ( const char *  name) [inline]

Sets the author's name.

const char* imagen::iAbstractImage::getAuthor ( ) const [inline]

Returns a pointer to the author's name.

void imagen::iAbstractImage::setComment ( const char *  comm) [inline]

Sets a comment for the image.

const char* imagen::iAbstractImage::getComment ( ) const [inline]

Returns a pointer to the image's comment.

Sets the image's clear color.

Many image file formats have a 'clear', 'background', or 'transparent' color that is the color used when the image data is cleared.

Gets the image's clear color.

Checks whether or not this image contains color palette data.

Sets the color palette for this image.

Returns a copy of this image's color palette.

Checks whether or not the image contains an alpha channel.

iColor imagen::iAbstractImage::getPixel ( int  x,
int  y 
) const

Gets the color of the pixel at the given coordinates.

Gets the color of the pixel at the given pixel index.

void imagen::iAbstractImage::setPixel ( int  x,
int  y,
const iColor col 
)

Sets the color of the pixel at the given coordinates.

void imagen::iAbstractImage::setPixel ( int  index,
const iColor col 
)

Sets the color of the pixel at the given pixel index.

int imagen::iAbstractImage::getPixelIndex ( int  x,
int  y 
) const

Gets the index of the pixel at the given coordinates.

Sets the function that will be called whenever a row of image data is read.

Sets the function that will be called whenever a row of image data is written.

iAbstractImage& imagen::iAbstractImage::operator= ( const iAbstractImage img)
void imagen::iAbstractImage::init ( ) [protected]
virtual bool imagen::iAbstractImage::loadImage ( ) [protected, pure virtual]
virtual bool imagen::iAbstractImage::saveImage ( ) [protected, pure virtual]

Member Data Documentation

Shared image data.

Image width.

Image height.

Image format.

int imagen::iAbstractImage::bpp [protected]

Bytes per pixel.

X offset.

Y offset.

Clear color.

Image type.

Image origin.

Image origin (when writing)

Color palette.

Unit density.

X resolution.

Y resolution.

Creation time.

Update creation time?

Job time.

const char* imagen::iAbstractImage::author [protected]

Author string.

const char* imagen::iAbstractImage::comment [protected]

Comment string.

Data stream pointer.

Read row callback function pointer.

Write row callback function pointer.


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