TextureProtocol
public protocol TextureProtocol : ObjectProtocol, PaintableProtocol
The TextureProtocol protocol exposes the methods and properties of an underlying GdkTexture 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 Texture.
Alternatively, use TextureRef as a lighweight, unowned reference if you already have an instance you just want to use.
GdkTexture is the basic element used to refer to pixel data.
It is primarily meant for pixel data that will not change over multiple frames, and will be used for a long time.
There are various ways to create GdkTexture objects from a
GdkPixbuf, or a Cairo surface, or other pixel data.
The ownership of the pixel data is transferred to the GdkTexture
instance; you can only make a copy of it, via
[methodGdk.Texture.download].
GdkTexture is an immutable object: That means you cannot change
anything about it other than increasing the reference count via
g_object_ref().
-
Untyped pointer to the underlying
GdkTextureinstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
texture_ptrDefault implementationTyped pointer to the underlying
GdkTextureinstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GdkTextureinstance.Declaration
Swift
var texture_ptr: UnsafeMutablePointer<GdkTexture>! { get } -
Required Initialiser for types conforming to
TextureProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
TexturePropertyNamesource property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: TexturePropertyName, 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 Texture property
Declaration
Swift
@inlinable func get(property: TexturePropertyName) -> 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 Texture property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: TexturePropertyName, value v: GLibObject.Value)Parameters
propertythe property to get the value for
Return Value
the value of the named property
-
download(data:Extension methodstride: ) Downloads the
textureinto 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:
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);Declaration
Swift
@inlinable func download(data: UnsafeMutablePointer<guchar>!, stride: Int) -
getHeight()Extension methodReturns the height of the
texture, in pixels.Declaration
Swift
@inlinable func getHeight() -> Int -
getWidth()Extension methodReturns the width of
texture, in pixels.Declaration
Swift
@inlinable func getWidth() -> Int -
saveToPng(filename:Extension method) Store the given
textureto thefilenameas 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
GFileor other location, you might want to look into using the gdk-pixbuf library.Declaration
Swift
@inlinable func saveToPng(filename: UnsafePointer<CChar>!) -> Bool -
pixbufGetFromTexture()Extension methodCreates a new pixbuf from
texture.This should generally not be used in newly written code as later stages will almost certainly convert the pixbuf back into a texture to draw it on screen.
Declaration
Swift
@inlinable func pixbufGetFromTexture() -> PixbufRef! -
heightExtension methodThe height of the texture, in pixels.
Declaration
Swift
@inlinable var height: Int { get } -
widthExtension methodThe width of the texture, in pixels.
Declaration
Swift
@inlinable var width: Int { get }
View on GitHub
Install in Dash
TextureProtocol Protocol Reference