Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert to and from https://github.com/pornel/rust-rgb structs #74

Closed
tiziano88 opened this issue Aug 17, 2017 · 6 comments
Closed

Comments

@tiziano88
Copy link

No description provided.

@tiziano88
Copy link
Author

@Ogeon
Copy link
Owner

Ogeon commented Aug 18, 2017

Hi! Can you elaborate a bit on what you are suggesting? If it is that Palette types should implement conversion to and from rust-rgb, then I would most likely say no, because it would:

  1. increase the complexity by adding a dependency that will need to be kept up to date,
  2. not provide that much value (unless you have a good use case that I don't know about) since it is a trivial transfer of values.

Palette could, on the other hand, be extended to support simple conversion from &[T] (currently the RgbPixel trait does only support fixed size arrays). That would make them automatically compatible, since rust-rgb can be used as a slice.

@tiziano88
Copy link
Author

Thanks @Ogeon for the quick reply! It seems that rust-rgb is just a "dumb" container (compared to palette which has actual logic going on), and for a bunch of projects I am using rust-rgb as a bridge between different crates (currently doing the trivial conversion in my code), so it would be nice to have a way to do this conversion out of the various crates directly. I don't think the dependency on rust-rgb should be an issue (even if it does change, should be trivial to fix the conversion), anyway if you are uneasy about that, I guess converting from &[T] or from (T, T, T) or [T; 3] (and making sure rust-rgb supports the same), could be a good step forward.

@Ogeon
Copy link
Owner

Ogeon commented Aug 21, 2017

I see. Well, (T, T, T) and [T; 3] works right now, so you may be able to make it more manageable with something like the slice_to_array crate and Rgb::from_pixel. Otherwise you will have to wait for &[T] (which rust-rgb already supports) support to be implemented. I'm not sure rust-rgb itself is ubiquitous enough to be added as a first class conversion target right now. Maybe some future changes will make it easier to use it as a user defined data representation within palette, but that's not yet on the horizon.

@kornelski
Copy link

If you need any support from the rgb crate I'm open to suggestions.

@Ogeon
Copy link
Owner

Ogeon commented Feb 18, 2018

I think the changes in #81 will make this possible without explicitly depending on it. It should only require a couple of simple conversion calls. With the current design it should just be something like Srgb::from_raw(rust_rgb.as_slice()).

bors bot added a commit that referenced this issue Mar 11, 2018
81: Make a new system for converting to and from arrays and slices r=Ogeon a=Ogeon

This should make some interoperability with other systems better, by making it easier to convert buffers and individual pixels to palette colors.

This includes
 * Bit by bit conversion system for colors.
 * `Rgb` works with `u8` and other integer types.
 * `Luma` works with `u8` and other integer types, and can also be non-linear.
 * Implements `AsRef` to convert colors to raw data.
 * A slight improvement to the hue types. No need to explicitly call `.into()` when setting a hue.

Closes #74
bors bot added a commit that referenced this issue Mar 11, 2018
81: Make a new system for converting to and from arrays and slices r=Ogeon a=Ogeon

This should make some interoperability with other systems better, by making it easier to convert buffers and individual pixels to palette colors.

This includes
 * Bit by bit conversion system for colors.
 * `Rgb` works with `u8` and other integer types.
 * `Luma` works with `u8` and other integer types, and can also be non-linear.
 * Implements `AsRef` to convert colors to raw data.
 * A slight improvement to the hue types. No need to explicitly call `.into()` when setting a hue.

Closes #74
@bors bors bot closed this as completed in #81 Mar 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants