| The gdk-pixbuf Library | ||||
|---|---|---|---|---|
#include <gdk-pixbuf/gdk-pixbuf.h> GdkPixbuf* gdk_pixbuf_new_from_file (constchar *filename,GError **error); GdkPixbuf* gdk_pixbuf_new_from_file_at_size (constchar *filename,int width,int height,GError **error); GdkPixbuf* gdk_pixbuf_new_from_file_at_scale (constchar *filename,int width,int height,gboolean preserve_aspect_ratio,GError **error); GdkPixbufFormat* gdk_pixbuf_get_file_info (constgchar *filename,gint *width,gint *height); GdkPixbuf* gdk_pixbuf_new_from_stream (GInputStream *stream,GCancellable *cancellable,GError **error); GdkPixbuf* gdk_pixbuf_new_from_stream_at_scale (GInputStream *stream,gint width,gint height,gboolean preserve_aspect_ratio,GCancellable *cancellable,GError **error);
The gdk-pixbuf library provides a simple mechanism for loading an image from a file in synchronous fashion. This means that the library takes control of the application while the file is being loaded; from the user's point of view, the application will block until the image is done loading.
This interface can be used by applications in which blocking is acceptable while an image is being loaded. It can also be used to load small images in general. Applications that need progressive loading can use the GdkPixbufLoader functionality instead.
GdkPixbuf* gdk_pixbuf_new_from_file (constchar *filename,GError **error);
Creates a new pixbuf by loading an image from a file. The file format is
detected automatically. If NULLerror will be set.
Possible errors are in the GDK_PIXBUF_ERROR and
filename : |
Name of file to load, in the GLib file name encoding |
error : |
Return location for an error |
| Returns : | A newly-created pixbuf with a reference count of 1, or NULL |
GdkPixbuf* gdk_pixbuf_new_from_file_at_size (constchar *filename,int width,int height,GError **error);
Creates a new pixbuf by loading an image from a file. The file format is
detected automatically. If NULLerror will be set.
Possible errors are in the GDK_PIXBUF_ERROR and
filename : |
Name of file to load, in the GLib file name encoding |
width : |
The width the image should have or -1 to not constrain the width |
height : |
The height the image should have or -1 to not constrain the height |
error : |
Return location for an error |
| Returns : | A newly-created pixbuf with a reference count of 1, or
NULL |
Since 2.4
GdkPixbuf* gdk_pixbuf_new_from_file_at_scale (constchar *filename,int width,int height,gboolean preserve_aspect_ratio,GError **error);
Creates a new pixbuf by loading an image from a file. The file format is
detected automatically. If NULLerror will be set.
Possible errors are in the GDK_PIXBUF_ERROR and
When preserving the aspect ratio, a width of -1 will cause the image
to be scaled to the exact given height, and a height of -1 will cause
the image to be scaled to the exact given width. When not preserving
aspect ratio, a width or height of -1 means to not scale the image
at all in that dimension. Negative values for width and height are
allowed since 2.8.
filename : |
Name of file to load, in the GLib file name encoding |
width : |
The width the image should have or -1 to not constrain the width |
height : |
The height the image should have or -1 to not constrain the height |
preserve_aspect_ratio : |
TRUE |
error : |
Return location for an error |
| Returns : | A newly-created pixbuf with a reference count of 1, or NULL |
Since 2.6
GdkPixbufFormat* gdk_pixbuf_get_file_info (constgchar *filename,gint *width,gint *height);
Parses an image file far enough to determine its format and size.
filename : |
The name of the file to identify. |
width : |
Return location for the width of the image, or NULL |
height : |
Return location for the height of the image, or NULL |
| Returns : | A GdkPixbufFormat describing the image format of the file
or NULL |
Since 2.4
GdkPixbuf* gdk_pixbuf_new_from_stream (GInputStream *stream,GCancellable *cancellable,GError **error);
Creates a new pixbuf by loading an image from an input stream.
The file format is detected automatically. If NULLerror will be set. The cancellable can be used to abort the operation
from another thread. If the operation was cancelled, the error
GIO_ERROR_CANCELLEDG_IO_ERROR
The stream is not closed.
stream : |
a |
cancellable : |
optional NULL |
error : |
Return location for an error |
| Returns : | A newly-created pixbuf, or NULL |
Since 2.14
GdkPixbuf* gdk_pixbuf_new_from_stream_at_scale (GInputStream *stream,gint width,gint height,gboolean preserve_aspect_ratio,GCancellable *cancellable,GError **error);
Creates a new pixbuf by loading an image from an input stream.
The file format is detected automatically. If NULLerror will be set. The cancellable can be used to abort the operation
from another thread. If the operation was cancelled, the error
GIO_ERROR_CANCELLEDG_IO_ERROR
The image will be scaled to fit in the requested size, optionally
preserving the image's aspect ratio. When preserving the aspect ratio,
a width of -1 will cause the image to be scaled to the exact given
height, and a height of -1 will cause the image to be scaled to the
exact given width. When not preserving aspect ratio, a width or
height of -1 means to not scale the image at all in that dimension.
The stream is not closed.
stream : |
a |
width : |
The width the image should have or -1 to not constrain the width |
height : |
The height the image should have or -1 to not constrain the height |
preserve_aspect_ratio : |
TRUE |
cancellable : |
optional NULL |
error : |
Return location for an error |
| Returns : | A newly-created pixbuf, or NULL |
Since 2.14