Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Ogre::Image Class Reference

Class representing an image file. More...

#include <OgreImage.h>

List of all members.

Public Methods

 Image ()
 Standard constructor.

 Image (const Image &img)
 Copy-constructor - copies all the data from the target image.

virtual ~Image ()
 Standard destructor.

Image & operator= (const Image &img)
 Assignment operator- copies all the data from the target image.

Image & flipAroundY ()
 Flips (mirrors) the image around the Y-axis.

Image & flipAroundX ()
 Flips (mirrors) the image around the X-axis.

Image & loadRawData (const DataChunk &pData, ushort uWidth, ushort uHeight, PixelFormat eFormat)
 Loads raw data from memory.

Image & load (const String &strFileName)
 Loads an image file.

Image & load (const DataChunk &chunk, const String &type)
 Loads an image file from a chunk of memory.

uchargetData (void)
 Returns a pointer to the internal image buffer.

const uchargetData () const
 Returns a const pointer to the internal image buffer.

size_t getSize () const
 Returns the size of the data buffer.

unsigned short getNumMipmaps () const
 Returns the number of mipmaps contained in the image.

bool hasFlag (const ImageFlags imgFlag)
 Returns true if the image has the appropriate flag set.

ushort getWidth (void) const
 Gets the width of the image in pixels.

ushort getHeight (void) const
 Gets the height of the image in pixels.

ushort getDepth (void) const
 Gets the depth of the image.

ushort getRowSpan (void) const
 Gets the physical width in bytes of each row of pixels.

PixelFormat getFormat () const
 Returns the image format.

uchar getBPP () const
 Returns the number of bits per pixel.

bool getHasAlpha () const
 Returns true if the image has an alpha component.


Static Public Methods

uchar PF2PS (PixelFormat format)
uchar getNumElemBytes (PixelFormat format)
 Returns the size in bytes of an element of the given pixel format.

uchar PF2BPP (PixelFormat format)
uchar getNumElemBits (PixelFormat format)
 Returns the size in bits of an element of the given pixel format.

bool convReqsFlip (PixelFormat srcformat, PixelFormat destformat)
 Decides wether converting from a pixel format to another requires endian-flipping.

void applyGamma (uchar *buffer, Real gamma, size_t size, uchar bpp)
 Does gamma adjustment.

bool formatHasAlpha (PixelFormat format)

Private Attributes

ushort m_uWidth
ushort m_uHeight
ushort m_uDepth
uint m_uSize
ushort m_uNumMipmaps
int m_uFlags
PixelFormat m_eFormat
uchar m_ucPixelSize
ucharm_pBuffer


Detailed Description

Class representing an image file.

Remarks:
The Image class usually holds uncompressed image data and is the only object that can be loaded in a texture. Image objects handle image data decoding themselves by the means of locating the correct Codec object for each data type.

Typically, you would want to use an Image object to load a texture when extra processing needs to be done on an image before it is loaded or when you want to blit to an existing texture.

Definition at line 51 of file OgreImage.h.


Constructor & Destructor Documentation

Ogre::Image::Image  
 

Standard constructor.

Definition at line 36 of file OgreImage.cpp.

Ogre::Image::Image const Image &    img
 

Copy-constructor - copies all the data from the target image.

Definition at line 46 of file OgreImage.cpp.

Ogre::Image::~Image   [virtual]
 

Standard destructor.

Definition at line 53 of file OgreImage.cpp.

References m_pBuffer.


Member Function Documentation

void Ogre::Image::applyGamma uchar   buffer,
Real    gamma,
size_t    size,
uchar    bpp
[static]
 

Does gamma adjustment.

Note:
Basic algo taken from Titan Engine, copyright (c) 2000 Ignacio Castano Iguado

bool Ogre::Image::convReqsFlip PixelFormat    srcformat,
PixelFormat    destformat
[static]
 

Decides wether converting from a pixel format to another requires endian-flipping.

Parameters:
srcformat  The source pixel format.
destformat  The destination pixel format.
Returns:
true if the conversion requires flipping, false otherwise. See Remarks.
Remarks:
If one of the two pixel formats is FMT_UNKNOWN or is not registered, no assumption can be made for the returned value.

