Rasterfarm-SDK
Loading...
Searching...
No Matches
Image Class Referenceabstract

#include <image.h>

Inheritance diagram for Image:
JpegImage PngImage TgaImage TgaCompressedImage TgaUncompressedImage

Public Types

enum  Format {
  RGB_565 ,
  RGB_888 ,
  BGR_888 ,
  RGBA_8888 ,
  BGRA_8888 ,
  RGBA_5551 ,
  RGBA_4444 ,
  BGRA_4444 ,
  ALPHA_8 ,
  GRAY_8 ,
  GRAY_16 ,
  GRAY_ALPHA_8_8 ,
  GRAY_ALPHA_15_1 ,
  DEPTH_8 ,
  DEPTH_16 ,
  DEPTH_24
}
 

Public Member Functions

 Image (const char *filename)
 
virtual ~Image ()
 
virtual Byte * allocAndCreatePixels ()=0
 
virtual void save (const char *file)=0
 
uint getWidth () const
 
uint getHeight () const
 
Format getFormat () const
 
Byte * getData () const
 

Static Public Member Functions

static ImagecreateImage (const char *filename)
 
static bool isValid (const char *filename, const ByteArray &magic)
 
static size_t byteSize (PixelFormat pixelFormat)
 
static Format convert (PixelFormat pixelFormat)
 
static bool hasAlpha (PixelFormat pixelFormat)
 
static PixelFormat removeAlpha (PixelFormat pixelFormat)
 

Public Attributes

size_t dataSize
 

Protected Attributes

uint width
 
uint height
 
uint channels
 
Format format
 
Byte * pData
 

Detailed Description

ADT Class for managing image data. Derived-types would include jpeg, png,

ADT for Image decoding.

Member Enumeration Documentation

◆ Format

Enumerator
RGB_565 
RGB_888 
BGR_888 
RGBA_8888 
BGRA_8888 
RGBA_5551 
RGBA_4444 
BGRA_4444 
ALPHA_8 

Alhpa image, typically used as a mask.

GRAY_8 

A grey-scaled image.

GRAY_16 

A grey-scaled image.

GRAY_ALPHA_8_8 

A grey-scaled image with alpha channel.

GRAY_ALPHA_15_1 

A grey-scaled image with alpha bit. This is generally used for producing holes.

DEPTH_8 
DEPTH_16 
DEPTH_24 

Constructor & Destructor Documentation

◆ Image()

Image::Image ( const char * filename)

◆ ~Image()

virtual Image::~Image ( )
virtual

Member Function Documentation

◆ allocAndCreatePixels()

virtual Byte * Image::allocAndCreatePixels ( )
pure virtual

Creates a new array of pixels on the heap. Caller must delete as this data is not managed.

Returns
Byte array.

Implemented in JpegImage, PngImage, TgaCompressedImage, TgaImage, and TgaUncompressedImage.

◆ byteSize()

static size_t Image::byteSize ( PixelFormat pixelFormat)
static

Get the number of bytes per pixel for a given PixelFormat.

Returns
Size in bytes per pixel for the given PixelFormat.

◆ convert()

static Format Image::convert ( PixelFormat pixelFormat)
static

Get the number of bytes per pixel for a given PixelFormat.

Returns
The appropriate Image::Format for the given PixelFormat.

◆ createImage()

static Image * Image::createImage ( const char * filename)
static

Creates a new Image automagically, resulting object will be of a derived-type depending on encoding(eg. JpegImage). The caller is reponsible for destroying this object.

Returns
Image pointer to new object.

◆ getData()

Byte * Image::getData ( ) const
inline

◆ getFormat()

Format Image::getFormat ( ) const
inline

◆ getHeight()

uint Image::getHeight ( ) const
inline

◆ getWidth()

uint Image::getWidth ( ) const
inline

◆ hasAlpha()

static bool Image::hasAlpha ( PixelFormat pixelFormat)
static
Returns
True if the PixelFormat has an alpha component.

◆ isValid()

static bool Image::isValid ( const char * filename,
const ByteArray & magic )
static
Returns
True if the file is a valid JPEG and can be decoded.

◆ removeAlpha()

static PixelFormat Image::removeAlpha ( PixelFormat pixelFormat)
static

Get the alpha-less format best matches the given Format containing an alpha component.

Returns
The appropriate PixelFormat::Format for the given PixelFormat without an alpha component.

◆ save()

virtual void Image::save ( const char * file)
pure virtual

Saves a texture to the filesystem.

Parameters
Pointerto texture.
Thetexture's target-data to save. If not specified the QUAD target will be selected.

Implemented in JpegImage, PngImage, TgaImage, and TgaUncompressedImage.

Member Data Documentation

◆ channels

uint Image::channels
protected

Also known as components (eg. red, green, blue, alpha)

◆ dataSize

size_t Image::dataSize

◆ format

Format Image::format
protected

◆ height

uint Image::height
protected

◆ pData

Byte* Image::pData
protected

◆ width

uint Image::width
protected

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