-
-
Notifications
You must be signed in to change notification settings - Fork 328
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
Image rework for soundness and usability #748
Open
cyrgani
wants to merge
26
commits into
not-fl3:master
Choose a base branch
from
cyrgani:image-rework
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains 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
…el argument types from u32 to u16
… examples using images
…ion warnings to fields
@not-fl3 I think this is ready for reviewing now. |
Also fixes #544. |
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
Image
type 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_color
Image::set_image_data
: updates all of the image data given a&[[u8; 4]]
Bugfixes
Image::get_pixel
correctly panics nowImage::blend
andImage::overlay
panic now if the two images have the same amount of pixels, but differentwidth
andheight
Other non-breaking changes
Into
implementations forColor
are nowFrom
implementations (should giveInto
automatically)Image::filled_with_color
/Image::gen_image_color
is 2-3 times faster nowImage::sub_image
is 2 times faster now(done in make all methodsImage::empty
,Image::width
,Image::height
areconst fn
s nowconst
that can beconst
on 1.70.0 #850)Image::gen_image_color
is a deprecated alias ofImage::filled_with_color
nowImage
fields directly gives a deprecation warning and suggests using the methods instead.Planned breaking changes for version 0.5
Image.width
,Image.height
andImage.bytes
privateImage::width
andImage::height
fromusize
tou16
x
andy
inImage::set_pixel
andImage::get_pixel
fromu32
tou16