Definition at line 255 of file OgreImage.h.

References Ogre::PF_A2R10G10B10, Ogre::PF_A4L4, Ogre::PF_A4R4G4B4, Ogre::PF_A8R8G8B8, Ogre::PF_R5G6B5, Ogre::PF_R8G8B8, Ogre::PixelFormat, and Ogre::uchar.

Image & Ogre::Image::flipAroundX  
 

Flips (mirrors) the image around the X-axis.

Remarks:
An example of an original and flipped image:
                        flip axis
                            |
                originalimg|gmilanigiro
                00000000000|00000000000
                00000000000|00000000000
                00000000000|00000000000
                00000000000|00000000000
                00000000000|00000000000
                

Definition at line 175 of file OgreImage.cpp.

References Except, m_pBuffer, m_ucPixelSize, m_uHeight, m_uWidth, OgreGuard, OgreUnguardRet, Ogre::uchar, and Ogre::ushort.

Referenced by Ogre::Win32Window::writeContentsToFile(), and Ogre::SDLWindow::writeContentsToFile().

Image & Ogre::Image::flipAroundY  
 

Flips (mirrors) the image around the Y-axis.

Remarks:
An example of an original and flipped image:
 
                originalimg
                00000000000
                00000000000
                00000000000
                00000000000
                00000000000
                ------------> flip axis
                00000000000
                00000000000
                00000000000
                00000000000
                00000000000
                originalimg
                

Definition at line 81 of file OgreImage.cpp.

References Except, m_pBuffer, m_uHeight, m_uWidth, OgreGuard, OgreUnguardRet, Ogre::uchar, Ogre::uint, and Ogre::ushort.

bool Ogre::Image::formatHasAlpha PixelFormat    format [static]
 

Definition at line 404 of file OgreImage.cpp.

References Ogre::PF_A2R10G10B10, Ogre::PF_A4L4, Ogre::PF_A4R4G4B4, Ogre::PF_A8, Ogre::PF_A8R8G8B8, Ogre::PF_B10G10R10A2, Ogre::PF_B4G4R4A4, Ogre::PF_B5G6R5, Ogre::PF_B8G8R8, Ogre::PF_B8G8R8A8, Ogre::PF_L4A4, Ogre::PF_L8, Ogre::PF_R5G6B5, Ogre::PF_R8G8B8, Ogre::PF_UNKNOWN, and Ogre::PixelFormat.

uchar Ogre::Image::getBPP   const
 

Returns the number of bits per pixel.

Definition at line 393 of file OgreImage.cpp.

References m_ucPixelSize, and Ogre::uchar.

Referenced by Ogre::D3D9Texture::_loadCubeTex(), Ogre::D3DTexture::blitImage(), Ogre::D3DTexture::blitImage3D(), Ogre::D3D9Texture::loadImage(), Ogre::D3DTexture::loadImage(), and Ogre::D3DTexture::loadImage3D().

const uchar* Ogre::Image::getData   const
 

Returns a const pointer to the internal image buffer.

const uchar * Ogre::Image::getData void   
 

Returns a pointer to the internal image buffer.

Definition at line 326 of file OgreImage.cpp.

References m_pBuffer, and Ogre::uchar.

Referenced by Ogre::ColourImageAffector::_affectParticles(), Ogre::D3D9Texture::_blitImagesToCubeTex(), Ogre::D3D9Texture::_blitImageToNormTex(), Ogre::ColourImageAffector::_initParticle(), Ogre::D3DTexture::blitImage(), Ogre::D3DTexture::blitImage3D(), Ogre::GLTexture::blitToTexture(), Ogre::GLTexture::load(), Ogre::D3D9Texture::loadImage(), Ogre::GLTexture::rescaleNPower2(), Ogre::Win32Window::writeContentsToFile(), and Ogre::SDLWindow::writeContentsToFile().

ushort Ogre::Image::getDepth void    const
 

Gets the depth of the image.

Definition at line 364 of file OgreImage.cpp.

References m_uDepth, and Ogre::ushort.

Referenced by Ogre::GLTexture::load(), and Ogre::GLTexture::loadImages().

