PixelLightAPI  .
Public Member Functions | Static Public Member Functions
PLGraphics::ImageBuffer Class Reference

Image buffer class. More...

#include <ImageBuffer.h>

List of all members.

Public Member Functions

 ImageBuffer ()
 Constructor.
 ImageBuffer (const ImageBuffer &cSource)
 Copy constructor.
 ~ImageBuffer ()
 Destructor.
ImageBufferoperator= (const ImageBuffer &cSource)
 Assignment operator.
void CreateImage (EDataFormat nDataFormat, EColorFormat nColorFormat, const PLMath::Vector3i &vSize, ECompression nCompression=CompressionNone)
 Create image.
void Clear ()
 Clear data.
PLGRAPHICS_API void ApplyEffect (const ImageEffect &cEffect)
 Apply image effect.
PLGRAPHICS_API ECheckConsistency CheckConsistency () const
 Check image for possible problems.
void CreateTestImage (ETestImage nTestImage=TestImage2DSimple)
 Create a test image.
EDataFormat GetDataFormat () const
 Get data format.
EColorFormat GetColorFormat () const
 Get color format.
PLCore::uint32 GetComponentsPerPixel () const
 Returns the number of components per pixel.
PLCore::uint32 GetBytesPerPixelComponent () const
 Returns the number of bytes per pixel component.
PLCore::uint32 GetBytesPerPixel () const
 Returns the number of bytes per pixel.
ECompression GetCompression () const
 Get compression type.
void SetCompression (ECompression nCompression)
 Set compression type.
PLMath::Vector3i GetSize () const
 Get image size.
PLCore::uint32 GetNumOfPixels () const
 Returns the number of pixels.
bool HasAnyData () const
 Check if uncompressed or compressed data is available.
bool HasData () const
 Check if uncompressed data is available.
PLCore::uint32 GetDataSize () const
 Get size of image data in bytes.
PLCore::uint32 GetRowSize () const
 Get size of one row of image data in bytes.
const PLCore::uint8 * GetData () const
 Get image data.
PLCore::uint8 * GetData ()
bool HasCompressedData () const
 Check if compressed data is available.
PLCore::uint32 GetCompressedDataSize () const
 Get size of compressed image data in bytes.
const PLCore::uint8 * GetCompressedData () const
 Get compressed image data.
PLCore::uint8 * GetCompressedData ()
bool Compress ()
 Compress image data.
bool Decompress ()
 Decompress image data.
void SetPalette (ImagePalette *pPalette)
 Set color palette.
const ImagePaletteGetPalette () const
 Get color palette.
ImagePaletteGetPalette ()
void CopyData (const PLCore::uint8 *pnData)
 Copy provided uncompressed image data into this image buffer.
void TakeoverData (PLCore::uint8 *pnData)
 Let this image buffer takeover provided uncompressed image data.
void ShareData (PLCore::uint8 *pnData)
 Let this image buffer share provided uncompressed image data.

Static Public Member Functions

static PLGRAPHICS_API
PLCore::uint32 
GetComponentsPerPixel (EColorFormat nColorFormat)
 Returns the number of components per pixel.
static PLGRAPHICS_API
PLCore::uint32 
GetBytesPerPixelComponent (EDataFormat nDataFormat)
 Returns the number of bytes per pixel component.
static PLCore::uint32 GetBytesPerPixel (EDataFormat nDataFormat, EColorFormat nColorFormat)
 Returns the number of bytes per pixel.
static PLGRAPHICS_API
PLCore::uint32 
GetMipmapSize (PLCore::uint32 nBaseSize, PLCore::uint32 nMipmap)
 Returns the size of a certain mipmap.
static bool IsAlphaChannelColorFormat (EColorFormat nColorFormat)
 Returns whether or not the given color format has an alpha channel.
static PLGRAPHICS_API EColorFormat GetAlphaChannelColorFormat (EColorFormat nColorFormat)
 Returns a version with alpha channel of the given color format.
static PLGRAPHICS_API EColorFormat GetNoneAlphaChannelColorFormat (EColorFormat nColorFormat)
 Returns a version without alpha channel of the given color format.

Detailed Description

Image buffer class.

Remarks:
The image buffer class uses a 'copy on change' technique - therefore copying one image buffer into another is quite performant because the internal image buffer data is shared as long as a image buffer doesn't change.
Note:
  • The origin (0, 0) is on the upper-left ("top-down")
  • The image components are stored in a linear byte array. RGB example:
    R1G1B1R2G2B2R3G3B3...
  • Implementation of the proxy design pattern, this class is the proxy

Constructor & Destructor Documentation

Constructor.

PLGraphics::ImageBuffer::ImageBuffer ( const ImageBuffer cSource) [inline]

Copy constructor.

Parameters:
[in]cSourceSource to copy from

Destructor.


Member Function Documentation

