Using raster images with scale factor #8656
-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I have managed to solve this. All you have to do is to provide image with dimensions adjusted for scale factor, and enable image scaling by setting Consider this example: Image {
width: floor(parent.width / 1px) * 1px;
height: floor(parent.height / 1px) * 1px;
image-fit: contain;
source: Boards.render_board(
board,
self.width * ScaleFactor.value,
self.height * ScaleFactor.value,
{ show_rulers: true }
);
} * Here, Then, as far as I understand, slint would scale this image down to fit |
Beta Was this translation helpful? Give feedback.
I have managed to solve this.
All you have to do is to provide image with dimensions adjusted for scale factor, and enable image scaling by setting
image-fit
tofill
,contain
orcover
.Consider this example:
*
ScaleFactor
is global exported by my program, where value is set by rust code to representSLINT_SCALE_FACTOR
Here,
render_board
callback returns an image with dimensions that are greater than element width and height byScaleFactor.value