PixbufProtocol
public protocol PixbufProtocol : LoadableIconProtocol, ObjectProtocol
A pixel buffer.
GdkPixbuf contains information about an image’s pixel data,
its color space, bits per sample, width and height, and the
rowstride (the number of bytes between the start of one row
and the start of the next).
Creating new GdkPixbuf
The most basic way to create a pixbuf is to wrap an existing pixel
buffer with a [classGdkPixbuf.Pixbuf] instance. You can use the
[ctorGdkPixbuf.Pixbuf.new_from_data``] function to do this.
Every time you create a new GdkPixbuf instance for some data, you
will need to specify the destroy notification function that will be
called when the data buffer needs to be freed; this will happen when
a GdkPixbuf is finalized by the reference counting functions. If
you have a chunk of static data compiled into your application, you
can pass in NULL as the destroy notification function so that the
data will not be freed.
The [ctorGdkPixbuf.Pixbuf.new] constructor function can be used
as a convenience to create a pixbuf with an empty buffer; this is
equivalent to allocating a data buffer usingmalloc()and then
wrapping it withgdk_pixbuf_new_from_data(). Thegdk_pixbuf_new()“
function will compute an optimal rowstride so that rendering can be
performed with an efficient algorithm.
As a special case, you can use the [ctorGdkPixbuf.Pixbuf.new_from_xpm_data”]
function to create a pixbuf from inline XPM image data.
You can also copy an existing pixbuf with the [methodPixbuf.copy]
function. This is not the same as just acquiring a reference to
the old pixbuf instance: the copy function will actually duplicate
the pixel data in memory and create a new [classPixbuf] instance
for it.
Reference counting
GdkPixbuf structures are reference counted. This means that an
application can share a single pixbuf among many parts of the
code. When a piece of the program needs to use a pixbuf, it should
acquire a reference to it by calling g_object_ref(); when it no
longer needs the pixbuf, it should release the reference it acquired
by calling g_object_unref(). The resources associated with a
GdkPixbuf will be freed when its reference count drops to zero.
Newly-created GdkPixbuf instances start with a reference count
of one.
Image Data
Image data in a pixbuf is stored in memory in an uncompressed, packed format. Rows in the image are stored top to bottom, and in each row pixels are stored from left to right.
There may be padding at the end of a row.
The “rowstride” value of a pixbuf, as returned by [methodGdkPixbuf.Pixbuf.get_rowstride``],
indicates the number of bytes between rows.
NOTE: If you are copying raw pixbuf data with memcpy() note that the
last row in the pixbuf may not be as wide as the full rowstride, but rather
just as wide as the pixel data needs to be; that is: it is unsafe to do
memcpy (dest, pixels, rowstride * height) to copy a whole pixbuf. Use
[methodGdkPixbuf.Pixbuf.copy] instead, or compute the width in bytes of the
last row as:
last_row = width * ((n_channels * bits_per_sample + 7) / 8);
The same rule applies when iterating over each row of a GdkPixbuf pixels
array.
The following code illustrates a simple put_pixel()
function for RGB pixbufs with 8 bits per channel with an alpha
channel.
static void
put_pixel (GdkPixbuf *pixbuf,
int x,
int y,
guchar red,
guchar green,
guchar blue,
guchar alpha)
{
int n_channels = gdk_pixbuf_get_n_channels (pixbuf);
// Ensure that the pixbuf is valid
g_assert (gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB);
g_assert (gdk_pixbuf_get_bits_per_sample (pixbuf) == 8);
g_assert (gdk_pixbuf_get_has_alpha (pixbuf));
g_assert (n_channels == 4);
int width = gdk_pixbuf_get_width (pixbuf);
int height = gdk_pixbuf_get_height (pixbuf);
// Ensure that the coordinates are in a valid range
g_assert (x >= 0 && x < width);
g_assert (y >= 0 && y < height);
int rowstride = gdk_pixbuf_get_rowstride (pixbuf);
// The pixel buffer in the GdkPixbuf instance
guchar *pixels = gdk_pixbuf_get_pixels (pixbuf);
// The pixel we wish to modify
guchar *p = pixels + y * rowstride + x * n_channels;
p[0] = red;
p[1] = green;
p[2] = blue;
p[3] = alpha;
}
Loading images
The GdkPixBuf class provides a simple mechanism for loading
an image from a file in synchronous and asynchronous fashion.
For GUI applications, it is recommended to use the asynchronous stream API to avoid blocking the control flow of the application.
Additionally, GdkPixbuf provides the [classGdkPixbuf.PixbufLoader`]
API for progressive image loading.
Saving images
The GdkPixbuf class provides methods for saving image data in
a number of file formats. The formatted data can be written to a
file or to a memory buffer. GdkPixbuf can also call a user-defined
callback on the data, which allows to e.g. write the image
to a socket or store it in a database.
The PixbufProtocol protocol exposes the methods and properties of an underlying GdkPixbuf instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see Pixbuf.
Alternatively, use PixbufRef as a lighweight, unowned reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GdkPixbufinstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
pixbuf_ptrDefault implementationTyped pointer to the underlying
GdkPixbufinstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GdkPixbufinstance.Declaration
Swift
var pixbuf_ptr: UnsafeMutablePointer<GdkPixbuf>! { get } -
Required Initialiser for types conforming to
PixbufProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
PixbufPropertyNamesource property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: PixbufPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocolParameters
source_propertythe source property to bind
targetthe target object to bind to
target_propertythe target property to bind to
flagsthe flags to pass to the
Bindingtransform_fromValueTransformerto use for forward transformationtransform_toValueTransformerto use for backwards transformationReturn Value
binding reference or
nilin case of an error -
get(property:Extension method) Get the value of a Pixbuf property
Declaration
Swift
@inlinable func get(property: PixbufPropertyName) -> GLibObject.ValueParameters
propertythe property to get the value for
Return Value
the value of the named property
-
set(property:Extension methodvalue: ) Set the value of a Pixbuf property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: PixbufPropertyName, value v: GLibObject.Value)Parameters
propertythe property to get the value for
Return Value
the value of the named property
-
addAlpha(substituteColor:Extension methodr: g: b: ) Takes an existing pixbuf and adds an alpha channel to it.
If the existing pixbuf already had an alpha channel, the channel values are copied from the original; otherwise, the alpha channel is initialized to 255 (full opacity).
If
substitute_colorisTRUE, then the color specified by the (r,g,b) arguments will be assigned zero opacity. That is, if you pass(255, 255, 255)for the substitute color, all white pixels will become fully transparent.If
substitute_colorisFALSE, then the (r,g,b) arguments will be ignored.Declaration
Swift
@inlinable func addAlpha(substituteColor: Bool, r: guchar, g: guchar, b: guchar) -> GdkPixBuf.PixbufRef! -
applyEmbeddedOrientation()Extension methodTakes an existing pixbuf and checks for the presence of an associated “orientation” option.
The orientation option may be provided by the JPEG loader (which reads the exif orientation tag) or the TIFF loader (which reads the TIFF orientation tag, and compensates it for the partial transforms performed by libtiff).
If an orientation option/tag is present, the appropriate transform will be performed so that the pixbuf is oriented correctly.
Declaration
Swift
@inlinable func applyEmbeddedOrientation() -> GdkPixBuf.PixbufRef! -
composite(dest:Extension methoddestX: destY: destWidth: destHeight: offsetX: offsetY: scaleX: scaleY: interpType: overallAlpha: ) Creates a transformation of the source image
srcby scaling byscale_xandscale_ythen translating byoffset_xandoffset_y.This gives an image in the coordinates of the destination pixbuf. The rectangle (
dest_x,dest_y,dest_width,dest_height) is then alpha blended onto the corresponding rectangle of the original destination image.When the destination rectangle contains parts not in the source image, the data at the edges of the source image is replicated to infinity.

Declaration
Swift
@inlinable func composite<PixbufT>(dest: PixbufT, destX: Int, destY: Int, destWidth: Int, destHeight: Int, offsetX: CDouble, offsetY: CDouble, scaleX: CDouble, scaleY: CDouble, interpType: GdkInterpType, overallAlpha: Int) where PixbufT : PixbufProtocol -
compositeColor(dest:Extension methoddestX: destY: destWidth: destHeight: offsetX: offsetY: scaleX: scaleY: interpType: overallAlpha: checkX: checkY: checkSize: color1: color2: ) Creates a transformation of the source image
srcby scaling byscale_xandscale_ythen translating byoffset_xandoffset_y, then alpha blends the rectangle (dest_x,dest_y,dest_width,dest_height) of the resulting image with a checkboard of the colorscolor1andcolor2and renders it onto the destination image.If the source image has no alpha channel, and
overall_alphais 255, a fast path is used which omits the alpha blending and just performs the scaling.See
gdk_pixbuf_composite_color_simple()for a simpler variant of this function suitable for many tasks.Declaration
Swift
@inlinable func compositeColor<PixbufT>(dest: PixbufT, destX: Int, destY: Int, destWidth: Int, destHeight: Int, offsetX: CDouble, offsetY: CDouble, scaleX: CDouble, scaleY: CDouble, interpType: GdkInterpType, overallAlpha: Int, checkX: Int, checkY: Int, checkSize: Int, color1: guint32, color2: guint32) where PixbufT : PixbufProtocol -
compositeColorSimple(destWidth:Extension methoddestHeight: interpType: overallAlpha: checkSize: color1: color2: ) Creates a new pixbuf by scaling
srctodest_widthxdest_heightand alpha blending the result with a checkboard of colorscolor1andcolor2.Declaration
Swift
@inlinable func compositeColorSimple(destWidth: Int, destHeight: Int, interpType: GdkInterpType, overallAlpha: Int, checkSize: Int, color1: guint32, color2: guint32) -> GdkPixBuf.PixbufRef! -
copy()Extension methodCreates a new
GdkPixbufwith a copy of the information in the specifiedpixbuf.Note that this does not copy the options set on the original
GdkPixbuf, usegdk_pixbuf_copy_options()for this.Declaration
Swift
@inlinable func copy() -> GdkPixBuf.PixbufRef! -
copyArea(srcX:Extension methodsrcY: width: height: destPixbuf: destX: destY: ) Copies a rectangular area from
src_pixbuftodest_pixbuf.Conversion of pixbuf formats is done automatically.
If the source rectangle overlaps the destination rectangle on the same pixbuf, it will be overwritten during the copy operation. Therefore, you can not use this function to scroll a pixbuf.
Declaration
Swift
@inlinable func copyArea<PixbufT>(srcX: Int, srcY: Int, width: Int, height: Int, destPixbuf: PixbufT, destX: Int, destY: Int) where PixbufT : PixbufProtocol -
copyOptions(destPixbuf:Extension method) Copies the key/value pair options attached to a
GdkPixbufto anotherGdkPixbuf.This is useful to keep original metadata after having manipulated a file. However be careful to remove metadata which you’ve already applied, such as the “orientation” option after rotating the image.
Declaration
Swift
@inlinable func copyOptions<PixbufT>(destPixbuf: PixbufT) -> Bool where PixbufT : PixbufProtocol -
fill(pixel:Extension method) Clears a pixbuf to the given RGBA value, converting the RGBA value into the pixbuf’s pixel format.
The alpha component will be ignored if the pixbuf doesn’t have an alpha channel.
Declaration
Swift
@inlinable func fill(pixel: guint32) -
flip(horizontal:Extension method) Flips a pixbuf horizontally or vertically and returns the result in a new pixbuf.
Declaration
Swift
@inlinable func flip(horizontal: Bool) -> GdkPixBuf.PixbufRef! -
getBitsPerSample()Extension methodQueries the number of bits per color sample in a pixbuf.
Declaration
Swift
@inlinable func getBitsPerSample() -> Int -
getByteLength()Extension methodReturns the length of the pixel data, in bytes.
Declaration
Swift
@inlinable func getByteLength() -> Int -
getColorspace()Extension methodQueries the color space of a pixbuf.
Declaration
Swift
@inlinable func getColorspace() -> GdkColorspace -
getHasAlpha()Extension methodQueries whether a pixbuf has an alpha channel (opacity information).
Declaration
Swift
@inlinable func getHasAlpha() -> Bool -
getHeight()Extension methodQueries the height of a pixbuf.
Declaration
Swift
@inlinable func getHeight() -> Int -
getNChannels()Extension methodQueries the number of channels of a pixbuf.
Declaration
Swift
@inlinable func getNChannels() -> Int -
getOption(key:Extension method) Looks up
keyin the list of options that may have been attached to thepixbufwhen it was loaded, or that may have been attached by another function usinggdk_pixbuf_set_option().For instance, the ANI loader provides “Title” and “Artist” options. The ICO, XBM, and XPM loaders provide “x_hot” and “y_hot” hot-spot options for cursor definitions. The PNG loader provides the tEXt ancillary chunk key/value pairs as options. Since 2.12, the TIFF and JPEG loaders return an “orientation” option string that corresponds to the embedded TIFF/Exif orientation tag (if present). Since 2.32, the TIFF loader sets the “multipage” option string to “yes” when a multi-page TIFF is loaded. Since 2.32 the JPEG and PNG loaders set “x-dpi” and “y-dpi” if the file contains image density information in dots per inch. Since 2.36.6, the JPEG loader sets the “comment” option with the comment EXIF tag.
Declaration
Swift
@inlinable func getOption(key: UnsafePointer<gchar>!) -> String! -
getOptions()Extension methodReturns a
GHashTablewith a list of all the options that may have been attached to thepixbufwhen it was loaded, or that may have been attached by another function using [methodGdkPixbuf.Pixbuf.set_option].Declaration
Swift
@inlinable func getOptions() -> GLib.HashTableRef! -
getPixels()Extension methodQueries a pointer to the pixel data of a pixbuf.
This function will cause an implicit copy of the pixbuf data if the pixbuf was created from read-only data.
Please see the section on image data for information about how the pixel data is stored in memory.
Declaration
Swift
@inlinable func getPixels() -> String! -
getPixelsWith(length:Extension method) Queries a pointer to the pixel data of a pixbuf.
This function will cause an implicit copy of the pixbuf data if the pixbuf was created from read-only data.
Please see the section on image data for information about how the pixel data is stored in memory.
Declaration
Swift
@inlinable func getPixelsWith(length: UnsafeMutablePointer<guint>!) -> String! -
getRowstride()Extension methodQueries the rowstride of a pixbuf, which is the number of bytes between the start of a row and the start of the next row.
Declaration
Swift
@inlinable func getRowstride() -> Int -
getWidth()Extension methodQueries the width of a pixbuf.
Declaration
Swift
@inlinable func getWidth() -> Int -
newSubpixbuf(srcX:Extension methodsrcY: width: height: ) Creates a new pixbuf which represents a sub-region of
src_pixbuf.The new pixbuf shares its pixels with the original pixbuf, so writing to one affects both. The new pixbuf holds a reference to
src_pixbuf, sosrc_pixbufwill not be finalized until the new pixbuf is finalized.Note that if
src_pixbufis read-only, this function will force it to be mutable.Declaration
Swift
@inlinable func newSubpixbuf(srcX: Int, srcY: Int, width: Int, height: Int) -> GdkPixBuf.PixbufRef! -
readPixelBytes()Extension methodProvides a
GBytesbuffer containing the raw pixel data; the data must not be modified.This function allows skipping the implicit copy that must be made if
gdk_pixbuf_get_pixels()is called on a read-only pixbuf.Declaration
Swift
@inlinable func readPixelBytes() -> GLib.BytesRef! -
readPixels()Extension methodProvides a read-only pointer to the raw pixel data.
This function allows skipping the implicit copy that must be made if
gdk_pixbuf_get_pixels()is called on a read-only pixbuf.Declaration
Swift
@inlinable func readPixels() -> UnsafePointer<guint8>! -
ref()Extension methodAdds a reference to a pixbuf.
ref is deprecated: Use g_object_ref().
Declaration
Swift
@available(*, deprecated) @discardableResult @inlinable func ref() -> GdkPixBuf.PixbufRef! -
removeOption(key:Extension method) Removes the key/value pair option attached to a
GdkPixbuf.Declaration
Swift
@inlinable func removeOption(key: UnsafePointer<gchar>!) -> Bool -
rotateSimple(angle:Extension method) Rotates a pixbuf by a multiple of 90 degrees, and returns the result in a new pixbuf.
If
angleis 0, this function will return a copy ofsrc.Declaration
Swift
@inlinable func rotateSimple(angle: GdkPixbufRotation) -> GdkPixBuf.PixbufRef! -
saturateAndPixelate(dest:Extension methodsaturation: pixelate: ) Modifies saturation and optionally pixelates
src, placing the result indest.The
srcanddestpixbufs must have the same image format, size, and rowstride.The
srcanddestarguments may be the same pixbuf with no ill effects.If
saturationis 1.0 then saturation is not changed. If it’s less than 1.0, saturation is reduced (the image turns toward grayscale); if greater than 1.0, saturation is increased (the image gets more vivid colors).If
pixelateisTRUE, then pixels are faded in a checkerboard pattern to create a pixelated image.Declaration
Swift
@inlinable func saturateAndPixelate<PixbufT>(dest: PixbufT, saturation: Double, pixelate: Bool) where PixbufT : PixbufProtocol -
saveToBufferv(buffer:Extension methodbufferSize: type: optionKeys: optionValues: ) Vector version of
gdk_pixbuf_save_to_buffer().Saves pixbuf to a new buffer in format
type, which is currently “jpeg”, “tiff”, “png”, “ico” or “bmp”.See [method
GdkPixbuf.Pixbuf.save_to_buffer] for more details.Declaration
Swift
@inlinable func saveToBufferv(buffer: UnsafeMutablePointer<UnsafeMutablePointer<gchar>?>!, bufferSize: UnsafeMutablePointer<gsize>!, type: UnsafePointer<CChar>!, optionKeys: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>! = nil, optionValues: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>! = nil) throws -> Bool -
saveToCallbackv(saveFunc:Extension methoduserData: type: optionKeys: optionValues: ) Vector version of
gdk_pixbuf_save_to_callback().Saves pixbuf to a callback in format
type, which is currently “jpeg”, “png”, “tiff”, “ico” or “bmp”.If
erroris set,FALSEwill be returned.See [method
GdkPixbuf.Pixbuf.save_to_callback] for more details.Declaration
Swift
@inlinable func saveToCallbackv(saveFunc: GdkPixbufSaveFunc?, userData: gpointer? = nil, type: UnsafePointer<CChar>!, optionKeys: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>! = nil, optionValues: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>! = nil) throws -> Bool -
saveToStreamv(stream:Extension methodtype: optionKeys: optionValues: cancellable: ) Saves
pixbufto an output stream.Supported file formats are currently “jpeg”, “tiff”, “png”, “ico” or “bmp”.
See [method
GdkPixbuf.Pixbuf.save_to_stream] for more details.Declaration
Swift
@inlinable func saveToStreamv<GioOutputStreamT>(stream: GioOutputStreamT, type: UnsafePointer<CChar>!, optionKeys: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>! = nil, optionValues: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>! = nil, cancellable: GIO.CancellableRef? = nil) throws -> Bool where GioOutputStreamT : OutputStreamProtocol -
saveToStreamv(stream:Extension methodtype: optionKeys: optionValues: cancellable: ) Saves
pixbufto an output stream.Supported file formats are currently “jpeg”, “tiff”, “png”, “ico” or “bmp”.
See [method
GdkPixbuf.Pixbuf.save_to_stream] for more details.Declaration
Swift
@inlinable func saveToStreamv<GioCancellableT, GioOutputStreamT>(stream: GioOutputStreamT, type: UnsafePointer<CChar>!, optionKeys: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>! = nil, optionValues: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>! = nil, cancellable: GioCancellableT?) throws -> Bool where GioCancellableT : CancellableProtocol, GioOutputStreamT : OutputStreamProtocol -
saveToStreamvAsync(stream:Extension methodtype: optionKeys: optionValues: cancellable: callback: userData: ) Saves
pixbufto an output stream asynchronously.For more details see
gdk_pixbuf_save_to_streamv(), which is the synchronous version of this function.When the operation is finished,
callbackwill be called in the main thread.You can then call
gdk_pixbuf_save_to_stream_finish()to get the result of the operation.Declaration
Swift
@inlinable func saveToStreamvAsync<GioOutputStreamT>(stream: GioOutputStreamT, type: UnsafePointer<gchar>!, optionKeys: UnsafeMutablePointer<UnsafeMutablePointer<gchar>?>! = nil, optionValues: UnsafeMutablePointer<UnsafeMutablePointer<gchar>?>! = nil, cancellable: GIO.CancellableRef? = nil, callback: GAsyncReadyCallback? = nil, userData: gpointer? = nil) where GioOutputStreamT : OutputStreamProtocol -
saveToStreamvAsync(stream:Extension methodtype: optionKeys: optionValues: cancellable: callback: userData: ) Saves
pixbufto an output stream asynchronously.For more details see
gdk_pixbuf_save_to_streamv(), which is the synchronous version of this function.When the operation is finished,
callbackwill be called in the main thread.You can then call
gdk_pixbuf_save_to_stream_finish()to get the result of the operation.Declaration
Swift
@inlinable func saveToStreamvAsync<GioCancellableT, GioOutputStreamT>(stream: GioOutputStreamT, type: UnsafePointer<gchar>!, optionKeys: UnsafeMutablePointer<UnsafeMutablePointer<gchar>?>! = nil, optionValues: UnsafeMutablePointer<UnsafeMutablePointer<gchar>?>! = nil, cancellable: GioCancellableT?, callback: GAsyncReadyCallback? = nil, userData: gpointer? = nil) where GioCancellableT : CancellableProtocol, GioOutputStreamT : OutputStreamProtocol -
savev(filename:Extension methodtype: optionKeys: optionValues: ) Vector version of
gdk_pixbuf_save().Saves pixbuf to a file in
type, which is currently “jpeg”, “png”, “tiff”, “ico” or “bmp”.If
erroris set,FALSEwill be returned.See [method
GdkPixbuf.Pixbuf.save] for more details.Declaration
Swift
@inlinable func savev(filename: UnsafePointer<CChar>!, type: UnsafePointer<CChar>!, optionKeys: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>! = nil, optionValues: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>! = nil) throws -> Bool -
scale(dest:Extension methoddestX: destY: destWidth: destHeight: offsetX: offsetY: scaleX: scaleY: interpType: ) Creates a transformation of the source image
srcby scaling byscale_xandscale_ythen translating byoffset_xandoffset_y, then renders the rectangle (dest_x,dest_y,dest_width,dest_height) of the resulting image onto the destination image replacing the previous contents.Try to use
gdk_pixbuf_scale_simple()first; this function is the industrial-strength power tool you can fall back to, ifgdk_pixbuf_scale_simple()isn’t powerful enough.If the source rectangle overlaps the destination rectangle on the same pixbuf, it will be overwritten during the scaling which results in rendering artifacts.
Declaration
Swift
@inlinable func scale<PixbufT>(dest: PixbufT, destX: Int, destY: Int, destWidth: Int, destHeight: Int, offsetX: CDouble, offsetY: CDouble, scaleX: CDouble, scaleY: CDouble, interpType: GdkInterpType) where PixbufT : PixbufProtocol -
scaleSimple(destWidth:Extension methoddestHeight: interpType: ) Create a new pixbuf containing a copy of
srcscaled todest_widthxdest_height.This function leaves
srcunaffected.The
interp_typeshould beGDK_INTERP_NEARESTif you want maximum speed (but when scaling downGDK_INTERP_NEARESTis usually unusably ugly). The defaultinterp_typeshould beGDK_INTERP_BILINEARwhich offers reasonable quality and speed.You can scale a sub-portion of
srcby creating a sub-pixbuf pointing intosrc; see [methodGdkPixbuf.Pixbuf.new_subpixbuf].If
dest_widthanddest_heightare equal to the width and height ofsrc, this function will return an unscaled copy ofsrc.For more complicated scaling/alpha blending see [method
GdkPixbuf.Pixbuf.scale] and [methodGdkPixbuf.Pixbuf.composite].Declaration
Swift
@inlinable func scaleSimple(destWidth: Int, destHeight: Int, interpType: GdkInterpType) -> GdkPixBuf.PixbufRef! -
setOption(key:Extension methodvalue: ) Attaches a key/value pair as an option to a
GdkPixbuf.If
keyalready exists in the list of options attached to thepixbuf, the new value is ignored andFALSEis returned.Declaration
Swift
@inlinable func setOption(key: UnsafePointer<gchar>!, value: UnsafePointer<gchar>!) -> Bool -
unref()Extension methodRemoves a reference from a pixbuf.
unref is deprecated: Use g_object_unref().
Declaration
Swift
@available(*, deprecated) @inlinable func unref() -
bitsPerSampleExtension methodQueries the number of bits per color sample in a pixbuf.
Declaration
Swift
@inlinable var bitsPerSample: Int { get } -
byteLengthExtension methodReturns the length of the pixel data, in bytes.
Declaration
Swift
@inlinable var byteLength: Int { get } -
colorspaceExtension methodThe color space of the pixbuf.
Currently, only
GDK_COLORSPACE_RGBis supported.Declaration
Swift
@inlinable var colorspace: GdkColorspace { get } -
hasAlphaExtension methodQueries whether a pixbuf has an alpha channel (opacity information).
Declaration
Swift
@inlinable var hasAlpha: Bool { get } -
heightExtension methodThe number of rows of the pixbuf.
Declaration
Swift
@inlinable var height: Int { get } -
nChannelsExtension methodQueries the number of channels of a pixbuf.
Declaration
Swift
@inlinable var nChannels: Int { get } -
optionsExtension methodReturns a
GHashTablewith a list of all the options that may have been attached to thepixbufwhen it was loaded, or that may have been attached by another function using [methodGdkPixbuf.Pixbuf.set_option].Declaration
Swift
@inlinable var options: GLib.HashTableRef! { get } -
pixelsExtension methodA pointer to the pixel data of the pixbuf.
Declaration
Swift
@inlinable var pixels: String! { get } -
rowstrideExtension methodThe number of bytes between the start of a row and the start of the next row.
This number must (obviously) be at least as large as the width of the pixbuf.
Declaration
Swift
@inlinable var rowstride: Int { get } -
widthExtension methodThe number of columns of the pixbuf.
Declaration
Swift
@inlinable var width: Int { get }
View on GitHub
Install in Dash
PixbufProtocol Protocol Reference