An image file for a Slint image property, made by Ui.image.
Remarks
Opaque: pass it where the Slint type is image, with View.set or
View.bind: the whole value of an image property or, an image
field at any depth, such as the logo of each row of a list. Making the
reference does not read the file: the player checks and decodes it each time
it receives the value (a property write, a window opening; Ui.image
has the rules and limits).
A reference belongs to the Scope that created it. Once that scope
is disposed, writing the reference fails with invalid (reported to
Scope.onError); an image already on screen stays until the
property changes or the view closes.
Example: Show a cover image from the data directory
A window opens showing cover.png, which the plugin saved in its data
directory. ui.image only makes a reference, without reading the file;
the player checks and decodes the file when it receives the value, so a
missing file fails that write with missing (here: show rejects, as
it is an initial property). A missing image nested inside a value is
drawn empty instead.
constcover = plugin.windows.create("ui/cover.slint"); // `art` is an `image` property in ui/cover.slint. cover.set({ art:plugin.ui.image(`${plugin.dataDirectory}/cover.png`) }); awaitcover.show();
Example: Show a logo in each row of a list
Each row of the list draws its own small logo next to its name. An ImageRef
may sit in any field of a property value, so the rows carry their icons;
maxSide: 64 decodes each logo at most 64 px wide, which keeps the view's
image memory small.
An image file for a Slint
imageproperty, made by Ui.image.Remarks
Opaque: pass it where the Slint type is
image, with View.set or View.bind: the whole value of animageproperty or, animagefield at any depth, such as the logo of each row of a list. Making the reference does not read the file: the player checks and decodes it each time it receives the value (a property write, a window opening; Ui.image has the rules and limits).A reference belongs to the Scope that created it. Once that scope is disposed, writing the reference fails with
invalid(reported to Scope.onError); an image already on screen stays until the property changes or the view closes.Example: Show a cover image from the data directory
A window opens showing
cover.png, which the plugin saved in its data directory.ui.imageonly makes a reference, without reading the file; the player checks and decodes the file when it receives the value, so a missing file fails that write withmissing(here:showrejects, as it is an initial property). A missing image nested inside a value is drawn empty instead.Example: Show a logo in each row of a list
Each row of the list draws its own small logo next to its name. An
ImageRefmay sit in any field of a property value, so the rows carry their icons;maxSide: 64decodes each logo at most 64 px wide, which keeps the view's image memory small.See
Ui.image, Example: Markdown
Since
1.0.0