PixelFormat Ogre::Image::getFormat   const
 

Returns the image format.

Definition at line 387 of file OgreImage.cpp.

References m_eFormat, and Ogre::PixelFormat.

Referenced by Ogre::D3D9Texture::_blitImageToNormTex(), Ogre::GLTexture::load(), Ogre::D3D9Texture::loadImage(), Ogre::D3DTexture::loadImage(), Ogre::D3DTexture::loadImage3D(), Ogre::GLTexture::loadImages(), Ogre::ColourImageAffector::setImageAdjust(), and Ogre::TerrainSceneManager::setWorldGeometry().

bool Ogre::Image::getHasAlpha   const
 

Returns true if the image has an alpha component.

Definition at line 399 of file OgreImage.cpp.

References m_eFormat.

Referenced by Ogre::D3DTexture::blitImage(), Ogre::D3DTexture::blitImage3D(), Ogre::D3DTexture::loadImage(), Ogre::D3DTexture::loadImage3D(), and Ogre::GLTexture::loadImages().

ushort Ogre::Image::getHeight void    const
 

Gets the height of the image in pixels.

Definition at line 375 of file OgreImage.cpp.

References m_uHeight, and Ogre::ushort.

Referenced by Ogre::ColourImageAffector::_affectParticles(), Ogre::D3D9Texture::_blitImagesToCubeTex(), Ogre::D3D9Texture::_blitImageToNormTex(), Ogre::D3DTexture::blitImage(), Ogre::D3DTexture::blitImage3D(), Ogre::GLTexture::blitToTexture(), Ogre::D3DTexture::blitToTexture(), Ogre::GLTexture::load(), Ogre::D3D9Texture::loadImage(), Ogre::D3DTexture::loadImage(), Ogre::D3DTexture::loadImage3D(), Ogre::GLTexture::loadImages(), and Ogre::TerrainSceneManager::setWorldGeometry().

uchar Ogre::Image::getNumElemBits PixelFormat    format [static]
 

Returns the size in bits of an element of the given pixel format.

Returns:
The size in bits of an element. See Remarks.
Remarks:
Passing PF_UNKNOWN will result in returning a size of 0 bits while passing an unregistered pixel format will result in returning a size of 256 bits.

Definition at line 209 of file OgreImage.h.

References Ogre::PF_A2R10G10B10, Ogre::PF_A4L4, Ogre::PF_A4R4G4B4, Ogre::PF_A8, Ogre::PF_A8R8G8B8, Ogre::PF_B10G10R10A2, Ogre::PF_B4G4R4A4, Ogre::PF_B5G6R5, Ogre::PF_B8G8R8, Ogre::PF_B8G8R8A8, Ogre::PF_DXT1, Ogre::PF_DXT2, Ogre::PF_DXT3, Ogre::PF_DXT4, Ogre::PF_DXT5, Ogre::PF_L4A4, Ogre::PF_L8, Ogre::PF_R5G6B5, Ogre::PF_R8G8B8, Ogre::PF_UNKNOWN, Ogre::PixelFormat, and Ogre::uchar.

uchar Ogre::Image::getNumElemBytes PixelFormat    format [static]
 

Returns the size in bytes of an element of the given pixel format.

Returns:
The size in bytes of an element. See Remarks.
Remarks:
Passing PF_UNKNOWN will result in returning a size of 0 bytes while passing an unregistered pixel format will result in returning a size of 256 bytes.

Definition at line 157 of file OgreImage.h.

References Ogre::PF_A2R10G10B10, Ogre::PF_A4L4, Ogre::PF_A4R4G4B4, Ogre::PF_A8, Ogre::PF_A8R8G8B8, Ogre::PF_B10G10R10A2, Ogre::PF_B4G4R4A4, Ogre::PF_B5G6R5, Ogre::PF_B8G8R8, Ogre::PF_B8G8R8A8, Ogre::PF_L4A4, Ogre::PF_L8, Ogre::PF_R5G6B5, Ogre::PF_R8G8B8, Ogre::PF_UNKNOWN, Ogre::PixelFormat, and Ogre::uchar.

unsigned short Ogre::Image::getNumMipmaps   const
 