static PLGRAPHICS_API PLCore::uint32 PLGraphics::ImageBuffer::GetComponentsPerPixel ( EColorFormat  nColorFormat) [static]

Returns the number of components per pixel.

Parameters:
[in]nColorFormatColor format
Returns:
The number of components per pixel
static PLGRAPHICS_API PLCore::uint32 PLGraphics::ImageBuffer::GetBytesPerPixelComponent ( EDataFormat  nDataFormat) [static]

Returns the number of bytes per pixel component.

Parameters:
[in]nDataFormatData format
Returns:
The number of bytes per pixel component
PLCore::uint32 PLGraphics::ImageBuffer::GetBytesPerPixel ( EDataFormat  nDataFormat,
EColorFormat  nColorFormat 
) [inline, static]

Returns the number of bytes per pixel.

Parameters:
[in]nDataFormatData format
[in]nColorFormatColor format
Returns:
The number of bytes per pixel
static PLGRAPHICS_API PLCore::uint32 PLGraphics::ImageBuffer::GetMipmapSize ( PLCore::uint32  nBaseSize,
PLCore::uint32  nMipmap 
) [static]

Returns the size of a certain mipmap.

Parameters:
[in]nBaseSizeSize of the base level
[in]nMipmapMipmap level
Returns:
The size of a certain mipmap
bool PLGraphics::ImageBuffer::IsAlphaChannelColorFormat ( EColorFormat  nColorFormat) [inline, static]

Returns whether or not the given color format has an alpha channel.

Parameters:
[in]nColorFormatColor format to check
Returns:
'true' if the given color format has an alpha channel, else 'false'
static PLGRAPHICS_API EColorFormat PLGraphics::ImageBuffer::GetAlphaChannelColorFormat ( EColorFormat  nColorFormat) [static]

Returns a version with alpha channel of the given color format.

Parameters:
[in]nColorFormatColor format to return a color format with alpha channel from
Returns:
Color format with alpha channel on success, same color format channel if the given color format has already a alpha channel or when there's no version of the given color format with alpha channel
static PLGRAPHICS_API EColorFormat PLGraphics::ImageBuffer::GetNoneAlphaChannelColorFormat ( EColorFormat  nColorFormat) [static]

Returns a version without alpha channel of the given color format.

Parameters:
[in]nColorFormatColor format to return a color format without alpha channel from
Returns:
Color format without alpha channel on success, same color format channel if the given color format has already no alpha channel or when there's no version of the given color format without alpha channel
ImageBuffer & PLGraphics::ImageBuffer::operator= ( const ImageBuffer cSource) [inline]

Assignment operator.

Parameters:
[in]cSourceSource to copy from
Returns:
Reference to this object
void PLGraphics::ImageBuffer::CreateImage ( EDataFormat  nDataFormat,
EColorFormat  nColorFormat,
const PLMath::Vector3i vSize,
ECompression  nCompression = CompressionNone 
) [inline]

Create image.

Parameters:
[in]nDataFormatDesired data format (for example "DataByte")
[in]nColorFormatDesired color format (for example "ColorRGB")
[in]vSizeImage size (for example "PLMath::Vector3i(64, 32, 1)")
[in]nCompressionCompression type (for example "CompressionNone")
Remarks:
Please note that a call to CreateImage() will not immediately create the image buffer itself. The image buffer is created on the first call to GetData() or GetCompressedData() respectively.
void PLGraphics::ImageBuffer::Clear ( ) [inline]

Clear data.

PLGRAPHICS_API void PLGraphics::ImageBuffer::ApplyEffect ( const ImageEffect cEffect)

Apply image effect.

Parameters:
[in]cEffectImage effect
PLGRAPHICS_API ECheckConsistency PLGraphics::ImageBuffer::CheckConsistency ( ) const

Check image for possible problems.

Returns:
Error code describing any problem found, 'CheckOk' if everything is fine
void PLGraphics::ImageBuffer::CreateTestImage ( ETestImage  nTestImage = TestImage2DSimple) [inline]

Create a test image.

Parameters:
[in]nTestImageID of test image
Remarks:
Only 2D and 3D test images are allowed here. For images containing more than one image buffer, you have to use Image::CreateTestImage().
EDataFormat PLGraphics::ImageBuffer::GetDataFormat ( ) const [inline]

Get data format.

Returns:
Data format
EColorFormat PLGraphics::ImageBuffer::GetColorFormat ( ) const [inline]

Get color format.

Returns:
Color format
PLCore::uint32 PLGraphics::ImageBuffer::GetComponentsPerPixel ( ) const [inline]

Returns the number of components per pixel.

Returns:
The number of components per pixel
PLCore::uint32 PLGraphics::ImageBuffer::GetBytesPerPixelComponent ( ) const [inline]

Returns the number of bytes per pixel component.

