ImageFile Class Reference
[Framework Module]

#include <imagefile.h>

Inheritance diagram for ImageFile:

DataFile TgaImageFile

List of all members.


Detailed Description

Provides read / write access to iamge file.

This class is the base for all image files.

Public Types

enum  Format { IF_UNKNOWN, IF_LUMINANCE, IF_RGB, IF_RGBA }

Public Member Functions

 ImageFile ()
virtual ~ImageFile ()
virtual ulong_t LoadData ()
Format GetFormat ()
bool TestFormat (ImageFile::Format format)
byte_tGetData (bool close=false)
ushort_t GetWidth ()
ushort_t GetHeight ()
void SetData (byte_t *data, ulong_t size, Format format, ushort_t width, ushort_t height)
void CopyData (const byte_t *data, ulong_t size, Format format, ushort_t width, ushort_t height)
void CopyData (ImageFile *image)
bool AddOverlay (ImageFile *overlay_image, const vector3 &overlay_color)
void Resample (ushort_t new_width, ushort_t new_height)

Static Public Member Functions

static byte_t GetBytesPerPixel (ImageFile::Format format)

Protected Attributes

Format format
 Format of the image.
ushort_t width
 Image width.
ushort_t height
 Image height.
byte_tdata
 Loaded image data (simple buffer).
bool use_free
 Use free() instead of delete for releasing image data.

Private Member Functions

virtual void DeleteData ()


Member Enumeration Documentation

enum ImageFile::Format

Format of image data.

Enumerator:
IF_UNKNOWN  Unknown format.
IF_LUMINANCE  Grayscale 8bit.
IF_RGB  RGB 24bit.
IF_RGBA  RGB+Alpha 32bit.


Constructor & Destructor Documentation

ImageFile::ImageFile (  ) 

Constructor. Sets file mode to binary.

ImageFile::~ImageFile (  )  [virtual]

Deletes data. This data can be set only by Set method in this class.


Member Function Documentation

ulong_t ImageFile::LoadData (  )  [virtual]

Loads data from opened file. Data has to be unloaded before. This function should be redefined in derived classes.

Returns:
Size of loaded data.

Reimplemented from DataFile.

Reimplemented in TgaImageFile.

ImageFile::Format ImageFile::GetFormat (  )  [inline]

Returns image format.

Returns:
Image format.

bool ImageFile::TestFormat ( ImageFile::Format  format  )  [inline]

Tests image format.

Parameters:
format Image format to be tested.
Returns:
True if given format is as same as image format.

byte_t * ImageFile::GetData ( bool  close = false  )  [inline]

Returns loaded image data.

Parameters:
close Whether file will be closed after returning the data.
Returns:
Loaded image data.

ushort_t ImageFile::GetWidth (  )  [inline]

Returns image width.

Returns:
Image width.

ushort_t ImageFile::GetHeight (  )  [inline]

Returns image height.

Returns:
Image height.

void ImageFile::SetData ( byte_t data,
ulong_t  size,
Format  format,
ushort_t  width,
ushort_t  height 
)

Sets new image data. Old data will be deleted.

Parameters:
data Memory buffer with image data.
size Size of memory buffer.
format Format of image data stored in buffer.
width Image width.
height Image height.

void ImageFile::CopyData ( const byte_t data,
ulong_t  size,
Format  format,
ushort_t  width,
ushort_t  height 
)

Copys new image data from given memory buffer. Old data will be deleted.

Parameters:
data Memory buffer with image data.
size Size of memory buffer.
format Format of image data stored in buffer.
width Image width.
height Image height.

void ImageFile::CopyData ( ImageFile image  ) 

Copys new image data from given ImageFile. Old data will be deleted.

Parameters:
image ImageFile object.

bool ImageFile::AddOverlay ( ImageFile overlay_image,
const vector3 overlay_color 
)

Adds overlay image to current image data.

Parameters:
overlay_image ImageFile object with overlay image.
overlay_color Color used for coloring overlay image.
Returns:
True if successful.

void ImageFile::Resample ( ushort_t  new_width,
ushort_t  new_height 
)

Resample current image data to new size.

Parameters:
new_width New width of image.
new_height New height of image.

byte_t ImageFile::GetBytesPerPixel ( ImageFile::Format  format  )  [inline, static]

Returns number of bytes per pixel of given image format.

Parameters:
format Image format.
Returns:
Bytes per pixel.

void ImageFile::DeleteData (  )  [private, virtual]

Deletes loaded data.

Implements DataFile.


Member Data Documentation

Format ImageFile::format [protected]

Format of the image.

ushort_t ImageFile::width [protected]

Image width.

ushort_t ImageFile::height [protected]

Image height.

byte_t* ImageFile::data [protected]

Loaded image data (simple buffer).

bool ImageFile::use_free [protected]

Use free() instead of delete for releasing image data.


The documentation for this class was generated from the following files:
Generated on Sat Oct 20 14:47:32 2007 for Dark Oberon by  doxygen 1.5.3