package ocgtk

  1. Overview
  2. Docs
OCaml bindings for GTK 4

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.1-preview2.tar.gz
sha256=4e50fdb5093136a10fc8ffbe388e44cbcb70d52f8afdd48863ec7e22580ff054

doc/ocgtk.gdk/Ocgtk_gdk/Gdk/Wrappers/Texture/index.html

Module Wrappers.Texture

type t = [ `texture | `object_ ] Gobject.obj

Create a new Texture

val new_from_bytes : Glib_bytes.t -> (t, GError.t) result

Create a new Texture

Create a new Texture

val new_from_filename : string -> (t, GError.t) result

Create a new Texture

val new_from_resource : string -> t

Create a new Texture

val save_to_tiff_bytes : t -> Glib_bytes.t

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.

val save_to_tiff : t -> string -> bool

Store the given @texture to the @filename as a TIFF file.

GTK will attempt to store data without loss.

val save_to_png_bytes : t -> Glib_bytes.t

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.

val save_to_png : t -> string -> bool

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.

val get_width : t -> int

Returns the width of @texture, in pixels.

val get_height : t -> int

Returns the height of the @texture, in pixels.

val get_format : t -> Gdk_enums.memoryformat

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.