CoreComponents 3.0.0
A Modern C++ Toolkit
Loading...
Searching...
No Matches
Image Class Reference

2-dimensional color matrix More...

#include <cc/Image>

Inheritance diagram for Image:

Public Member Functions

 Image ()=default
 Create a null image.
 
 Image (int width, int height)
 Create an image of width x height pixels.
 
 Image (int width, int height, const Bytes &data)
 Create an image for user allocated image data.
 
 Image (Size size)
 Convenience method to create an image of size.ceil() pixels.
 
 Image (const String &path, const Bytes &data=Bytes{})
 Load image from path.
 
 Image (const char *path)
 Convenience method to load an image from path.
 
int width () const
 Width of the image in pixels.
 
int height () const
 Height of the image in pixels.
 
Size size () const
 Get the size of the image.
 
int pitch () const
 Number of bytes per image row.
 
Bytesdata ()
 Directly access image data.
 
const Bytesdata () const
 Directly access image data.
 
Colorpixel (long i)
 Get a reference to the i-th pixel.
 
const Colorpixel (long i) const
 Get a constant reference to the i-th pixel.
 
long count () const
 Number of pixels.
 
void clear (Color c)
 Clear the entire image with color c.
 
void premultiply ()
 Convert the entire image from normal alpha to pre-multiplied alpha.
 
void normalize ()
 Convert the entire image from pre-multiplied alpha to normal alpha.
 
Image copy () const
 Create a deep copy of this image.
 
void copyToXy (Out< Image > target, int x, int y) const
 Copy this image to target at (x, y)
 
void applyOver (Color paper)
 Add background paper to each transparent pixel.
 
bool checkOpaque () const
 Check if all pixels of this image are opaque.
 
void tone (Color color)
 Replace the red, green and blue of all non-transparent pixels by red, green and blue of color.
 
void shadowBlur (int radius, Color shadowColor)
 Replace this image by a low-pass monochrome version of itself.
 
Image scale (int scaledWidth, int scaledHeight) const
 Scaled image to new size (scaledWidth, scaledHeight)
 
void save (const String &path, const String &mediaType="")
 Save image to path using given mediaType.
 
cairo_surface_t * cairoSurface ()
 
- Public Member Functions inherited from Surface
 Surface ()=default
 Create a null surface.
 
void nextPage (bool clear=true)
 Open next page.
 
cairo_surface_t * cairoSurface ()
 Get a pointer to the underlying Cairo surface.
 
void polish ()
 Prepare surface before start painting.
 
- Public Member Functions inherited from Object
 Object ()=default
 Create a null object.
 
 operator bool () const
 Check if this is a non-null object.
 
bool isNull () const
 Check if this is a null object.
 
template<class T >
bool is () const
 Check if this object is of type T.
 
template<class T >
as () const
 Cast this object to type T.
 
bool isWeak () const
 Check if the underlying object reference is weak.
 
bool operator== (const Object &other) const
 Equality operator.
 
std::strong_ordering operator<=> (const Object &other) const
 Ordering operator.
 
long useCount () const
 Reference count.
 

Additional Inherited Members

- Protected Member Functions inherited from Surface
 Surface (State *newState)
 
State & me ()
 
const State & me () const
 
- Protected Member Functions inherited from Object
template<class T >
weak () const
 
template<class T >
void initOnce ()
 Create the object state when called the first time.
 
template<class T >
void initOncePerThread ()
 Create a distinct object state for each thread when called the first time in that thread.
 
 Object (State *newState)
 Initialize object with newState.
 
 Object (State *state, Alias)
 
 Object (State *state, Weak)
 
Objectoperator= (std::nullptr_t)
 
- Static Protected Member Functions inherited from Object
template<class T >
static T alias (const State *state)
 Create an alias object for the given state.
 
template<class T >
static T weak (const State *state)
 
- Protected Attributes inherited from Object
Handle< Stateme
 Internal object state
 

Detailed Description

2-dimensional color matrix

Constructor & Destructor Documentation

◆ Image() [1/6]

Image ( )
default

Create a null image.

◆ Image() [2/6]

Image ( int width,
int height )

Create an image of width x height pixels.

◆ Image() [3/6]

Image ( int width,
int height,
const Bytes & data )

Create an image for user allocated image data.

◆ Image() [4/6]

Image ( Size size)
explicit

Convenience method to create an image of size.ceil() pixels.

◆ Image() [5/6]

Image ( const String & path,
const Bytes & data = Bytes{} )

Load image from path.

Parameters
pathFile system or resource path
dataOptionally pass already loaded image data
Note
If loading of the image data fails a null image is created instead.

◆ Image() [6/6]

Image ( const char * path)

Convenience method to load an image from path.

See also
Image(const String &, const Bytes &)

Member Function Documentation

◆ width()

int width ( ) const

Width of the image in pixels.

◆ height()

int height ( ) const

Height of the image in pixels.

◆ size()

Size size ( ) const

Get the size of the image.

◆ pitch()

int pitch ( ) const

Number of bytes per image row.

◆ data() [1/2]

Bytes & data ( )

Directly access image data.

◆ data() [2/2]

const Bytes & data ( ) const

Directly access image data.

◆ pixel() [1/2]

Color & pixel ( long i)

Get a reference to the i-th pixel.

◆ pixel() [2/2]

const Color & pixel ( long i) const

Get a constant reference to the i-th pixel.

◆ count()

long count ( ) const

Number of pixels.

◆ clear()

void clear ( Color c)

Clear the entire image with color c.

◆ premultiply()

void premultiply ( )

Convert the entire image from normal alpha to pre-multiplied alpha.

◆ normalize()

void normalize ( )

Convert the entire image from pre-multiplied alpha to normal alpha.

◆ copy()

Image copy ( ) const

Create a deep copy of this image.

◆ copyToXy()

void copyToXy ( Out< Image > target,
int x,
int y ) const

Copy this image to target at (x, y)

◆ applyOver()

void applyOver ( Color paper)

Add background paper to each transparent pixel.

◆ checkOpaque()

bool checkOpaque ( ) const

Check if all pixels of this image are opaque.

◆ tone()

void tone ( Color color)

Replace the red, green and blue of all non-transparent pixels by red, green and blue of color.

◆ shadowBlur()

void shadowBlur ( int radius,
Color shadowColor )

Replace this image by a low-pass monochrome version of itself.

Parameters
radiusBlur radius
shadowColorReplacement color

◆ scale()

Image scale ( int scaledWidth,
int scaledHeight ) const

Scaled image to new size (scaledWidth, scaledHeight)

◆ save()

void save ( const String & path,
const String & mediaType = "" )

Save image to path using given mediaType.

Warning
Any existing file under path will be silently overwritten.