HOME | DOWNLOAD | DOCS | DEVELOPMENT | LICENSE | CREDITS |
Abstract image class. More...
#include <iAbstractImage.h>
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. | |
Iubyte * | getData () |
Returns a pointer to the first byte of the image. | |
const Iubyte * | getData () 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. | |
iAbstractImage & | operator= (const iAbstractImage &img) |
Protected Member Functions | |
void | init () |
virtual bool | loadImage ()=0 |
virtual bool | saveImage ()=0 |
Protected Attributes | |
iSharedData * | data |
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. | |
iDataStream * | stream |
Data stream pointer. | |
iReadCallback | readFunc |
Read row callback function pointer. | |
iWriteCallback | writeFunc |
Write row callback function pointer. |
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.
Constructs a null image.
imagen::iAbstractImage::iAbstractImage | ( | const iAbstractImage & | img | ) |
Copy constructor.
This copies all image attributes, and attaches itself to img's shared data.
imagen::iAbstractImage::iAbstractImage | ( | int | w, |
int | h, | ||
iImageFormat | f | ||
) |
Constructs an image with the given size and format.
The image data will be allocated, but not initialized.
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.
virtual imagen::iAbstractImage::~iAbstractImage | ( | ) | [virtual] |
Destructor.
Detaches itself from the image data, and deletes it if there are no other users attached to it.
bool imagen::iAbstractImage::load | ( | const char * | filename | ) |
Loads an image file from disk.
filename | : The name of the image to load. |
Reimplemented in imagen::iImage.
bool imagen::iAbstractImage::load | ( | Iubyte * | buf, |
int | len | ||
) |
Loads an image from an existing memory buffer.
buf | : Pointer to a memory buffer. |
len | : Size of the memory buffer. |
Reimplemented in imagen::iImage.
bool imagen::iAbstractImage::load | ( | iDataStream * | s | ) |
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.
Reimplemented in imagen::iImage.
bool imagen::iAbstractImage::save | ( | const char * | filename | ) |
Writes an image file to disk.
filename | : The name to save the image as. |
Reimplemented in imagen::iImage.
bool imagen::iAbstractImage::save | ( | Iubyte * | buf, |
int | len | ||
) |
Writes an image to an existing memory buffer.
buf | : Pointer to a memory buffer. |
len | : Size of the memory buffer. |
Reimplemented in imagen::iImage.
bool imagen::iAbstractImage::save | ( | iDataStream * | s | ) |
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.
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.
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.
void imagen::iAbstractImage::detachData | ( | ) |
Detaches this image from the image data.
If there are no more users of the image data, it will be deleted.
void imagen::iAbstractImage::flipVertical | ( | ) |
Flips the image data vertically.
Flips the image data horizontally.
void imagen::iAbstractImage::rotateLeft | ( | ) |
Rotates the image counterclockwise 90 degrees.
void imagen::iAbstractImage::rotateRight | ( | ) |
Rotates the image clockwise 90 degrees.
void imagen::iAbstractImage::rotate180 | ( | ) |
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.
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.
w | : New image width. |
h | : New image height. |
x | : X offset of source image. |
y | : Y offset of source image. |
void imagen::iAbstractImage::swapRGB | ( | ) |
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.
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.
bool imagen::iAbstractImage::isNull | ( | ) | const |
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.
Implemented in imagen::iTGA, imagen::iBMP, imagen::iImage, imagen::iJPEG, imagen::iPNG, and imagen::iRawImage.
Iubyte* imagen::iAbstractImage::getData | ( | ) | [inline] |
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.
iImageFormat imagen::iAbstractImage::getFormat | ( | ) | const [inline] |
Gets the image format.
int imagen::iAbstractImage::getBpp | ( | ) | const [inline] |
Gets the pixel depth of the image (bytes per pixel).
iImageType imagen::iAbstractImage::getType | ( | ) | const [inline] |
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.
void imagen::iAbstractImage::setUnitType | ( | iUnitType | unit | ) | [inline] |
Sets the image's physical unit type.
iUnitType imagen::iAbstractImage::getUnitType | ( | ) | const [inline] |
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.
void imagen::iAbstractImage::setOrigin | ( | iImageOrigin | org | ) | [inline] |
Sets the origin of the image data.
iImageOrigin imagen::iAbstractImage::getOrigin | ( | ) | const [inline] |
Gets the origin of the image data.
void imagen::iAbstractImage::setWriteOrigin | ( | iImageOrigin | org | ) | [inline] |
Sets the origin of the image data when writing an image.
iImageOrigin imagen::iAbstractImage::getWriteOrigin | ( | ) | const [inline] |
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.
iDateTime imagen::iAbstractImage::getCreationTime | ( | ) | const [inline] |
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.
iJobTime imagen::iAbstractImage::getJobTime | ( | ) | const [inline] |
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.
void imagen::iAbstractImage::setClearCol | ( | iColor | col | ) | [inline] |
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.
iColor imagen::iAbstractImage::getClearCol | ( | ) | const [inline] |
Gets the image's clear color.
bool imagen::iAbstractImage::hasPalette | ( | ) | const |
Checks whether or not this image contains color palette data.
iPalette imagen::iAbstractImage::setPalette | ( | const iPalette & | pal | ) | [inline] |
Sets the color palette for this image.
iPalette imagen::iAbstractImage::getPalette | ( | ) | const [inline] |
Returns a copy of this image's color palette.
bool imagen::iAbstractImage::hasAlpha | ( | ) | const |
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.
iColor imagen::iAbstractImage::getPixel | ( | int | index | ) | const |
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.
void imagen::iAbstractImage::setReadFunc | ( | iReadCallback | func | ) | [inline] |
Sets the function that will be called whenever a row of image data is read.
void imagen::iAbstractImage::setWriteFunc | ( | iWriteCallback | func | ) | [inline] |
Sets the function that will be called whenever a row of image data is written.
iAbstractImage& imagen::iAbstractImage::operator= | ( | const iAbstractImage & | img | ) |
Reimplemented in imagen::iTGA, imagen::iBMP, imagen::iImage, imagen::iJPEG, imagen::iPNG, and imagen::iRawImage.
void imagen::iAbstractImage::init | ( | ) | [protected] |
Reimplemented in imagen::iTGA, imagen::iBMP, imagen::iImage, imagen::iJPEG, imagen::iPNG, and imagen::iRawImage.
virtual bool imagen::iAbstractImage::loadImage | ( | ) | [protected, pure virtual] |
Implemented in imagen::iTGA, imagen::iBMP, imagen::iImage, imagen::iJPEG, imagen::iPNG, and imagen::iRawImage.
virtual bool imagen::iAbstractImage::saveImage | ( | ) | [protected, pure virtual] |
Implemented in imagen::iTGA, imagen::iBMP, imagen::iImage, imagen::iJPEG, imagen::iPNG, and imagen::iRawImage.
iSharedData* imagen::iAbstractImage::data [protected] |
Shared image data.
int imagen::iAbstractImage::width [protected] |
Image width.
int imagen::iAbstractImage::height [protected] |
Image height.
iImageFormat imagen::iAbstractImage::format [protected] |
Image format.
int imagen::iAbstractImage::bpp [protected] |
Bytes per pixel.
int imagen::iAbstractImage::xoffset [protected] |
X offset.
int imagen::iAbstractImage::yoffset [protected] |
Y offset.
iColor imagen::iAbstractImage::clrcol [protected] |
Clear color.
iImageType imagen::iAbstractImage::type [protected] |
Image type.
iImageOrigin imagen::iAbstractImage::origin [protected] |
Image origin.
iImageOrigin imagen::iAbstractImage::worigin [protected] |
Image origin (when writing)
iPalette imagen::iAbstractImage::palette [protected] |
Color palette.
iUnitType imagen::iAbstractImage::unitType [protected] |
Unit density.
int imagen::iAbstractImage::XResolution [protected] |
X resolution.
int imagen::iAbstractImage::YResolution [protected] |
Y resolution.
iDateTime imagen::iAbstractImage::createTime [protected] |
Creation time.
bool imagen::iAbstractImage::updateTime [protected] |
Update creation time?
iJobTime imagen::iAbstractImage::jobTime [protected] |
Job time.
const char* imagen::iAbstractImage::author [protected] |
Author string.
const char* imagen::iAbstractImage::comment [protected] |
Comment string.
iDataStream* imagen::iAbstractImage::stream [protected] |
Data stream pointer.
iReadCallback imagen::iAbstractImage::readFunc [protected] |
Read row callback function pointer.
iWriteCallback imagen::iAbstractImage::writeFunc [protected] |
Write row callback function pointer.
API Documentation by Mark D. Procarione | Generated by |