![]() |
1.1 |
Raster image resource used for drawing or displaying. More...
Public Member Functions | |
Image (cairo_surface_t *surface) | |
Image (const std::string &uri, float hscale, float vscale) | |
Construct a raster image from a URI with an optional scale. More... | |
Image (const std::string &uri={}, float scale=1.0) | |
Construct a raster image from a URI with an optional scale. More... | |
Image (const unsigned char *data, size_t len) | |
Construct a raster image from memory. More... | |
Image (shared_cairo_surface_t surface) | |
void | copy () |
This function must be called any time the surface is going to be modified. More... | |
Image | crop (const Rect &rect) |
Image | crop (const RectF &rect) |
void | deserialize (const std::string &name, const std::string &value, const Serializer::Attributes &attrs) |
Deserialized property. More... | |
EGT_NODISCARD bool | empty () const |
Returns true if no internal surface is set. More... | |
EGT_NODISCARD DefaultDim | height () const |
EGT_NODISCARD float | hscale () const |
Get the horizontal scale value. More... | |
void | load (const std::string &uri, float hscale=1.0, float vscale=1.0) |
Load a new source image with an optional scale. More... | |
EGT_NODISCARD cairo_pattern_t * | pattern () const |
Get internal pattern representation. More... | |
void | resize (const Size &size) |
Resize the image to the specified absolute size. More... | |
void | scale (float hscale, float vscale, bool approximate=false) |
Scale the image. More... | |
void | scale (float scale, bool approximate=false) |
Scale the image. More... | |
void | serialize (const std::string &name, Serializer &serializer) const |
Serialize to the specified serializer. More... | |
EGT_NODISCARD Size | size () const |
Get the absolute size of the image. More... | |
EGT_NODISCARD Size | size_orig () const |
Get the original size of the image before any Image::resize() or Image::scale() calls. More... | |
EGT_NODISCARD shared_cairo_surface_t | surface () const |
Get a reference to the internal image surface. More... | |
EGT_NODISCARD std::string | uri () const |
EGT_NODISCARD float | vscale () const |
Get the vertical scale value. More... | |
EGT_NODISCARD DefaultDim | width () const |
Protected Attributes | |
float | m_hscale {1.0} |
Horizontal scale value, compared to original. More... | |
Size | m_orig_size |
Original image size. More... | |
shared_cairo_pattern_t | m_pattern |
Internal pattern representation. More... | |
shared_cairo_surface_t | m_surface |
Shared surface pointer. More... | |
shared_cairo_surface_t | m_surface_local |
Local surface pointer. More... | |
std::string | m_uri |
If a URI was used, the URI. More... | |
float | m_vscale {1.0} |
Vertical scale value, compared to original. More... | |
Raster image resource used for drawing or displaying.
This class by default shares the internal surface pointer with anything else using the surface. To force this class to keep its own copy, call the copy() function.
Image | ( | const std::string & | uri = {} , |
float | scale = 1.0 |
||
) |
Image | ( | const std::string & | uri, |
float | hscale, | ||
float | vscale | ||
) |
Construct a raster image from a URI with an optional scale.
uri | Resource path. |
hscale | Horizontal scale of the image, with 1.0 being 100%. |
vscale | Vertical scale of the image, with 1.0 being 100%. |
Image | ( | const unsigned char * | data, |
size_t | len | ||
) |
Construct a raster image from memory.
data | Pointer to the data. |
len | Length of the data. |
Image | ( | shared_cairo_surface_t | surface | ) |
surface | A pre-existing surface. |
This takes a reference to the passed in image.
Image | ( | cairo_surface_t * | surface | ) |
surface | A pre-existing surface. |
This will not own the passed in pointer or surface, and instead will make a copy of the surface.
void copy | ( | ) |
void deserialize | ( | const std::string & | name, |
const std::string & | value, | ||
const Serializer::Attributes & | attrs | ||
) |
Deserialized property.
|
inline |
Returns true if no internal surface is set.
|
inline |
|
inline |
Get the horizontal scale value.
void load | ( | const std::string & | uri, |
float | hscale = 1.0 , |
||
float | vscale = 1.0 |
||
) |
Load a new source image with an optional scale.
uri | Resource path. |
hscale | Horizontal scale of the image, with 1.0 being 100%. |
vscale | Vertical scale of the image, with 1.0 being 100%. |
|
inline |
Get internal pattern representation.
|
inline |
Resize the image to the specified absolute size.
size | The new size of the image. |
void scale | ( | float | hscale, |
float | vscale, | ||
bool | approximate = false |
||
) |
Scale the image.
Change the scale of the image, similar to calling Image::resize().
This scales relative to the original size of the image. Not the result of any subsequent Image::resize() or Image::scale() call.
hscale | Horizontal scale of the image, with 1.0 being 100%. |
vscale | Vertical scale of the image, with 1.0 being 100%. |
approximate | Approximate the scale to increase image cache hit efficiency. |
|
inline |
Scale the image.
void serialize | ( | const std::string & | name, |
Serializer & | serializer | ||
) | const |
Serialize to the specified serializer.
|
inline |
Get the absolute size of the image.
|
inline |
Get the original size of the image before any Image::resize() or Image::scale() calls.
|
inline |
Get a reference to the internal image surface.
|
inline |
|
inline |
Get the vertical scale value.
|
inline |
|
protected |
Horizontal scale value, compared to original.
|
protected |
Original image size.
|
mutableprotected |
Internal pattern representation.
|
protected |
Shared surface pointer.
|
protected |
Local surface pointer.
|
protected |
If a URI was used, the URI.
|
protected |
Vertical scale value, compared to original.