Image rework for soundness and usability#748
Open
cyrgani wants to merge 28 commits intonot-fl3:masterfrom
Open
Image rework for soundness and usability#748cyrgani wants to merge 28 commits intonot-fl3:masterfrom
cyrgani wants to merge 28 commits intonot-fl3:masterfrom
Conversation
…el argument types from u32 to u16
… examples using images
…ion warnings to fields
Contributor
Author
|
@not-fl3 I think this is ready for reviewing now. |
Contributor
Author
|
Also fixes #544. |
Contributor
Author
|
I'm going to split this into some smaller PRs over the next days to hopefully make it easier to review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is a huge rework of the
Imagetype to fix a soundness issue and other bugs, increase performance and improve ergonomics. It also adds deprecation warnings to prepare users for future breaking changes.Fixes #634.
Fixes #746.
Fixes #637.
Fixes #544.
New methods
Image::from_raw_parts: method for creating an image from width, height and bytes while checking if the amount of bytes is correctImage::bytes,Image::bytes_mut: returns an immutable / mutable slice of all bytes in the imageImage::width_mut,Image::height_mut,Image::bytes_vec_mut: unsafe methods that return a mutable reference to the respective field, allowing for unchecked manipulation (mostly exist to support migration of strange usecases)Image::pixel_amount: returns the amount of pixels this image has according to its dimensionsImage::filled_with_color: creates an image filled with one color, previously calledImage::gen_image_colorImage::set_image_data: updates all of the image data given a&[[u8; 4]]Bugfixes
Image::get_pixelcorrectly panics nowImage::blendandImage::overlaypanic now if the two images have the same amount of pixels, but differentwidthandheightOther non-breaking changes
Some(done in replace allIntoimplementations forColorare nowFromimplementations (should giveIntoautomatically)Intoimplementations withFromimplementations #926)Image::filled_with_color/Image::gen_image_coloris 2-3 times faster nowImage::sub_imageis 2 times faster now(done in make all methodsImage::empty,Image::width,Image::heightareconst fns nowconstthat can beconston 1.70.0 #850)Image::gen_image_coloris a deprecated alias ofImage::filled_with_colornowImagefields directly gives a deprecation warning and suggests using the methods instead.Planned breaking changes for version 0.5
Image.width,Image.heightandImage.bytesprivateImage::widthandImage::heightfromusizetou16xandyinImage::set_pixelandImage::get_pixelfromu32tou16