Overview
Examples
Screenshots
Comparisons
Applications
Download
Manual
Status & Roadmap
FAQ
Authors & License
Forums
Wiki
Funding Ultimate++
Search on this site











SourceForge.net Logo



Image and ImageBuffer

class Image : public AssignValueTypeNo< Image, 150, Moveable<Image> > 

Image represents an immutable image value. Image can be directly painted to Draw. To create or change Image, use ImageBuffer.

Image has low-cost constant time deep copy. It is moveable and Rich-Value compatible type.

U++ expects pixels to be in premultiplied alpha format.

 

const RGBAoperator~() const

operator const RGBA*() const

Returns a pointer to Image pixels.

 

const RGBAoperator[](int iconst

Returns a pointer to the first pixel in the line i.

 

Size GetSize() const

Returns the dimension of Image.

 

int GetWidth() const

Same as GetSize().cx.

 

int GetHeight() const

Same as GetSize().cy.

 

int GetLength() const

Number of pixels in Image - GetWidth() * GetHeight().

 

Point GetHotSpot() const

Returns the reference point.

 

Size GetDots() const

Gets the physical size of Image. If physical size is not set, returns Size(0, 0).

 

int GetKind() const

Returns the kind of image. See ImageBuffer for detail.

 

int64 GetSerialId() const

Returns the unique, per application run, identifier of Image. All Images with the same serial id can be considered equal (this is useful for caching images).

 

bool IsSame(const Imageimgconst

Same as GetSerialId() == img.GetSerialId().

 

bool operator==(const Imageimgconst

bool operator!=(const Imageimgconst

Tests whether two Images are equal (or not equal). Dimensions, hot-spot, dots and all pixels are compared. Note that the comparison can be slow.

 

dword GetHashValue() const

Returns the hash-value for image. All pixels combined into hash value (potentially slow).

 

String ToString() const

Returns the basic Image informations as String.

 

void Serialize(Stream& s)

Serializes Image.

 

void Clear()

Assigns an empty Image.

 

Imageoperator=(const Imageimg)

Assigns another Image.

 

Imageoperator=(ImageBufferimg)

Assigns Image created in ImageBuffer. ImageBuffer is emptied by this operation.

 

bool IsNullInstance() const

Test whether Image has nonzero dimension.

 

bool IsEmpty() const

Same as IsNullInstance.

 

operator Value() const

Converts Image to Value.

 

Image()

Image(const Nuller&)

Constructs empty Image.

 

Image(const Value& src)

Converts Image from Value.

 

Image(const Imageimg)

Copy constructor.

 

Image(Image (*fn)())

This function allow Image to be directly constructed from pointer to function returning the Image. This allows omitting parenthesis when passing Iml image constants as arguments.

 

Image(ImageBufferb)

Uses Image created in ImageBuffer. ImageBuffer is emptied by this operation.

 

~Image()

Destructor.

 

 

Standard cursors

 

Image class contains several standard mouse cursor Images as static member methods:

 

Arrow

 

Wait

 

IBeam

 

No

 

SizeAll

 

SizeHorz

 

SizeVert

 

SizeTopLeft

 

SizeTop

 

SizeTopRight

 

SizeLeft

 

SizeRight

 

SizeBottomLeft

 

SizeBottom

 

SizeBottomRight

 

 

 

 

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_EMPTY

The image is empty (all alpha values are 0).

IMAGE_ALPHA

The image has alpha values different from 255 and 0.

IMAGE_MASK

The image has alpha values 0 or 255 only.

IMAGE_OPAQUE

The image has all alpha values 255.

 

Note that is the kind of image is unknown, painting routine determines it automatically by scanning pixels and stores the result.

 

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().

 

void SetHotSpot(Point p)

Sets the reference point. This point is e.g. used as hot-spot when Image is used as mouse pointer.

 

Point GetHotSpot() const

Returns the 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).

 

Size GetSize() const

Returns the dimensions of image.

 

int GetWidth() const

Same as GetSize().cx.

 

int GetHeight() const

Same as GetSize().cy.

 

int GetLength() const

Returns the number of pixels in the image. Same as GetSize().cx * GetSize().cy.

 

RGBA *operator[](int i)

const RGBA *operator[](int iconst

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 operator=(Imageimg)

void operator=(ImageBufferimg)

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(Imageimg)

ImageBuffer(ImageBufferimg)

Assigns pixels of img to ImageBuffer. img is cleared and empty after this operation, price paid for low-cost constant time operation.

 

ImageBuffer(ImageDraw& w)

Creates ImageBuffer from ImageDraw. ImageDraw is cleared and empty after this operation, price paid for low-cost constant time operation.