Returns the number of mipmaps contained in the image.

Definition at line 345 of file OgreImage.cpp.

References m_uNumMipmaps.

Referenced by Ogre::GLTexture::loadImages().

ushort Ogre::Image::getRowSpan void    const
 

Gets the physical width in bytes of each row of pixels.

Definition at line 381 of file OgreImage.cpp.

References m_ucPixelSize, m_uWidth, and Ogre::ushort.

size_t Ogre::Image::getSize   const
 

Returns the size of the data buffer.

Definition at line 339 of file OgreImage.cpp.

References m_uSize.

Referenced by Ogre::D3D9Texture::_loadCubeTex(), Ogre::D3DTexture::blitImage(), Ogre::D3DTexture::blitImage3D(), Ogre::GLTexture::load(), Ogre::D3D9Texture::loadImage(), and Ogre::GLTexture::rescaleNPower2().

ushort Ogre::Image::getWidth void    const
 

Gets the width of the image in pixels.

Definition at line 369 of file OgreImage.cpp.

References m_uWidth, and Ogre::ushort.

Referenced by Ogre::ColourImageAffector::_affectParticles(), Ogre::D3D9Texture::_blitImagesToCubeTex(), Ogre::D3D9Texture::_blitImageToNormTex(), Ogre::D3DTexture::blitImage(), Ogre::D3DTexture::blitImage3D(), Ogre::GLTexture::blitToTexture(), Ogre::D3DTexture::blitToTexture(), Ogre::GLTexture::load(), Ogre::D3D9Texture::loadImage(), Ogre::D3DTexture::loadImage(), Ogre::D3DTexture::loadImage3D(), Ogre::GLTexture::loadImages(), and Ogre::TerrainSceneManager::setWorldGeometry().

bool Ogre::Image::hasFlag const ImageFlags    imgFlag
 

Returns true if the image has the appropriate flag set.

Definition at line 351 of file OgreImage.cpp.

References Ogre::ImageFlags, and m_uFlags.

Referenced by Ogre::GLTexture::load(), and Ogre::GLTexture::loadImages().

Image & Ogre::Image::load const DataChunk   chunk,
const String   type
 

Loads an image file from a chunk of memory.

Remarks:
This method works in the same way as the filename-based load method except it loads the image from a DataChunk object, ie a chunk of memory. This DataChunk is expected to contain the encoded data as it would be held in a file.

This method is here to support loading from compressed archives where you decompress the data from the archive into memory first. This method will then decode the data and return a raw image data stream.

Parameters:
chunk  The source data.
type  The type of the image. Used to decide what decompression codec to use.
See also:
Image::load( const String& strFileName )

Definition at line 289 of file OgreImage.cpp.

References Ogre::Codec::decode(), Ogre::ImageCodec::ImageData::depth, Except, Ogre::ImageCodec::ImageData::flags, Ogre::ImageCodec::ImageData::format, Ogre::DataChunk::getPtr(), Ogre::ImageCodec::ImageData::height, m_eFormat, m_pBuffer, m_ucPixelSize, m_uDepth, m_uFlags, m_uHeight, m_uNumMipmaps, m_uSize, m_uWidth, Ogre::ImageCodec::ImageData::num_mipmaps, OgreGuard, OgreUnguardRet, PF2PS(), Ogre::ImageCodec::ImageData::size, and Ogre::ImageCodec::ImageData::width.

Image & Ogre::Image::load const String   strFileName
 

Loads an image file.

Remarks:
This method loads an image into memory held in the object. The pixel format will be either greyscale or RGB with an optional Alpha component. The type can be determined by calling getFormat().
Parameters:
strFileName  Name of a file file to load.
Note:
The memory associated with this buffer is destroyed with the Image object.

Definition at line 226 of file OgreImage.cpp.

References Ogre::Codec::decode(), Ogre::ImageCodec::ImageData::depth, Except, Ogre::ImageCodec::ImageData::flags, Ogre::ImageCodec::ImageData::format, Ogre::DataChunk::getPtr(), Ogre::ImageCodec::ImageData::height, m_eFormat, m_pBuffer, m_ucPixelSize, m_uDepth, m_uFlags, m_uHeight, m_uNumMipmaps, m_uSize, m_uWidth, Ogre::ImageCodec::ImageData::num_mipmaps, OgreGuard, OgreUnguardRet, PF2PS(), Ogre::ImageCodec::ImageData::size, and Ogre::ImageCodec::ImageData::width.

