Pixbuf

constructor(colorspace: Colorspace, hasAlpha: Boolean, bitsPerSample: Int, width: Int, height: Int)

Creates a new GdkPixbuf structure and allocates a buffer for it.

If the allocation of the buffer failed, this function will return NULL.

The buffer has an optimal rowstride. Note that the buffer is not cleared; you will have to fill it completely yourself.

Return

A newly-created pixel buffer

Parameters

colorspace

Color space for image

hasAlpha

Whether the image should have transparency information

bitsPerSample

Number of bits per color sample

width

Width of image in pixels, must be 0

height

Height of image in pixels, must be 0


constructor(data: <Error class: unknown class>, colorspace: Colorspace, hasAlpha: Boolean, bitsPerSample: Int, width: Int, height: Int, rowstride: Int)

Creates a new #GdkPixbuf out of in-memory readonly image data.

Currently only RGB images with 8 bits per sample are supported.

This is the GBytes variant of gdk_pixbuf_new_from_data(), useful for language bindings.

Return

A newly-created pixbuf

Since

2.32

Parameters

data

Image data in 8-bit/sample packed format inside a #GBytes

colorspace

Colorspace for the image data

hasAlpha

Whether the data has an opacity channel

bitsPerSample

Number of bits per sample

width

Width of the image in pixels, must be 0

height

Height of the image in pixels, must be 0

rowstride

Distance in bytes between row starts


constructor(filename: String)

Creates a new pixbuf by loading an image from a file.

The file format is detected automatically.

If NULL is returned, then @error will be set. Possible errors are:

  • the file could not be opened

  • there is no loader for the file's format

  • there is not enough memory to allocate the image buffer

  • the image buffer contains invalid data

The error domains are GDK_PIXBUF_ERROR and G_FILE_ERROR.

Return

A newly-created pixbuf

Parameters

filename

Name of file to load, in the GLib file name encoding


constructor(filename: String, width: Int, height: Int, preserveAspectRatio: Boolean)

Creates a new pixbuf by loading an image from a file.

The file format is detected automatically.

If NULL is returned, then @error will be set. Possible errors are:

  • the file could not be opened

  • there is no loader for the file's format

  • there is not enough memory to allocate the image buffer

  • the image buffer contains invalid data

The error domains are GDK_PIXBUF_ERROR and G_FILE_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. Negative values for width and height are allowed since 2.8.

Return

A newly-created pixbuf

Since

2.6

Parameters

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

preserveAspectRatio

TRUE to preserve the image's aspect ratio


constructor(filename: String, width: Int, height: Int)

Creates a new pixbuf by loading an image from a file.

The file format is detected automatically.

If NULL is returned, then @error will be set. Possible errors are:

  • the file could not be opened

  • there is no loader for the file's format

  • there is not enough memory to allocate the image buffer

  • the image buffer contains invalid data

The error domains are GDK_PIXBUF_ERROR and G_FILE_ERROR.

The image will be scaled to fit in the requested size, preserving the image's aspect ratio. Note that the returned pixbuf may be smaller than width x height, if the aspect ratio requires it. To load and image at the requested size, regardless of aspect ratio, use ctor@GdkPixbuf.Pixbuf.new_from_file_at_scale.

Return

A newly-created pixbuf

Since

2.4

Parameters

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


constructor(stream: <Error class: unknown class>, cancellable: <Error class: unknown class>? = null)

Creates a new pixbuf by loading an image from an input stream.

The file format is detected automatically.

If NULL is returned, then error will be set.

The cancellable can be used to abort the operation from another thread. If the operation was cancelled, the error G_IO_ERROR_CANCELLED will be returned. Other possible errors are in the GDK_PIXBUF_ERROR and G_IO_ERROR domains.

The stream is not closed.

Return

A newly-created pixbuf

Since

2.14

Parameters

stream

a GInputStream to load the pixbuf from

cancellable

optional GCancellable object, NULL to ignore


constructor(stream: <Error class: unknown class>, width: Int, height: Int, preserveAspectRatio: Boolean, cancellable: <Error class: unknown class>? = null)

Creates a new pixbuf by loading an image from an input stream.

The file format is detected automatically. If NULL is returned, then

Return

A newly-created pixbuf

Since

2.14

Parameters

stream

a GInputStream to load the pixbuf from

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

preserveAspectRatio

TRUE to preserve the image's aspect ratio

cancellable

optional GCancellable object, NULL to ignore


constructor(asyncResult: <Error class: unknown class>)

Finishes an asynchronous pixbuf creation operation started with gdk_pixbuf_new_from_stream_async().

Return

the newly created pixbuf

Since

2.24

Parameters

asyncResult

a GAsyncResult


constructor(data: List<String>)

Creates a new pixbuf by parsing XPM data in memory.

This data is commonly the result of including an XPM file into a program's C source.

Return

A newly-created pixbuf

Parameters

data

Pointer to inline XPM data.


constructor(pointer: <Error class: unknown class><<Error class: unknown class>>)