kornelski / rust-rgb

struct RGB for sharing pixels between crates
https://lib.rs/rgb
MIT License
98 stars 19 forks source link

Add conversions to alt #44

Closed Diegovsky closed 2 years ago

Diegovsky commented 2 years ago

What do you think about alt types implementing From for [T; 4] and other types, like From<RGBA> for ARGB? Loving the crate btw :)

kornelski commented 2 years ago

If conversions between types defined in this crate are missing (like ARGB<>RGBA), then yes — please make a PR for them.

I'm less sure about other types. There are already some functions for converting from slices, which could work with arrays too.

Diegovsky commented 2 years ago

Yes, there are a bunch of ways to convert them and that's great! I proposed theses changes mainly because of something I stumbled upon while using it.

For example, I'm working with a global ARGB format for all my buffers and painting the final result into a BGRA buffer. To solve this, I had to manually write the byte swapping. That's not ideal but it was just 4 lines so it's fine. Since it's a simple I conversion I thought about proposing it.

I'll take a look and then come up with a PR soon :)