#include <OpenGUI_TextureDataRect.h>
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.)
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. | |
| 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
| void OpenGUI::TextureDataRect::copy | ( | const TextureDataRect * | srcTextureDataRect, | |
| IRect | srcRect | |||
| ) |
Copies the contents of an existing TextureDataRect into the buffer of this object.
| srcTextureDataRect | The TextureDataRect object that is used as the data source. | |
| srcRect | The rect within the source that is to be copied. |
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. 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.
| srcTextureData | The TextureData object that is used as the data source. | |
| srcRect | The rect within the source that is to be copied. |
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. 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.) 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.
| dstTextureDataRect | The TextureDataRect object that is the destination for writing. | |
| dstOffset | The position within the destination to begin the paste. |
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.
| dstTextureData | The TextureData object that is the destination for writing. | |
| dstOffset | The position within the destination to begin the paste. |
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. 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.
Provides pixel write functionality.
This function respects logical image dimensions. Writes outside of the image area will do nothing.