-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Merged by Bors] - Expose Image
conversion functions (fixes #5452)
#5527
Conversation
|
Is this still WIP? I see commented code and builds fail. Makes sense I think. There is a few more image formats that can be supported, I've a branch of bevy that adds four more compatible image formats. I'll upload them later and let you copy the code. The idea of exposing the |
Sorry about the messiness, I'm a hobbyist and it's the first time I've ever tried submitting code to a public repo. I tried implementing |
cdff730
to
fd41f5b
Compare
I'll try the changes with some code that would benefit from this change and drop a review tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think once the doc link is fixed, this is good to go.
The API is still very limited due to the limited number of supported formats, but it's a step toward the right direction, and can be improved later on.
@IceSentry is it good to merge now? |
🤔 actually, the old function was pub(crate) so I guess it isn't a breaking change |
Change makes sense to me, and is well-documented and has basic tests. bors r+ |
## Solution Exposes the image <-> "texture" as methods on `Image`. ## Extra I'm wondering if `image_texture_conversion.rs` should be renamed to `image_conversion.rs`. That or the file be deleted altogether in favour of putting the code alongside the rest of the `Image` impl. Its kind-of weird to refer to the `Image` as a texture. Also `Image::convert` is a public method so I didn't want to edit its signature, but it might be nice to have the function consume the image instead of just passing a reference to it because it would eliminate a clone. ## Changelog > Rename `image_to_texture` to `Image::from_dynamic` > Rename `texture_to_image` to `Image::try_into_dynamic` > `Image::try_into_dynamic` now returns a `Result` (this is to make it easier for users who didn't read that only a few conversions are supported to figure it out.)
Pull request successfully merged into main. Build succeeded: |
Image
conversion functions (fixes #5452)Image
conversion functions (fixes #5452)
…ne#5527) ## Solution Exposes the image <-> "texture" as methods on `Image`. ## Extra I'm wondering if `image_texture_conversion.rs` should be renamed to `image_conversion.rs`. That or the file be deleted altogether in favour of putting the code alongside the rest of the `Image` impl. Its kind-of weird to refer to the `Image` as a texture. Also `Image::convert` is a public method so I didn't want to edit its signature, but it might be nice to have the function consume the image instead of just passing a reference to it because it would eliminate a clone. ## Changelog > Rename `image_to_texture` to `Image::from_dynamic` > Rename `texture_to_image` to `Image::try_into_dynamic` > `Image::try_into_dynamic` now returns a `Result` (this is to make it easier for users who didn't read that only a few conversions are supported to figure it out.)
…ne#5527) ## Solution Exposes the image <-> "texture" as methods on `Image`. ## Extra I'm wondering if `image_texture_conversion.rs` should be renamed to `image_conversion.rs`. That or the file be deleted altogether in favour of putting the code alongside the rest of the `Image` impl. Its kind-of weird to refer to the `Image` as a texture. Also `Image::convert` is a public method so I didn't want to edit its signature, but it might be nice to have the function consume the image instead of just passing a reference to it because it would eliminate a clone. ## Changelog > Rename `image_to_texture` to `Image::from_dynamic` > Rename `texture_to_image` to `Image::try_into_dynamic` > `Image::try_into_dynamic` now returns a `Result` (this is to make it easier for users who didn't read that only a few conversions are supported to figure it out.)
Solution
Exposes the image <-> "texture" as methods on
Image
.Extra
I'm wondering if
image_texture_conversion.rs
should be renamed toimage_conversion.rs
. That or the file be deleted altogether in favour of putting the code alongside the rest of theImage
impl. Its kind-of weird to refer to theImage
as a texture.Also
Image::convert
is a public method so I didn't want to edit its signature, but it might be nice to have the function consume the image instead of just passing a reference to it because it would eliminate a clone.Changelog