Loading a pixbuf from a file.
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
<gdk-pixbuf-loader>
functionality instead.
mchars
) ⇒ (ret <gdk-pixbuf>
)Creates a new pixbuf by loading an image from a file. The file format is detected automatically. If ‘
#f
’ is returned, then error will be set. Possible errors are in the<gdk-pixbuf-error>
and<g-file-error>
domains.
- filename
- Name of file to load, in the GLib file name encoding
- error
- Return location for an error
- ret
- A newly-created pixbuf with a reference count of 1, or ‘
#f
’ if any of several error conditions occurred: the file could not be opened, there was no loader for the file's format, there was not enough memory to allocate the image buffer, or the image file contained invalid data.
mchars
) (width int
) (height int
) ⇒ (ret <gdk-pixbuf>
)Creates a new pixbuf by loading an image from a file. The file format is detected automatically. If ‘
#f
’ is returned, then error will be set. Possible errors are in the<gdk-pixbuf-error>
and<g-file-error>
domains. The image will be scaled to fit in the requested size, preserving the image's aspect ratio.
- 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
- ret
- A newly-created pixbuf with a reference count of 1, or ‘
#f
’ if any of several error conditions occurred: the file could not be opened, there was no loader for the file's format, there was not enough memory to allocate the image buffer, or the image file contained invalid data.Since 2.4
mchars
) (width int
) (height int
) (preserve_aspect_ratio bool
) ⇒ (ret <gdk-pixbuf>
)Creates a new pixbuf by loading an image from a file. The file format is detected automatically. If ‘
#f
’ is returned, then error will be set. Possible errors are in the<gdk-pixbuf-error>
and<g-file-error>
domains. 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. 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
- ‘
#t
’ to preserve the image's aspect ratio- error
- Return location for an error
- ret
- A newly-created pixbuf with a reference count of 1, or ‘
#f
’ if any of several error conditions occurred: the file could not be opened, there was no loader for the file's format, there was not enough memory to allocate the image buffer, or the image file contained invalid data.Since 2.6