Spinning Topp Logo BlackTopp Studios
inc
Public Member Functions | Protected Attributes | List of all members
Mezzanine::Graphics::Image Class Reference

This class represents an image loaded into system memory. More...

#include <image.h>

+ Collaboration diagram for Mezzanine::Graphics::Image:

Public Member Functions

 Image ()
 Blank, no-init constructor.
 
 Image (const String &ResourceName, const String &ResourceGroup)
 Resource constructor. More...
 
 Image (UInt8 *Data, const UInt32 Width, const UInt32 Height, const Graphics::PixelFormat Format, const Boole AutoDelete=false, const Whole NumFaces=1, const UInt8 NumMipMaps=0)
 2D image buffer constructor. More...
 
 Image (UInt8 *Data, const UInt32 Width, const UInt32 Height, const UInt32 Depth, const Graphics::PixelFormat Format, const Boole AutoDelete=false, const Whole NumFaces=1, const UInt8 NumMipMaps=0)
 3D image buffer constructor. More...
 
 ~Image ()
 Class Destructor.
 
Ogre::Image & _GetInternalImage () const
 Gets the internal Image this class is based on. More...
 
ImageFlipAroundXAxis ()
 Reverses the order of each pixel on the X axis. More...
 
ImageFlipAroundYAxis ()
 Reverses the order of each pixel on the Y axis. More...
 
UInt8 GetBitsPerPixel () const
 Gets the number of bits allocated for each pixel in this image. More...
 
ColourValue GetColourAt (const Whole X, const Whole Y, const Whole Z) const
 Gets the colour of an individual pixel in this image. More...
 
UInt32 GetDepth () const
 Gets the depth of this image in pixels. More...
 
Graphics::PixelFormat GetFormat () const
 Gets the pixel format of this image. More...
 
UInt32 GetHeight () const
 Gets the height of this image in pixels. More...
 
UInt8GetImageData ()
 Gets the raw image data. More...
 
const UInt8GetImageData () const
 Gets the raw image data. More...
 
Whole GetNumFaces () const
 Gets the number of faces for thie image. More...
 
Whole GetNumMipMaps () const
 Gets the number of MipMaps that exist for this image. More...
 
Whole GetRowSpan () const
 Gets the size of a row of pixels in this image. More...
 
Whole GetSize () const
 Gets the size of this image. More...
 
UInt32 GetWidth () const
 Gets the width of this image in pixels. More...
 
ImageInitialize (UInt8 *Data, const UInt32 Width, const UInt32 Height, const Graphics::PixelFormat Format, const Boole AutoDelete=false, const Whole NumFaces=1, const UInt8 NumMipMaps=0)
 Loads an image from a buffer. More...
 
ImageInitialize (UInt8 *Data, const UInt32 Width, const UInt32 Height, const UInt32 Depth, const Graphics::PixelFormat Format, const Boole AutoDelete=false, const Whole NumFaces=1, const UInt8 NumMipMaps=0)
 Loads an image from a buffer. More...
 
ImageLoad (const String &ResourceName, const String &ResourceGroup)
 Loads an image. More...
 
ImageLoad (const String &FilePathAndName)
 Loads an image from the disk. More...
 
ImageLoad (std::istream *Stream, const String &ExtensionHint="")
 Loads an image from an input stream. More...
 
ImageSave (const String &FileName, const String &GroupName)
 Writes this image to the asset group. More...
 
ImageSave (const String &FilePathAndName)
 Writes this image to the disk. More...
 
ImageSave (const Graphics::ImageFileFormat Format, std::ostream *Stream)
 Writes this image in a final serializable form to an output stream. More...
 
ImageSave (const String &Extension, std::ostream *Stream)
 Writes this image in a final serializable form to an output stream. More...
 
void SetColourAt (const Whole X, const Whole Y, const Whole Z, const ColourValue &Colour)
 Sets the colour of an individual pixel in this image. More...
 

Protected Attributes

InternalImageDataIID
 A pointer to the internal implementation of the Image. More...
 

Detailed Description

This class represents an image loaded into system memory.

Definition at line 63 of file image.h.

Constructor & Destructor Documentation

Mezzanine::Graphics::Image::Image ( const String ResourceName,
const String ResourceGroup 
)

Resource constructor.

Parameters
ResourceNameThe name of the resource to be loaded.
ResourceGroupThe name of the group the resource is located in.

Definition at line 77 of file image.cpp.

Mezzanine::Graphics::Image::Image ( UInt8 Data,
const UInt32  Width,
const UInt32  Height,
const Graphics::PixelFormat  Format,
const Boole  AutoDelete = false,
const Whole  NumFaces = 1,
const UInt8  NumMipMaps = 0 
)

2D image buffer constructor.

Parameters
DataThe buffer to load the image from.
WidthThe width of the image to be loaded.
HeightThe height of the image to be loaded.
FormatThe pixel format of the buffer being loaded.
AutoDeleteWhether or not this image owns the buffer, allowing it to delete the buffer when it is done.
NumFacesThe number of faces that exist for the image.
NumMipMapsThe number of mipmaps that exist for the image.

