gtkmm 4.16.0
|
Pixel data. More...
#include <gdkmm/texture.h>
Public Member Functions | |
Texture (Texture &&src) noexcept | |
Texture & | operator= (Texture &&src) noexcept |
~Texture () noexcept override | |
GdkTexture * | gobj () |
Provides access to the underlying C GObject. | |
const GdkTexture * | gobj () const |
Provides access to the underlying C GObject. | |
GdkTexture * | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
int | get_width () const |
Returns the width of texture, in pixels. | |
int | get_height () const |
Returns the height of the texture, in pixels. | |
MemoryFormat | get_format () const |
Gets the memory format most closely associated with the data of the texture. | |
Glib::RefPtr< ColorState > | get_color_state () const |
Returns the color state associated with the texture. | |
void | download (guchar *data, gsize stride) const |
Downloads the texture into local memory. | |
bool | save_to_png (const Glib::ustring &filename) const |
Store the given texture to the filename as a PNG file. | |
Glib::RefPtr< Glib::Bytes > | save_to_png_bytes () const |
Store the given texture in memory as a PNG file. | |
bool | save_to_tiff (const std::string &filename) const |
Store the given texture to the filename as a TIFF file. | |
Glib::RefPtr< Glib::Bytes > | save_to_tiff_bytes () const |
Store the given texture in memory as a TIFF file. | |
Glib::PropertyProxy_ReadOnly< int > | property_width () const |
The width of the texture, in pixels. | |
Glib::PropertyProxy_ReadOnly< int > | property_height () const |
The height of the texture, in pixels. | |
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< ColorState > > | property_color_state () const |
The color state of the texture. | |
Public Member Functions inherited from Gdk::Paintable | |
Paintable (Paintable &&src) noexcept | |
Paintable & | operator= (Paintable &&src) noexcept |
~Paintable () noexcept override | |
GdkPaintable * | gobj () |
Provides access to the underlying C GObject. | |
const GdkPaintable * | gobj () const |
Provides access to the underlying C GObject. | |
void | snapshot (const Glib::RefPtr< Gdk::Snapshot > & snapshot, double width, double height) |
Snapshots the given paintable with the given width and height. | |
Glib::RefPtr< const Paintable > | get_current_image () const |
Gets an immutable paintable for the current contents displayed by paintable. | |
Flags | get_flags () const |
Get flags for the paintable. | |
int | get_intrinsic_width () const |
Gets the preferred width the paintable would like to be displayed at. | |
int | get_intrinsic_height () const |
Gets the preferred height the paintable would like to be displayed at. | |
double | get_intrinsic_aspect_ratio () const |
Gets the preferred aspect ratio the paintable would like to be displayed at. | |
void | compute_concrete_size (double specified_width, double specified_height, double default_width, double default_height, double &concrete_width, double &concrete_height) const |
Compute a concrete size for the Gdk::Paintable . | |
void | invalidate_contents () |
Called by implementations of Gdk::Paintable to invalidate their contents. | |
void | invalidate_size () |
Called by implementations of Gdk::Paintable to invalidate their size. | |
Glib::SignalProxy< void()> | signal_invalidate_contents () |
Glib::SignalProxy< void()> | signal_invalidate_size () |
Static Public Member Functions | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
static Glib::RefPtr< Texture > | create_for_pixbuf (const Glib::RefPtr< Pixbuf > &pixbuf) |
Creates a new texture object representing the Gdk::Pixbuf . | |
static Glib::RefPtr< Texture > | create_from_resource (const std::string &resource_path) |
Creates a new texture by loading an image from a resource. | |
static Glib::RefPtr< Texture > | create_from_file (const Glib::RefPtr< Gio::File > & file) |
Creates a new texture by loading an image from a file. | |
static Glib::RefPtr< Texture > | create_from_filename (const std::string & path) |
Creates a new texture by loading an image from a file. | |
static Glib::RefPtr< Texture > | create_from_bytes (const Glib::RefPtr< const Glib::Bytes > &bytes) |
Creates a new texture by loading an image from memory,. | |
Static Public Member Functions inherited from Gdk::Paintable | |
static void | add_interface (GType gtype_implementer) |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
Protected Member Functions | |
Texture () | |
Protected Member Functions inherited from Gdk::Paintable | |
Paintable () | |
You should derive from this class to use it. | |
virtual void | snapshot_vfunc (const Glib::RefPtr< Gdk::Snapshot > &snapshot, double width, double height) |
virtual Glib::RefPtr< Paintable > | get_current_image_vfunc () const |
virtual Flags | get_flags_vfunc () const |
virtual int | get_intrinsic_width_vfunc () const |
virtual int | get_intrinsic_height_vfunc () const |
virtual double | get_intrinsic_aspect_ratio_vfunc () const |
Related Symbols | |
(Note that these are not member symbols.) | |
Glib::RefPtr< Gdk::Texture > | wrap (GdkTexture *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
Related Symbols inherited from Gdk::Paintable | |
Glib::RefPtr< Gdk::Paintable > | wrap (GdkPaintable *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
Additional Inherited Members | |
Public Types inherited from Gdk::Paintable | |
enum class | Flags { Flags::STATIC_SIZE = 1 << 0 , Flags::STATIC_CONTENTS = 1 << 1 } |
Flags about a paintable object. More... | |
Pixel data.
Gdk::Texture is the basic element used to refer to pixel data. It is primarily meant for pixel data that will not change over multiple frames, and will be used for a long time.
There are various ways to create Gdk::Texture objects from a Gdk::Pixbuf, or a Cairo surface, or other pixel data.
The ownership of the pixel data is transferred to the Gdk::Texture instance; you can only make a copy of it, via download().
Gdk::Texture is an immutable object: That means you cannot change anything about it.
|
noexcept |
|
overridenoexcept |
|
protected |
|
static |
Creates a new texture object representing the Gdk::Pixbuf
.
This function is threadsafe, so that you can e.g. use GTask and Gio::Task::run_in_thread() to avoid blocking the main thread while loading a big image.
pixbuf | A Gdk::Pixbuf . |
Gdk::Texture
.
|
static |
Creates a new texture by loading an image from memory,.
The file format is detected automatically. The supported formats are PNG, JPEG and TIFF, though more formats might be available.
If nullptr
is returned, then error will be set.
This function is threadsafe, so that you can e.g. use GTask and Gio::Task::run_in_thread() to avoid blocking the main thread while loading a big image.
bytes | A Glib::Bytes containing the data to load. |
Gdk::Texture
.Glib::Error |
|
static |
Creates a new texture by loading an image from a file.
The file format is detected automatically. The supported formats are PNG, JPEG and TIFF, though more formats might be available.
If nullptr
is returned, then error will be set.
This function is threadsafe, so that you can e.g. use GTask and Gio::Task::run_in_thread() to avoid blocking the main thread while loading a big image.
file | File to load. |
Gdk::Texture
.Glib::Error |
|
static |
Creates a new texture by loading an image from a file.
The file format is detected automatically. The supported formats are PNG, JPEG and TIFF, though more formats might be available.
If nullptr
is returned, then error will be set.
This function is threadsafe, so that you can e.g. use GTask and Gio::Task::run_in_thread() to avoid blocking the main thread while loading a big image.
path | The filename to load. |
Gdk::Texture
.Glib::Error |
|
static |
Creates a new texture by loading an image from a resource.
The file format is detected automatically. The supported formats are PNG and JPEG, though more formats might be available.
It is a fatal error if resource_path does not specify a valid image resource and the program will abort if that happens. If you are unsure about the validity of a resource, use new_from_file() to load it.
This function is threadsafe, so that you can e.g. use GTask and Gio::Task::run_in_thread() to avoid blocking the main thread while loading a big image.
resource_path | The path of the resource file. |
Gdk::Texture
. Downloads the texture into local memory.
This may be an expensive operation, as the actual texture data may reside on a GPU or on a remote display server.
The data format of the downloaded data is equivalent to Cairo::Surface::Format::ARGB32, so every downloaded pixel requires 4 bytes of memory.
Downloading a texture into a Cairo image surface:
[C example ellipted]
For more flexible download capabilities, see Gdk::TextureDownloader.
data | Pointer to enough memory to be filled with the downloaded data of texture. |
stride | Rowstride in bytes. |
Glib::RefPtr< ColorState > Gdk::Texture::get_color_state | ( | ) | const |
Returns the color state associated with the texture.
Gdk::Texture
. MemoryFormat Gdk::Texture::get_format | ( | ) | const |
Gets the memory format most closely associated with the data of the texture.
Note that it may not be an exact match for texture data stored on the GPU or with compression.
The format can give an indication about the bit depth and opacity of the texture and is useful to determine the best format for downloading the texture.
int Gdk::Texture::get_height | ( | ) | const |
Returns the height of the texture, in pixels.
Gdk::Texture
.
|
static |
Get the GType for this class, for use with the underlying GObject type system.
int Gdk::Texture::get_width | ( | ) | const |
Returns the width of texture, in pixels.
Gdk::Texture
.
|
inline |
Provides access to the underlying C GObject.
|
inline |
Provides access to the underlying C GObject.
GdkTexture * Gdk::Texture::gobj_copy | ( | ) |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< ColorState > > Gdk::Texture::property_color_state | ( | ) | const |
The color state of the texture.
Glib::PropertyProxy_ReadOnly< int > Gdk::Texture::property_height | ( | ) | const |
The height of the texture, in pixels.
Default value: 1
Glib::PropertyProxy_ReadOnly< int > Gdk::Texture::property_width | ( | ) | const |
The width of the texture, in pixels.
Default value: 1
bool Gdk::Texture::save_to_png | ( | const Glib::ustring & | filename | ) | const |
Store the given texture to the filename as a PNG file.
This is a utility function intended for debugging and testing. If you want more control over formats, proper error handling or want to store to a Gio::File or other location, you might want to use save_to_png_bytes() or look into the gdk-pixbuf library.
filename | The filename to store to. |
true
if saving succeeded, false
on failure. Glib::RefPtr< Glib::Bytes > Gdk::Texture::save_to_png_bytes | ( | ) | const |
Store the given texture in memory as a PNG file.
Use new_from_bytes() to read it back.
If you want to serialize a texture, this is a convenient and portable way to do that.
If you need more control over the generated image, such as attaching metadata, you should look into an image handling library such as the gdk-pixbuf library.
If you are dealing with high dynamic range float data, you might also want to consider save_to_tiff_bytes() instead.
Glib::Bytes
containing PNG data. bool Gdk::Texture::save_to_tiff | ( | const std::string & | filename | ) | const |
Store the given texture to the filename as a TIFF file.
GTK will attempt to store data without loss.
filename | The filename to store to. |
true
if saving succeeded, false
on failure. Glib::RefPtr< Glib::Bytes > Gdk::Texture::save_to_tiff_bytes | ( | ) | const |
Store the given texture in memory as a TIFF file.
Use new_from_bytes() to read it back.
This function is intended to store a representation of the texture's data that is as accurate as possible. This is particularly relevant when working with high dynamic range images and floating-point texture data.
If that is not your concern and you are interested in a smaller size and a more portable format, you might want to use save_to_png_bytes().
Glib::Bytes
containing TIFF data.
|
related |
A Glib::wrap() method for this object.
object | The C instance. |
take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref. |