Referenced by Ogre::D3D9Texture::_loadCubeTex(), Ogre::GLTexture::load(), Ogre::D3DTexture::load(), Ogre::ColourImageAffector::setImageAdjust(), and Ogre::TerrainSceneManager::setWorldGeometry().

Image & Ogre::Image::loadRawData const DataChunk   pData,
ushort    uWidth,
ushort    uHeight,
PixelFormat    eFormat
 

Loads raw data from memory.

The pixel format has to be specified.

Definition at line 206 of file OgreImage.cpp.

References Ogre::DataChunk::getPtr(), m_eFormat, m_pBuffer, m_ucPixelSize, m_uHeight, m_uSize, m_uWidth, OgreGuard, OgreUnguardRet, PF2PS(), Ogre::PixelFormat, Ogre::uchar, and Ogre::ushort.

Referenced by Ogre::Font::createTextureFromFont(), Ogre::Quake3Level::extractLightmaps(), Ogre::GLTexture::load(), Ogre::Texture::loadRawData(), Ogre::Win32Window::writeContentsToFile(), and Ogre::SDLWindow::writeContentsToFile().

Image & Ogre::Image::operator= const Image &    img
 

Assignment operator- copies all the data from the target image.

Definition at line 63 of file OgreImage.cpp.

References m_eFormat, m_pBuffer, m_ucPixelSize, m_uDepth, m_uFlags, m_uHeight, m_uNumMipmaps, m_uSize, m_uWidth, and Ogre::uchar.

uchar Ogre::Image::PF2BPP PixelFormat    format [static]
 

Deprecated:
Use getNumElemBits instead.

Definition at line 196 of file OgreImage.h.

References Ogre::PixelFormat, and Ogre::uchar.

uchar Ogre::Image::PF2PS PixelFormat    format [static]
 

Deprecated:
Use getNumElemBytes instead.

Definition at line 144 of file OgreImage.h.

References Ogre::PixelFormat, and Ogre::uchar.

Referenced by load(), and loadRawData().


Member Data Documentation

PixelFormat Ogre::Image::m_eFormat [private]
 

Definition at line 413 of file OgreImage.h.

Referenced by getFormat(), getHasAlpha(), load(), loadRawData(), and operator=().

uchar* Ogre::Image::m_pBuffer [private]
 

Definition at line 417 of file OgreImage.h.

Referenced by flipAroundX(), flipAroundY(), getData(), load(), loadRawData(), operator=(), and ~Image().

uchar Ogre::Image::m_ucPixelSize [private]
 

Definition at line 416 of file OgreImage.h.

Referenced by flipAroundX(), getBPP(), getRowSpan(), load(), loadRawData(), and operator=().

ushort Ogre::Image::m_uDepth [private]
 

Definition at line 404 of file OgreImage.h.

Referenced by getDepth(), load(), and operator=().

int Ogre::Image::m_uFlags [private]
 

Definition at line 410 of file OgreImage.h.

Referenced by hasFlag(), load(), and operator=().

ushort Ogre::Image::m_uHeight [private]
 

Definition at line 402 of file OgreImage.h.

Referenced by flipAroundX(), flipAroundY(), getHeight(), load(), loadRawData(), and operator=().

ushort Ogre::Image::m_uNumMipmaps [private]
 

Definition at line 408 of file OgreImage.h.

Referenced by getNumMipmaps(), load(), and operator=().

uint Ogre::Image::m_uSize [private]
 

Definition at line 406 of file OgreImage.h.

Referenced by getSize(), load(), loadRawData(), and operator=().

ushort Ogre::Image::m_uWidth [private]
 

Definition at line 400 of file OgreImage.h.

Referenced by flipAroundX(), flipAroundY(), getRowSpan(), getWidth(), load(), loadRawData(), and operator=().


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

Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:17:55 2004