Returns:
The number of bytes per pixel component
PLCore::uint32 PLGraphics::ImageBuffer::GetBytesPerPixel ( ) const [inline]

Returns the number of bytes per pixel.

Returns:
The number of bytes per pixel
ECompression PLGraphics::ImageBuffer::GetCompression ( ) const [inline]

Get compression type.

Returns:
Compression type
void PLGraphics::ImageBuffer::SetCompression ( ECompression  nCompression) [inline]

Set compression type.

Parameters:
[in]nCompressionCompression type
Remarks:
This will invalidate the compressed image data buffer

Get image size.

Returns:
Size of image
PLCore::uint32 PLGraphics::ImageBuffer::GetNumOfPixels ( ) const [inline]

Returns the number of pixels.

Returns:
The number of pixels
bool PLGraphics::ImageBuffer::HasAnyData ( ) const [inline]

Check if uncompressed or compressed data is available.

Returns:
'true' if image data is available, else 'false'
bool PLGraphics::ImageBuffer::HasData ( ) const [inline]

Check if uncompressed data is available.

Returns:
'true' if image data is available, else 'false'
PLCore::uint32 PLGraphics::ImageBuffer::GetDataSize ( ) const [inline]

Get size of image data in bytes.

Returns:
Size of image data in bytes
PLCore::uint32 PLGraphics::ImageBuffer::GetRowSize ( ) const [inline]

Get size of one row of image data in bytes.

Returns:
Size of one row in bytes
const PLCore::uint8 * PLGraphics::ImageBuffer::GetData ( ) const [inline]

Get image data.

Returns:
Pointer to image data, a null pointer on error
Remarks:
If the image contains no uncompressed data, but compressed image data is available the data, will be decompressed automatically and stored in the decompressed image buffer this method returns.
Note:
  • Lookout! This method is dangerous and must be used with care! Do always ensure that you never read or write over the data buffer boundings!
PLCore::uint8 * PLGraphics::ImageBuffer::GetData ( ) [inline]

Check if compressed data is available.

Returns:
'true' if compressed image data is available, else 'false'
PLCore::uint32 PLGraphics::ImageBuffer::GetCompressedDataSize ( ) const [inline]

Get size of compressed image data in bytes.

Returns:
Size of compressed image data in bytes
const PLCore::uint8 * PLGraphics::ImageBuffer::GetCompressedData ( ) const [inline]

Get compressed image data.

Returns:
Pointer to compressed image data, a null pointer on error
Note:
  • Lookout! This method is dangerous and must be used with care! Do always ensure that you never read or write over the data buffer boundings!
PLCore::uint8 * PLGraphics::ImageBuffer::GetCompressedData ( ) [inline]

Compress image data.

Remarks:
If the image contains uncompressed image data, the data will be compressed and stored in the compressed image buffer.

Decompress image data.

Remarks:
If the image contains compressed image data, the data will be decompressed and stored in the decompressed image buffer.
void PLGraphics::ImageBuffer::SetPalette ( ImagePalette pPalette) [inline]

Set color palette.

Parameters:
[in]pPalettePointer to color palette, or a null pointer if the image has no palette

Get color palette.

Returns:
Pointer to color palette, or a null pointer if the image has no palette
void PLGraphics::ImageBuffer::CopyData ( const PLCore::uint8 *  pnData) [inline]

Copy provided uncompressed image data into this image buffer.

Parameters:
[in]pnDataData to copy into this image buffer, must have enough bytes to fill the whole image! If null pointer, this method does nothing.
Note:
  • Lookout! This method is dangerous and must be used with care! Do always ensure that your given image data has enough bytes for this image buffer!
void PLGraphics::ImageBuffer::TakeoverData ( PLCore::uint8 *  pnData) [inline]

Let this image buffer takeover provided uncompressed image data.

Parameters:
[in]pnDataPointer to the image data to be taken over by this image buffer, must have enough bytes to fill the whole image buffer! If null pointer, this method does nothing.
Note:
  • "Takeover" means that this image buffer will destroy the provided data when it's no longer used!
  • Lookout! This method is dangerous and must be used with care! Do always ensure that your given image data has enough bytes for this image buffer!
void PLGraphics::ImageBuffer::ShareData ( PLCore::uint8 *  pnData) [inline]

Let this image buffer share provided uncompressed image data.

Parameters:
[in]pnDataPointer to the image data to be shared by this image buffer, must have enough bytes to fill the whole image buffer! If null pointer, this method does nothing.
Note:
  • "Share" means that this image buffer will not destroy the provided data when it's no longer used!
  • Please be aware that your provided image data must stay valid during the lifetime of the image buffer instance (and potential image buffer copies!)
  • While this method is quite efficient, it's also quite error prone, so be really careful when using this method
  • Lookout! This method is dangerous and must be used with care! Do always ensure that your given image data has enough bytes for this image buffer!

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


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:31
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported