Package ch.bailu.gtk.gdk
Class Texture
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.gdk.Texture
- All Implemented Interfaces:
PointerInterface
- Direct Known Subclasses:
GLTexture
,MemoryTexture
`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
[class@GdkPixbuf.Pixbuf], 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 [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 thread-safe object.
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 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 [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 thread-safe object.
-
Nested Class Summary
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionasIcon()
Implements interfaceIcon
.Implements interfaceLoadableIcon
.Implements interfacePaintable
.static ClassHandler
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.Methods inherited from class 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
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Constructor Details
-
Texture
-
-
Method Details
-
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.- Parameters:
pixbuf
- a `GdkPixbuf`- Returns:
- 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 and JPEG, 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.- Parameters:
bytes
- a `GBytes` containing the data to load- Returns:
- A newly-created `GdkTexture`
- Throws:
AllocationError
-
newFromFileTexture
Creates a new texture by loading an image from a file.
The file format is detected automatically. The supported formats
are PNG and JPEG, 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.- Parameters:
file
- `GFile` to load- Returns:
- A newly-created `GdkTexture`
- Throws:
AllocationError
-
newFromFilenameTexture
Creates a new texture by loading an image from a file.
The file format is detected automatically. The supported formats
are PNG and JPEG, 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.- Parameters:
path
- the filename to load- Returns:
- A newly-created `GdkTexture`
- Throws:
AllocationError
-
newFromFilenameTexture
Creates a new texture by loading an image from a file.
The file format is detected automatically. The supported formats
are PNG and JPEG, 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.- Parameters:
path
- the filename to load- Returns:
- A newly-created `GdkTexture`
- Throws:
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.- Parameters:
resource_path
- the path of the resource file- Returns:
- 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.- Parameters:
resource_path
- the path of the resource file- Returns:
- A newly-created `GdkTexture`
-
getHeight
public int getHeight()Returns the height of the @texture, in pixels.- Returns:
- the height of the `GdkTexture`
-
getWidth
public int getWidth()Returns the width of @texture, in pixels.- Returns:
- 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.- Parameters:
filename
- the filename to store to- Returns:
- %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.- Parameters:
filename
- the filename to store to- Returns:
- %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.- Returns:
- 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.- Parameters:
filename
- the filename to store to- Returns:
- %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.- Parameters:
filename
- the filename to store to- Returns:
- %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].- Returns:
- a newly allocated `GBytes` containing TIFF data
-
asPaintable
Implements interfacePaintable
. Call this to get access to interface functions.- Returns:
Paintable
-
asIcon
Implements interfaceIcon
. Call this to get access to interface functions.- Returns:
Icon
-
asLoadableIcon
Implements interfaceLoadableIcon
. Call this to get access to interface functions.- Returns:
LoadableIcon
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-