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













SourceForge.net Logo

ImageBuffer

 

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.

 

 

Public Member List

 

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

 


 

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

 

 

Constructor Detail

 

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.

 

 

Last edit by cxl on 12/02/2017. Do you want to contribute?. T++