Top | ![]() |
![]() |
![]() |
![]() |
GdkTexture * | gdk_texture_new_for_data () |
GdkTexture * | gdk_texture_new_for_pixbuf () |
GdkTexture * | gdk_texture_new_from_resource () |
GdkTexture * | gdk_texture_new_from_file () |
int | gdk_texture_get_width () |
int | gdk_texture_get_height () |
void | gdk_texture_download () |
GdkTexture is the basic element used to refer to pixel data. It is primarily mean for pixel data that will not change over multiple frames, and will be used for a long time.
You cannot get your pixel data back once you've uploaded it.
GdkTexture is an immutable object: That means you cannot change
anything about it other than increasing the reference count via
g_object_ref()
.
GdkTexture * gdk_texture_new_for_data (const guchar *data
,int width
,int height
,int stride
);
Creates a new texture object holding the given data. The data is assumed to be in CAIRO_FORMAT_ARGB32 format.
data |
the pixel data. |
[array] |
width |
the number of pixels in each row |
|
height |
the number of rows |
|
stride |
the distance from the beginning of one row to the next, in bytes |
Since: 3.94
GdkTexture *
gdk_texture_new_for_pixbuf (GdkPixbuf *pixbuf
);
Creates a new texture object representing the GdkPixbuf.
Since: 3.94
GdkTexture *
gdk_texture_new_from_resource (const char *resource_path
);
Creates a new texture by loading an image from a resource. The file format is detected automatically.
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
gdk_texture_new_from_file()
to load it.
Since: 3.94
GdkTexture * gdk_texture_new_from_file (GFile *file
,GError **error
);
Creates a new texture by loading an image from a file. The file format is
detected automatically. If NULL
is returned, then error
will be set.
Since: 3.94
int
gdk_texture_get_width (GdkTexture *texture
);
Returns the width of texture
.
Since: 3.94
int
gdk_texture_get_height (GdkTexture *texture
);
Returns the height of the texture
.
Since: 3.94
void gdk_texture_download (GdkTexture *texture
,guchar *data
,gsize stride
);
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_FORMAT_ARGB32
, so every downloaded pixel requires
4 bytes of memory.
Downloading a texture into a Cairo image surface:
1 2 3 4 5 6 7 |
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, gdk_texture_get_width (texture), gdk_texture_get_height (texture)); gdk_texture_download (texture, cairo_image_surface_get_data (surface), cairo_image_surface_get_stride (surface)); cairo_surface_mark_dirty (surface); |
texture |
||
data |
pointer to enough memory to be filled with the
downloaded data of |
[array] |
stride |
rowstride in bytes |
Since: 3.94