You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `image` type is a reference to an image. It's defined using the `@image-url("...")` construct.
109
-
The address within the `@image-url` function must be known at compile time.
109
+
The address within the `@image-url` function must be a string literal and the image is resolved at compile time.
110
110
111
111
Slint looks for images in the following places:
112
112
113
113
1. The absolute path or the path relative to the current `.slint` file.
114
114
2. The include path used by the compiler to look up `.slint` files.
115
115
116
+
Loading image from `http` is only supported in [SlintPad](https://slintpad.com).
117
+
116
118
Access an `image`'s dimension using its `width` and `height` properties.
117
119
118
120
```slint
119
121
export component Example inherits Window {
120
122
preferred-width: 150px;
121
123
preferred-height: 50px;
122
124
125
+
// Note: http URL only work on the web version.
123
126
in property <image> some_image: @image-url("https://slint.dev/logo/slint-logo-full-light.svg");
124
127
125
-
Text {
126
-
text: "The image is " + some_image.width + "x" + some_image.height;
128
+
HorizontalLayout {
129
+
Text {
130
+
text: "The image is " + some_image.width + "x" + some_image.height;
131
+
}
132
+
133
+
// Check the size to find out if the image is empty.
134
+
if some_image.width > 0 : Image {
135
+
source: some_image
136
+
}
127
137
}
128
138
}
129
139
```
130
140
131
141
It is also possible to load images supporting [9 slice scaling](https://en.wikipedia.org/wiki/9-slice_scaling) (also called nine patch or border images)
132
142
by adding a `nine-slice(...)` argument. The argument can have either one, two, or four numbers that specifies the size of the edges.
133
143
The numbers are either `top right bottom left` or `vertical horizontal`, or one number for everything
0 commit comments