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













SourceForge.net Logo

Image

 

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.

 

 

Public Member List

 

const RGBA* operator~() const

operator const RGBA*() const

Returns a pointer to Image pixels.

 


 

const RGBA* operator[](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.

 


 

Point Get2ndSpot() const

Returns secondary reference point.

 


 

Size GetDots() const

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

 


 

Size GetDPI() const

Returns the image resolution in dpi (dots per inch).

 


 

int GetKindNoScan() const

Returns the kind of image. Unlike GetKind(), it does not perform the scan of image if the kind it not know, therefore it can return IMAGE_UNKNOWN.

 


 

int GetKind() const

Returns the kind of image, either set by ImageBuffer::SetKind or (if it is IMAGE_UNKNOWN) resolved by scanning pixels. If the kind is IMAGE_UNKNOWN, the pixels are scanned and the type is determined, it is then stored (in private Image instance variable) for future use and returned.

 


 

const RGBA *Begin() const

const RGBA *begin() const

Returns a pointer to the first pixel.

 


 

const RGBA *End() const

const RGBA *end() const

Returns begin() + GetLength().

 


 

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 Image& imgconst

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

 


 

bool operator==(const Image& imgconst

 


 

bool operator!=(const Image& imgconst

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.

 


 

Image& operator=(const Image& img)

Assigns another Image.

 


 

Image& operator=(ImageBuffer& img)

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.

 

 

Constructor Detail

 

Image()

 


 

Image(const Nuller&)

Constructs empty Image.

 


 

Image(const Value& src)

Converts Image from Value.

 


 

Image(const Image& img)

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(ImageBuffer& b)

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

 

 

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

 

 

 

 

Utility functions


 

Image WithHotSpots(const Image& m, int x1, int y1, int x2, int y2)

Returns a new Image based in Image m with hotspots x1, y1 and x2, y2.

 


 

Image WithHotSpot(const Image& m, int x1, int y1)

Returns a new Image based in Image m with hotspots x1, y1.

 


 

Image CreateImage(Size sz, const RGBA& rgba)

Creates a new Image with Size sz filled with color rgba.

 


 

Image CreateImage(Size sz, Color color)

Creates a new Image with Size sz filled with color color.

 


 

Size DstSrc(ImageBuffer& dest, Point& p, const Image& src, Rect& sr)

Calculates the minimum Size of Rect sr of Image src when trying to copy it into Point p of ImageBuffer dest.

 


 

void DstSrcOp(ImageBuffer& dest, Point p, const Image& src, const Rect& srect, void (*op)(RGBA *t, const RGBA *s, int n))

Copies Rect srect of Image src into Point p of ImageBuffer dest using copying function op.

 


 

void Copy(ImageBuffer& dest, Point p, const Image& src, const Rect& srect)

Copies Rect srect of Image src into Point p of ImageBuffer dest.

 


 

void Fill(ImageBuffer& dest, const Rect& rect, RGBA color)

Fills rectangular are rect with color .

 


 

void Copy(Image& dest, Point p, const Image& src, const Rect& srect)

Copies Rect srect of Image src into Point p of Image dest.

 


 

void Over(ImageBuffer& dest, Point p, const Image& src, const Rect& srect)

Mixes using alpha information Rect srect of Image src into Point p of ImageBuffer dest.

 


 

void Over(Image& dest, Point p, const Image& src, const Rect& srect)

Mixes using alpha information Rect srect of Image src into Point p of Image dest.

 


 

void Over(Image& dest, const Image& src)

Same as Over(dest, Point(0, 0), src, src.GetSize()).

 


 

void Fill(Image& dest, const Rect& rect, RGBA color)

Fills rectangular are rect with color.

 


 

void OverStraightOpaque(ImageBuffer& dest, Point p, const Image& src, const Rect& srect)

Mixes using alpha information Rect srect of Image src into Point p of ImageBuffer dest.

The alpha channel of dest is 255 (opaque).

 


 

void OverStraightOpaque(Image& dest, Point p, const Image& _src, const Rect& srect)

Mixes using alpha information Rect srect of Image src into Point p of Image dest.

The alpha channel of dest is 255 (opaque).

 


 

Image Crop(const Image& img, const Rect& rc)

Returns a subimage from img defined by Rect rc.

 


 

Image Crop(const Image& img, int x, int y, int cx, int cy)

Returns a subimage from img defined by origin x, y, width cx and height cy.

 


 

Image AutoCrop(const Image& m, RGBA c)

Detects rectangular margin with uniform color c and then crops this margin out.

 


 

Image ColorMask(const Image& src, Color transparent)

Returns a new Image based on src replaced Color transparent with RGBAZero().

 


 

Image CanvasSize(const Image& img, int cx, int cy)

img cx cy.

 


 

Image AssignAlpha(const Image& img, const Image& new_alpha)

Returns a new Image based on img colors and new_alpha alpha.

Image size is the minimum of img and new_alpha.

 


 

Image Equalight(const Image& img, int thold = 10)

img thold.

 


 

Image Grayscale(const Image& img)

Returns a new Image including img converted to grayscale.

 


 

Image Grayscale(const Image& img, int amount)

img amount.

 


 

Image Colorize(const Image& img, Color color, int alpha = 100)

img color alpha.

 


 

Image Contrast(const Image& img, int amount = 256)

Returns a new Image with its contrast increased in amount based on img.

 


 

Image Rescale(const Image& src, Size sz, const Rect& src_rc, Gate2<int, intprogress = false)

Returns a new Image rescaled to Size sz based on Rect src_rc of Image src

 


 

Image Sharpen(const Image& img, int amount = 100)

Sharpens image using primitive convolution filter.

 


 

Image Dither(const Image& m, int dival = 394)

Provides primitive dithering with 8x8 matrix into black/white picture. Dival is sort of gamma control of output, lowering it from default value (to e.g. 350) can produce better results when dithering is using for printing on purely monochromatic (without half-toning support) printers.

 


 

Image Etched(const Image& img)

"Etching" effect.

 


 

Image SetColorKeepAlpha(const Image& img, Color c)

Returns a new Image based on img alpha and c Color.

 


 

Image RotateClockwise(const Image& img)

Returns a new Image rotated 90º (clockwise) that is based on img.

 


 

Image RotateAntiClockwise(const Image& img)

Returns a new Image rotated -90º (anticlockwise) that is based on img.

 


 

Image Rotate180(const Image& orig)

Returns a new Image rotated 180º that is based on img.

 


 

Image MirrorHorz(const Image& img)

Returns a new Image that is a mirror of img following horizontal axis.

 


 

Image MirrorVert(const Image& img)

Returns a new Image that is a mirror of img following vertical axis.

 


 

Image Rotate(const Image& m, int angle)

Returns a new Image based on Image m rotated angle by its center where the full rotation (2π) is 3600.

 

 

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