Package ch.bailu.gtk.gdk
Klasse Texture
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.type.PropertyHolder
ch.bailu.gtk.gdk.Texture
- Alle implementierten Schnittstellen:
PointerInterface
- Bekannte direkte Unterklassen:
DmabufTexture
,GLTexture
,MemoryTexture
Refers to pixel data in various forms.
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
[class@GdkPixbuf.Pixbuf], or from bytes stored in memory, a file, or a
[struct@Gio.Resource].
The ownership of the pixel data is transferred to the `GdkTexture`
instance; you can only make a copy of it, via [method@Gdk.Texture.download].
`GdkTexture` is an immutable object: That means you cannot change
anything about it other than increasing the reference count via
[method@GObject.Object.ref], and consequently, it is a threadsafe object.
GDK provides a number of threadsafe texture loading functions:
[ctor@Gdk.Texture.new_from_resource],
[ctor@Gdk.Texture.new_from_bytes],
[ctor@Gdk.Texture.new_from_file],
[ctor@Gdk.Texture.new_from_filename],
[ctor@Gdk.Texture.new_for_pixbuf]. Note that these are meant for loading
icons and resources that are shipped with the toolkit or application. It
is recommended that you use a dedicated image loading framework such as
[glycin](https://lib.rs/crates/glycin), if you need to load untrusted image
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
[class@GdkPixbuf.Pixbuf], or from bytes stored in memory, a file, or a
[struct@Gio.Resource].
The ownership of the pixel data is transferred to the `GdkTexture`
instance; you can only make a copy of it, via [method@Gdk.Texture.download].
`GdkTexture` is an immutable object: That means you cannot change
anything about it other than increasing the reference count via
[method@GObject.Object.ref], and consequently, it is a threadsafe object.
GDK provides a number of threadsafe texture loading functions:
[ctor@Gdk.Texture.new_from_resource],
[ctor@Gdk.Texture.new_from_bytes],
[ctor@Gdk.Texture.new_from_file],
[ctor@Gdk.Texture.new_from_filename],
[ctor@Gdk.Texture.new_for_pixbuf]. Note that these are meant for loading
icons and resources that are shipped with the toolkit or application. It
is recommended that you use a dedicated image loading framework such as
[glycin](https://lib.rs/crates/glycin), if you need to load untrusted image
data.
-
Verschachtelte Klassen - Übersicht
Von Klasse geerbte verschachtelte Klassen/Schnittstellen ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Feldübersicht
Von Klasse geerbte Felder ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungasIcon()
Implements interfaceIcon
.Implements interfaceLoadableIcon
.Implements interfacePaintable
.static ClassHandler
Returns the color state associated with the texture.int
Gets the memory format most closely associated with the data of
the texture.int
Returns the height of the @texture, in pixels.static int
static long
static TypeSystem.TypeSize
static long
static TypeSystem.TypeSize
int
getWidth()
Returns the width of @texture, in pixels.static Texture
newForPixbufTexture
(Pixbuf pixbuf) Creates a new texture object representing the `GdkPixbuf`.static Texture
newFromBytesTexture
(Bytes bytes) Creates a new texture by loading an image from memory,
The file format is detected automatically.static Texture
newFromFilenameTexture
(Str path) Creates a new texture by loading an image from a file.static Texture
newFromFilenameTexture
(String path) Creates a new texture by loading an image from a file.static Texture
newFromFileTexture
(File file) Creates a new texture by loading an image from a file.static Texture
newFromResourceTexture
(Str resource_path) Creates a new texture by loading an image from a resource.static Texture
newFromResourceTexture
(String resource_path) Creates a new texture by loading an image from a resource.boolean
Store the given @texture to the @filename as a PNG file.boolean
Store the given @texture to the @filename as a PNG file.Store the given @texture in memory as a PNG file.boolean
saveToTiff
(Str filename) Store the given @texture to the @filename as a TIFF file.boolean
saveToTiff
(String filename) Store the given @texture to the @filename as a TIFF file.Store the given @texture in memory as a TIFF file.Von Klasse geerbte Methoden ch.bailu.gtk.type.PropertyHolder
getBooleanProperty, getIntProperty, getObjectProperty, getStringProperty, getStrProperty, setBooleanProperty, setIntProperty, setObjectProperty, setStringProperty, setStrProperty
Von Klasse geerbte Methoden ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Von Klasse geerbte Methoden ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Von Klasse geerbte Methoden ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Von Klasse geerbte Methoden java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Von Schnittstelle geerbte Methoden ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Konstruktordetails
-
Texture
-
-
Methodendetails
-
getClassHandler
-
newForPixbufTexture
Creates a new texture object representing the `GdkPixbuf`.
This function is threadsafe, so that you can e.g. use GTask
and [method@Gio.Task.run_in_thread] to avoid blocking the main thread
while loading a big image.- Parameter:
pixbuf
- a `GdkPixbuf`- Gibt zurück:
- a new `GdkTexture`
-
newFromBytesTexture
Creates a new texture by loading an image from memory,
The file format is detected automatically. The supported formats
are PNG, JPEG and TIFF, though more formats might be available.
If %NULL is returned, then @error will be set.
This function is threadsafe, so that you can e.g. use GTask
and [method@Gio.Task.run_in_thread] to avoid blocking the main thread
while loading a big image.- Parameter:
bytes
- a `GBytes` containing the data to load- Gibt zurück:
- A newly-created `GdkTexture`
- Löst aus:
AllocationError
-
newFromFileTexture
Creates a new texture by loading an image from a file.
The file format is detected automatically. The supported formats
are PNG, JPEG and TIFF, though more formats might be available.
If %NULL is returned, then @error will be set.
This function is threadsafe, so that you can e.g. use GTask
and [method@Gio.Task.run_in_thread] to avoid blocking the main thread
while loading a big image.- Parameter:
file
- `GFile` to load- Gibt zurück:
- A newly-created `GdkTexture`
- Löst aus:
AllocationError
-
newFromFilenameTexture
Creates a new texture by loading an image from a file.
The file format is detected automatically. The supported formats
are PNG, JPEG and TIFF, though more formats might be available.
If %NULL is returned, then @error will be set.
This function is threadsafe, so that you can e.g. use GTask
and [method@Gio.Task.run_in_thread] to avoid blocking the main thread
while loading a big image.- Parameter:
path
- the filename to load- Gibt zurück:
- A newly-created `GdkTexture`
- Löst aus:
AllocationError
-
newFromFilenameTexture
Creates a new texture by loading an image from a file.
The file format is detected automatically. The supported formats
are PNG, JPEG and TIFF, though more formats might be available.
If %NULL is returned, then @error will be set.
This function is threadsafe, so that you can e.g. use GTask
and [method@Gio.Task.run_in_thread] to avoid blocking the main thread
while loading a big image.- Parameter:
path
- the filename to load- Gibt zurück:
- A newly-created `GdkTexture`
- Löst aus:
AllocationError
-
newFromResourceTexture
Creates a new texture by loading an image from a resource.
The file format is detected automatically. The supported formats
are PNG and JPEG, though more formats might be available.
It is a fatal error if @resource_path does not specify a valid
image resource and the program will abort if that happens.
If you are unsure about the validity of a resource, use
[ctor@Gdk.Texture.new_from_file] to load it.
This function is threadsafe, so that you can e.g. use GTask
and [method@Gio.Task.run_in_thread] to avoid blocking the main thread
while loading a big image.- Parameter:
resource_path
- the path of the resource file- Gibt zurück:
- A newly-created `GdkTexture`
-
newFromResourceTexture
Creates a new texture by loading an image from a resource.
The file format is detected automatically. The supported formats
are PNG and JPEG, though more formats might be available.
It is a fatal error if @resource_path does not specify a valid
image resource and the program will abort if that happens.
If you are unsure about the validity of a resource, use
[ctor@Gdk.Texture.new_from_file] to load it.
This function is threadsafe, so that you can e.g. use GTask
and [method@Gio.Task.run_in_thread] to avoid blocking the main thread
while loading a big image.- Parameter:
resource_path
- the path of the resource file- Gibt zurück:
- A newly-created `GdkTexture`
-
getColorState
Returns the color state associated with the texture.- Gibt zurück:
- the color state of the `GdkTexture`
-
getFormat
public int getFormat()Gets the memory format most closely associated with the data of
the texture.
Note that it may not be an exact match for texture data
stored on the GPU or with compression.
The format can give an indication about the bit depth and opacity
of the texture and is useful to determine the best format for
downloading the texture.- Gibt zurück:
- the preferred format for the texture's data
-
getHeight
public int getHeight()Returns the height of the @texture, in pixels.- Gibt zurück:
- the height of the `GdkTexture`
-
getWidth
public int getWidth()Returns the width of @texture, in pixels.- Gibt zurück:
- the width of the `GdkTexture`
-
saveToPng
Store the given @texture to the @filename as 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 [iface@Gio.File] or other location, you might want to
use [method@Gdk.Texture.save_to_png_bytes] or look into the
gdk-pixbuf library.- Parameter:
filename
- the filename to store to- Gibt zurück:
- %TRUE if saving succeeded, %FALSE on failure.
-
saveToPng
Store the given @texture to the @filename as 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 [iface@Gio.File] or other location, you might want to
use [method@Gdk.Texture.save_to_png_bytes] or look into the
gdk-pixbuf library.- Parameter:
filename
- the filename to store to- Gibt zurück:
- %TRUE if saving succeeded, %FALSE on failure.
-
saveToPngBytes
Store the given @texture in memory as a PNG file.
Use [ctor@Gdk.Texture.new_from_bytes] to read it back.
If you want to serialize a texture, this is a convenient and
portable way to do that.
If you need more control over the generated image, such as
attaching metadata, you should look into an image handling
library such as the gdk-pixbuf library.
If you are dealing with high dynamic range float data, you
might also want to consider [method@Gdk.Texture.save_to_tiff_bytes]
instead.- Gibt zurück:
- a newly allocated `GBytes` containing PNG data
-
saveToTiff
Store the given @texture to the @filename as a TIFF file.
GTK will attempt to store data without loss.- Parameter:
filename
- the filename to store to- Gibt zurück:
- %TRUE if saving succeeded, %FALSE on failure.
-
saveToTiff
Store the given @texture to the @filename as a TIFF file.
GTK will attempt to store data without loss.- Parameter:
filename
- the filename to store to- Gibt zurück:
- %TRUE if saving succeeded, %FALSE on failure.
-
saveToTiffBytes
Store the given @texture in memory as a TIFF file.
Use [ctor@Gdk.Texture.new_from_bytes] to read it back.
This function is intended to store a representation of the
texture's data that is as accurate as possible. This is
particularly relevant when working with high dynamic range
images and floating-point texture data.
If that is not your concern and you are interested in a
smaller size and a more portable format, you might want to
use [method@Gdk.Texture.save_to_png_bytes].- Gibt zurück:
- a newly allocated `GBytes` containing TIFF data
-
asPaintable
Implements interfacePaintable
. Call this to get access to interface functions.- Gibt zurück:
Paintable
-
asIcon
Implements interfaceIcon
. Call this to get access to interface functions.- Gibt zurück:
Icon
-
asLoadableIcon
Implements interfaceLoadableIcon
. Call this to get access to interface functions.- Gibt zurück:
LoadableIcon
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-