Closed AllenDang closed 2 months ago
I think it makes sense to offer API in slint::Image
to provide access to a SharedPixelBuffer
, if that is easily available. I wonder if the API is perhaps just an implementation of TryFrom<slint::Image> for SharedPixelBuffer<Rgba8Pixel>
, that fails if the image is not trivially convertible.
Another option would be a counter-part to from_rgba8
and friends, such as to_rgba8
that returns an Option
or a Result
.
I'm leaning toward TryFrom
.
Done: https://docs.rs/slint/latest/slint/struct.Image.html#method.to_rgba8 (and similar)
Here is my use case:
image
crate.Image
.arboard
.Currently I use a callback which contains a image type parameter like
callback request_copy_image(image)
, at rust side, the pass in parameter's type isImage
, which has no function to get inner bytes.I could store the bytes in global state to work around now, but I think it will be good to have related functions to get inner data of
Image
.