OpenGUI::TextureDataRect Class Reference

#include <OpenGUI_TextureDataRect.h>

List of all members.


Detailed Description

Provides a clean and reliable method of altering the contents of a TextureData object.

These objects represent a subset of data from a TextureData object. The immediate contents of the image data contained is not directly linked to the data of a TextureData object. When a TextureDataRect is created, they can be created with a provided background color but otherwise empty, or they can be initialized with existing data from a TextureData object. Either way, making changes to the contents of a TextureDataRect does not immediately update the contents of any TextureData object. The TextureDataRect must be applied to a TextureData object using the paste() function. (It is entirely valid to create a TextureDataRect of size 0,0.)

Note:
All offsets and rects use the upper left of the image as 0,0 and the bottom right as sX,sY where sX is the width of the image, and sY is the height of the image.
Remarks:
The overall functionality of TextureDataRect is limited on purpose. If you require more complex image editing operations, it is highly recommended that you utilize a full blown image library, such as DevIL.
Warning:
TextureDataRect only supports one color mode: 4 channel, 32-bit, RGBA. All copies and pastes between non-RGBA TextureData objects are subject to a very crude form of data conversion. Color channels that do not fit into paste() destinations are dropped without error or warning, and color channels that are missing in copy() sources are autofilled with 0. If this doesn't fit your needs, see the above remarks.


Public Member Functions

 TextureDataRect (const IVector2 &size=IVector2(), const TDRColor &color=TDRColor())
 create a blank slate of the given size and color
 TextureDataRect (const TextureData *srcTextureData, const IRect &srcRect)
 create using an existing TextureData as the source of data. srcRect defines the sub area with it to use, as well as size
 TextureDataRect (const TextureDataRect *srcTextureDataRect, const IRect &srcRect)
 create using an existing TextureDataRect as the source of data. srcRect defines the sub area with it to use, as well as size
 ~TextureDataRect ()
 destructor
IVector2 getSize ()
 Returns the width and height of the texture data rect.
void setSize (const IVector2 &newSize, const TDRColor &color=TDRColor())
 Sets the size of this object to the given size.
void fill (const TDRColor &color=TDRColor())
 Fills this TextureDataRect with the given color, overwriting any existing data.
void copy (const TextureData *srcTextureData, IRect srcRect)
 Copies the contents of an existing TextureData into the buffer of this object.
void copy (const TextureDataRect *srcTextureDataRect, IRect srcRect)
 Copies the contents of an existing TextureDataRect into the buffer of this object.
void paste (TextureData *dstTextureData, const IVector2 &dstOffset) const
 Writes the contents of this object's buffer onto a TextureData at the desired offset.
void paste (TextureDataRect *dstTextureDataRect, const IVector2 &dstOffset) const
 Writes the contents of this object's buffer onto a TextureDataRect at the desired offset.
void write (const IVector2 &position, const TDRColor &color)
 Provides pixel write functionality.
TDRColor read (const IVector2 &position) const
 Provides pixel read functionality.


Constructor & Destructor Documentation

OpenGUI::TextureDataRect::TextureDataRect ( const IVector2 size = IVector2(),
const TDRColor color = TDRColor() 
)

create a blank slate of the given size and color

OpenGUI::TextureDataRect::TextureDataRect ( const TextureData srcTextureData,
const IRect srcRect 
)

create using an existing TextureData as the source of data. srcRect defines the sub area with it to use, as well as size

OpenGUI::TextureDataRect::TextureDataRect ( const TextureDataRect srcTextureDataRect,
const IRect srcRect 
)

create using an existing TextureDataRect as the source of data. srcRect defines the sub area with it to use, as well as size

OpenGUI::TextureDataRect::~TextureDataRect (  ) 

destructor


Member Function Documentation

void OpenGUI::TextureDataRect::copy ( const TextureDataRect srcTextureDataRect,
IRect  srcRect 
)

Copies the contents of an existing TextureDataRect into the buffer of this object.