Definition at line 83 of file image.cpp.

Mezzanine::Graphics::Image::Image ( UInt8 Data,
const UInt32  Width,
const UInt32  Height,
const UInt32  Depth,
const Graphics::PixelFormat  Format,
const Boole  AutoDelete = false,
const Whole  NumFaces = 1,
const UInt8  NumMipMaps = 0 
)

3D image buffer constructor.

Parameters
DataThe buffer to load the image from.
WidthThe width of the image to be loaded.
HeightThe height of the image to be loaded.
DepthThe depth of the image to be loaded.
FormatThe pixel format of the buffer being loaded.
AutoDeleteWhether or not this image owns the buffer, allowing it to delete the buffer when it is done.
NumFacesThe number of faces that exist for the image.
NumMipMapsThe number of mipmaps that exist for the image.

Definition at line 89 of file image.cpp.

Member Function Documentation

Ogre::Image & Mezzanine::Graphics::Image::_GetInternalImage ( ) const

Gets the internal Image this class is based on.

Returns
Returns a reference to the internal image class.

Definition at line 226 of file image.cpp.

Image & Mezzanine::Graphics::Image::FlipAroundXAxis ( )

Reverses the order of each pixel on the X axis.

Returns
Returns a reference to this.

Definition at line 134 of file image.cpp.

Image & Mezzanine::Graphics::Image::FlipAroundYAxis ( )

Reverses the order of each pixel on the Y axis.

Returns
Returns a reference to this.

Definition at line 140 of file image.cpp.

UInt8 Mezzanine::Graphics::Image::GetBitsPerPixel ( ) const

Gets the number of bits allocated for each pixel in this image.

Returns
Returns a UInt8 containing the size of each pixel in bits.

Definition at line 113 of file image.cpp.

ColourValue Mezzanine::Graphics::Image::GetColourAt ( const Whole  X,
const Whole  Y,
const Whole  Z 
) const

Gets the colour of an individual pixel in this image.

Parameters
XThe X position of the pixel to retrieve.
YThe Y position of the pixel to retrieve.
ZThe Z position of the pixel to retrieve.
Returns
Returns a ColourValue containing the colour of the pixel at the specified position.

Definition at line 149 of file image.cpp.

UInt32 Mezzanine::Graphics::Image::GetDepth ( ) const

Gets the depth of this image in pixels.

Returns
Returns a UInt32 representing the size of this image on the Z axis.

Definition at line 107 of file image.cpp.

Graphics::PixelFormat Mezzanine::Graphics::Image::GetFormat ( ) const

Gets the pixel format of this image.

Returns
Returns a PixelFormat enum value representing how the bits of this image are layed out.

Definition at line 110 of file image.cpp.

UInt32 Mezzanine::Graphics::Image::GetHeight ( ) const

Gets the height of this image in pixels.

Returns
Returns a UInt32 representing the size of this image on the Y axis.

Definition at line 104 of file image.cpp.

UInt8 * Mezzanine::Graphics::Image::GetImageData ( )

Gets the raw image data.

Returns
Returns a pointer to the array storing the raw data for this image.

Definition at line 122 of file image.cpp.

const UInt8 * Mezzanine::Graphics::Image::GetImageData ( ) const

Gets the raw image data.

Returns
Returns a const pointer to the array storing the raw data for this image.

Definition at line 125 of file image.cpp.

Whole Mezzanine::Graphics::Image::GetNumFaces ( ) const

Gets the number of faces for thie image.

Remarks
Generally this will either be 1 for a normal image, or 6 for a cubemap.
Returns
Returns a Whole representing the number of faces this image has.

Definition at line 116 of file image.cpp.

Whole Mezzanine::Graphics::Image::GetNumMipMaps ( ) const

Gets the number of MipMaps that exist for this image.

Returns
Returns the number of MipMaps this image has.

Definition at line 119 of file image.cpp.

Whole Mezzanine::Graphics::Image::GetRowSpan ( ) const

Gets the size of a row of pixels in this image.

Returns
Returns a Whole representing the byte size of a row of pixels in this image.

Definition at line 131 of file image.cpp.

Whole Mezzanine::Graphics::Image::GetSize ( ) const

Gets the size of this image.

Returns
Returns a Whole representing the total size of this image in bytes.

Definition at line 128 of file image.cpp.

UInt32 Mezzanine::Graphics::Image::GetWidth ( ) const

Gets the width of this image in pixels.

Returns
Returns a UInt32 representing the size of this image on the X axis.

Definition at line 101 of file image.cpp.

Image & Mezzanine::Graphics::Image::Initialize ( UInt8 Data,
const UInt32  Width,
const UInt32  Height,
const Graphics::PixelFormat  Format,
const Boole  AutoDelete = false,
const Whole  NumFaces = 1,
const UInt8  NumMipMaps = 0 
)

Loads an image from a buffer.

