class ImageBuffer : private NoCopy
ImageBuffer represents a writable Image - an array of RGBA pixels. ImageBuffer can be converted to Image in low-const constant time while loosing its content and vice versa, Image can be converted to ImageBuffer again loosing its content.
Content of Image / ImageBuffer can be classified to optimize drawing. Possible classifications are
|
IMAGE_UNKNOWN
|
The image kind is unknown.
|
IMAGE_ALPHA
|
The image has some alpha values that are not 255.
|
IMAGE_OPAQUE
|
The image has all alpha values 255.
|
IMAGE_EMPTY
|
[deprecated]
|
IMAGE_MASK
|
[deprecated]
|
|
|
To optimize drawing performance, is advisable to set kind to IMAGE_OPAQUE if it is a known fact.
Pixels of image are organized in simple continual POD array, first pixel being top-left.
U++ expects pixels to be in premultiplied alpha format.
void SetKind(int k)
Sets the kind of image. You can use this to avoid automatic detection.
int GetKind() const
Returns the kind of image set by SetKind.
int ScanKind() const
Scans all RGBA pixels to determine Image kind.
int GetScanKind() const
If kind set by SetKind is other than IMAGE_UNKNOWN, returns it, otherwise calls ScanKind().
ImageBuffer& Opaque()
Same as SetKind(IMAGE_OPAQUE).
void SetHotSpot(Point p)
Sets the reference point. This point is e.g. used as hot-spot when Image is used as mouse pointer. Iml designer has the ability to specify this point.
Point GetHotSpot() const
Returns the reference point.
void Set2ndSpot(Point p)
Sets secondary reference point. Iml designer has the ability to specify this point.
Point Get2ndSpot() const
Reads secondary reference point.
void SetDots(Size sz)
Sets the optional physical size in dots.
Size GetDots() const
Returns the optional physical size. Default value is Size(0, 0).
void SetDPI(Size sz)
Sets the image resolution in dpi (dots per inch).
As the dpi are not directly stored, if SetDots() is called or image is resized, the dpi could change.
Size GetDPI()
Returns the image resolution in dpi (dots per inch).
As the dpi are not directly stored, if SetDots() is called or image is resized, the dpi could change.
Size GetSize() const
Returns the dimensions of image.
int GetWidth() const
Same as GetSize().cx.
int GetHeight() const
Same as GetSize().cy.
size_t GetLength() const
Returns the number of pixels in the image. Same as GetSize().cx * GetSize().cy.
RGBA *operator[](int i)
const RGBA *operator[](int i) const
Returns a pointer to the first pixel in the line i.
RGBA *operator~()
operator RGBA*()
const RGBA *operator~() const
operator const RGBA*() const
Returns a pointer to the first pixel of the image.
void Create(int cx, int cy)
void Create(Size sz)
Creates a new image of specified size. Value of pixels is undefined. Previous content of ImageBuffer is lost.
bool IsEmpty() const
Same as GetLength() == 0.
void Clear()
Clears the content, removing all pixels and setting the size of Image to Size(0, 0).
void PaintOnceHint(bool b = true)
bool IsPaintOnceHint() const
Sets/gets the hint that the image will likely be painted only once with Draw::DrawImage. This hint can improve the rendering performance in certain contexts. Default is false.
void operator=(Image& img)
void operator=(ImageBuffer& img)
Assigns pixels of img to ImageBuffer. img is cleared and empty after this operation, price paid for low-cost constant time operation.
ImageBuffer()
Constructs empty ImageBuffer.
ImageBuffer(int cx, int cy)
ImageBuffer(Size sz)
Constructs ImageBuffer of specified size. Value of pixels is undefined.
ImageBuffer(Image& img)
ImageBuffer(ImageBuffer& img)
Assigns pixels of img to ImageBuffer. img is cleared and empty after this operation, price paid for low-cost constant time operation.
|