Parameters:
srcTextureDataRect The TextureDataRect object that is used as the data source.
srcRect The rect within the source that is to be copied.
Note:
This TextureDataRect will be automatically resized to perfectly hold the copied data. If you are attempting to copy the data to an offset position, use a temporary TextureDataRect to copy() the data out, and paste() it into the desired TextureDataRect at the desired position. Any data that is already held by this object will be properly discarded before the copy occurs.
Warning:
If you attempt to copy off the end of a data source on either axis by specifying an invalid srcRect, the area copied will be adjusted in size to fit the available area of the data source. This means it is possible to end up copying a rect of 0 height and 0 width. (If either height or width are adjusted to a size of 0, the other is automatically set to 0 as well and the copy will immediately return without performing any copy at all. The previous contents of this object are still discarded.)

void OpenGUI::TextureDataRect::copy ( const TextureData srcTextureData,
IRect  srcRect 
)

Copies the contents of an existing TextureData into the buffer of this object.

Parameters:
srcTextureData The TextureData object that is used as the data source.
srcRect The rect within the source that is to be copied.
Note:
This TextureDataRect will be automatically resized to perfectly hold the copied data. If you are attempting to copy the data to an offset position, use a temporary TextureDataRect to copy() the data out, and paste() it into the desired TextureDataRect at the desired position. Any data that is already held by this object will be properly discarded before the copy occurs.
Warning:
If you attempt to copy off the end of a data source on either axis by specifying an invalid srcRect, the area copied will be adjusted in size to fit the available area of the data source. This means it is possible to end up copying a rect of 0 height and 0 width. (If either height or width are adjusted to a size of 0, the other is automatically set to 0 as well and the copy will immediately return without performing any copy at all. The previous contents of this object are still discarded.)

void OpenGUI::TextureDataRect::fill ( const TDRColor color = TDRColor()  ) 

Fills this TextureDataRect with the given color, overwriting any existing data.

IVector2 OpenGUI::TextureDataRect::getSize (  ) 

Returns the width and height of the texture data rect.

void OpenGUI::TextureDataRect::paste ( TextureDataRect dstTextureDataRect,
const IVector2 dstOffset 
) const

Writes the contents of this object's buffer onto a TextureDataRect at the desired offset.

Parameters:
dstTextureDataRect The TextureDataRect object that is the destination for writing.
dstOffset The position within the destination to begin the paste.
Note:
The paste operation, like the copy operation, respects logical image dimensions. This means that if part of your paste does not fit within the destination, the part that does not fit will not be written, and no error will ever be thrown for it. The destination will not be resized to make it fit.

void OpenGUI::TextureDataRect::paste ( TextureData dstTextureData,
const IVector2 dstOffset 
) const

Writes the contents of this object's buffer onto a TextureData at the desired offset.

Parameters:
dstTextureData The TextureData object that is the destination for writing.
dstOffset The position within the destination to begin the paste.
Note:
The paste operation, like the copy operation, respects logical image dimensions. This means that if part of your paste does not fit within the destination, the part that does not fit will not be written, and no error will ever be thrown for it. The destination will not be resized to make it fit.

TDRColor OpenGUI::TextureDataRect::read ( const IVector2 position  )  const [inline]

Provides pixel read functionality.

This function respects logical image dimensions. Reads outside of the image area will return pure white w/ 100% alpha.

void OpenGUI::TextureDataRect::setSize ( const IVector2 newSize,
const TDRColor color = TDRColor() 
)

Sets the size of this object to the given size.

Existing data that fits within the new size is preserved but will be cropped as appropriate. Any new real estate will be filled with the provided color, or white w/ 100% alpha if none is provided.

Note:
It is impossible to have a negative value for either dimension, so any negative dimensions are automatically changed to a 0. If either dimension is 0, the other is automatically set to 0 as well.

void OpenGUI::TextureDataRect::write ( const IVector2 position,
const TDRColor color 
) [inline]

Provides pixel write functionality.

This function respects logical image dimensions. Writes outside of the image area will do nothing.


The documentation for this class was generated from the following files:
Copyright © 2006 OpenGUI | OpenGUI.SF.net
Generated: Fri Jan 5 23:05:26 2007