Top | ![]() |
![]() |
![]() |
![]() |
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 () |
gboolean | gdk_texture_save_to_png () |
GdkTexture * | gdk_memory_texture_new () |
GdkTexture * | gdk_gl_texture_new () |
void | gdk_gl_texture_release () |
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_pixbuf (GdkPixbuf *pixbuf
);
Creates a new texture object representing the GdkPixbuf.
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.
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.
int
gdk_texture_get_width (GdkTexture *texture
);
Returns the width of texture
.
int
gdk_texture_get_height (GdkTexture *texture
);
Returns the height of the texture
.
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); |
gboolean gdk_texture_save_to_png (GdkTexture *texture
,const char *filename
);
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 GFile or other location, you might want to look into using the gdk-pixbuf library.
GdkTexture * gdk_memory_texture_new (int width
,int height
,GdkMemoryFormat format
,GBytes *bytes
,gsize stride
);
Creates a new texture for a blob of image data.
The GBytes must contain stride
x height
pixels
in the given format.
GdkTexture * gdk_gl_texture_new (GdkGLContext *context
,guint id
,int width
,int height
,GDestroyNotify destroy
,gpointer data
);
Creates a new texture for an existing GL texture.
Note that the GL texture must not be modified until destroy
is called,
which will happen when the GdkTexture object is finalized, or due to
an explicit call of gdk_gl_texture_release()
.
void
gdk_gl_texture_release (GdkGLTexture *self
);
Releases the GL resources held by a GdkGLTexture that
was created with gdk_gl_texture_new()
.
The texture contents are still available via the
gdk_texture_download()
function, after this function
has been called.