image
image copied to clipboard
Usability of FlatSamples
Here is this example:
https://docs.rs/image/latest/image/flat/index.html
It seems that there is a lot of flexibility when using SampleLayout. I can set the number of channels, channel_stride, width, height and stride of both so it should be possible to construct an image from various sources. But for example in the output buffer of cairo surface with format CAIRO_FORMAT_RGB24 (it has channel_stride 1 and width_stride 4) the order of channels is actually BGR and not RGB. Is it possible to accommodate this? Seems huerotate
cannot be used to exchange R and B channels. In FlatSamples there is also color_hint
with description:
"A dynamic image representation could however use this to resolve representational ambiguities such as the order of RGB channels."
Like it should be possible to accommodate for different order of RGB channels but type of color_hint
is ColorType
and not for example ExtendedColorType where this could be theoretically possible by passing ExtendedColorType::Bgr8
.
Also another thing is how to get ImageBuffer
(or something which can be encoded into some supported image format) from view
(View<&[u8], Rgb<u8>>
) in original example without using function thumbnail
?
Not sure about the first part, but I have the same question about the second question. What's the most efficient way to go from FlatSamples to an ImageBuffer or DynamicImage?
For example, if I have a Vec<u8>
in column major format, I can use the same FlatSamples example above to get the proper view. However, trying to figure out the most efficient way to get to ImageBuffer or DynamicImage to save the image with the proper orientation.
Thanks for the help and library.