-
Hey! I'm using let pixels = Rgb::<encoding::Srgb, u8>::from_raw_slice(data);
for pixel in pixels {
let converted: palette::Srgba<f64> = pixel.into_format()
} However, sometimes the images don't come in as let pixels = palette::Packed<palette::rgb::channels::Argb>::from_raw_slice(data);
for pixel in pixels {
let color = palette::rgb::Rgba::<palette::encoding::Srgb, u32>::from(pixel);
}} This yields the error:
Thanks in advance! Also, thanks for this great package. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi, this use case is sadly not fully developed in the currently released version. To explain the error above, you would have to convert to You have a couple of options for how to solve this. One is to use the You could also use the |
Beta Was this translation helpful? Give feedback.
Hi, this use case is sadly not fully developed in the currently released version.
Pixel
, as you have noticed, doesn't change the data. It will only change the type the compiler sees it as.Packed
was added to cover the case where one want to represent a color as the bytes in au32
. It gives you the channel reordering but not the byte array representation. It only works with[u32]
buffers, where a singleu32
is a single pixel. This will be improved in the next version, currently on themaster
branch, as you can see in this example.To explain the error above, you would have to convert to
palette::Srgba<u8>
, notpalette::Srgba<u32>
. The former hasu8
channels while the latter hasu32
channe…