Parameters
DataThe buffer to load the image from.
WidthThe width of the image to be loaded.
HeightThe height of the image to be loaded.
FormatThe pixel format of the buffer being loaded.
AutoDeleteWhether or not this image owns the buffer, allowing it to delete the buffer when it is done.
NumFacesThe number of faces that exist for the image.
NumMipMapsThe number of mipmaps that exist for the image.
Returns
Returns a reference to this.

Definition at line 155 of file image.cpp.

Image & Mezzanine::Graphics::Image::Initialize ( UInt8 Data,
const UInt32  Width,
const UInt32  Height,
const UInt32  Depth,
const Graphics::PixelFormat  Format,
const Boole  AutoDelete = false,
const Whole  NumFaces = 1,
const UInt8  NumMipMaps = 0 
)

Loads an image from a buffer.

Parameters
DataThe buffer to load the image from.
WidthThe width of the image to be loaded.
HeightThe height of the image to be loaded.
DepthThe depth of the image to be loaded.
FormatThe pixel format of the buffer being loaded.
AutoDeleteWhether or not this image owns the buffer, allowing it to delete the buffer when it is done.
NumFacesThe number of faces that exist for the image.
NumMipMapsThe number of mipmaps that exist for the image.
Returns
Returns a reference to this.

Definition at line 161 of file image.cpp.

Image & Mezzanine::Graphics::Image::Load ( const String ResourceName,
const String ResourceGroup 
)

Loads an image.

Parameters
ResourceNameThe name of the resource to be loaded.
ResourceGroupThe name of the group the resource is located in.
Returns
Returns a reference to this.

Definition at line 170 of file image.cpp.

Image & Mezzanine::Graphics::Image::Load ( const String FilePathAndName)

Loads an image from the disk.

Parameters
FilePathAndNameThe full path and filename of the image to be read.
Returns
Returns a reference to this.

Definition at line 176 of file image.cpp.

Image & Mezzanine::Graphics::Image::Load ( std::istream *  Stream,
const String ExtensionHint = "" 
)

Loads an image from an input stream.

Parameters
StreamA pointer to the stream to load this image from.
ExtensionHintThe extension (not including the period) that this stream should be read as. Can be blank to auto-detect.
Returns
Returns a reference to this.

Definition at line 186 of file image.cpp.

Image & Mezzanine::Graphics::Image::Save ( const String FileName,
const String GroupName 
)

Writes this image to the asset group.

Remarks
This method will infer the encoding from the provided file extension which needs to be included in the FileName parameter. Check the ImageFileFormat enum for details on which formats/extensions have write support. Also keep in mind that different file formats have support for different pixel formats. Ensure you are encoding to something that can support the currently set pixel format otherwise you risk generating a corrupted image.
Parameters
FileNameThe name of the file to save this as.
GroupNameThe name of the asset group to save this to.
Returns
Returns a reference to this.

Definition at line 196 of file image.cpp.

Image & Mezzanine::Graphics::Image::Save ( const String FilePathAndName)

Writes this image to the disk.

Remarks
This method will infer the encoding from the provided file extension which needs to be included in the FileName parameter. Check the ImageFileFormat enum for details on which formats/extensions have write support. Also keep in mind that different file formats have support for different pixel formats. Ensure you are encoding to something that can support the currently set pixel format otherwise you risk generating a corrupted image.

This method also completely bypasses the bulk of the Mezzanine resource system and writes directly to the filesystem. Use with care.
Parameters
FilePathAndNameThe full path and filename of the image to be written.
Returns
Returns a reference to this.

Definition at line 202 of file image.cpp.

Image & Mezzanine::Graphics::Image::Save ( const Graphics::ImageFileFormat  Format,
std::ostream *  Stream 
)

Writes this image in a final serializable form to an output stream.

Remarks
Keep in mind that different file formats have support for different pixel formats. Ensure you are encoding to something that can support the currently set pixel format otherwise you risk generating a corrupted image.
Parameters
FormatThe ImageFileFormat to encode the image with.
StreamA pointer to the stream to save this image to.
Returns
Returns a reference to this.

Definition at line 209 of file image.cpp.

Image & Mezzanine::Graphics::Image::Save ( const String Extension,
std::ostream *  Stream 
)

Writes this image in a final serializable form to an output stream.

Remarks
This method will infer the encoding from the provided file extension. Keep in mind that different file formats have support for different pixel formats. Ensure you are encoding to something that can support the currently set pixel format otherwise you risk generating a corrupted image.
Parameters
ExtensionA string containing the extension to encode to (not including the period).
StreamA pointer to the stream to save this image to.
Returns
Returns a reference to this.

Definition at line 215 of file image.cpp.

void Mezzanine::Graphics::Image::SetColourAt ( const Whole  X,
const Whole  Y,
const Whole  Z,
const ColourValue Colour 
)

Sets the colour of an individual pixel in this image.

Parameters
XThe X position of the pixel to alter.
YThe Y position of the pixel to alter.
ZThe Z position of the pixel to alter.
ColourThe colour to set for the pixel at the specified position.

Definition at line 146 of file image.cpp.

Member Data Documentation

InternalImageData* Mezzanine::Graphics::Image::IID
protected

A pointer to the internal implementation of the Image.

Definition at line 68 of file image.h.


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