-
Notifications
You must be signed in to change notification settings - Fork 629
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
Feature: methods for getting a pixel using signed coordinates #1851
Open
rostyq
wants to merge
7
commits into
image-rs:main
Choose a base branch
from
rostyq:master
base: main
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
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
42aa9ac
methods for getting pixel using signed coordinates
rostyq 61d4bbe
clean up imports after previous commit :\
rostyq 0b34934
use min max approach for saturating get pixel
rostyq 15c1cd2
rm redundant negative check for checked get pixel
rostyq ceabbde
Merge branch 'image-rs:master' into master
rostyq be20130
fix flat bounds method
rostyq 983deea
Merge branch 'master' of https://github.com/image-rs/image
rostyq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
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.
They are not. Panic in those cases would be permissible behavior but maybe it's not desirable. The methodical evaluation of how we wrote the trait is, however:
Note that
in_bounds
is both safe, and the trait itself is safe. Thus, we can't make any assumption about its implementation other than the method signature. Since we haven't called the method here either, we can not argue to have fulfilled the precondition properly. I don't think this method possible in a generic, sound manner either way.However, we can add specialized implementations of these two new methods for
ImageBuffer
. Since thein_bounds
method is local, we can use its implementation details and rely on them being correct.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.
This is similar to
get_pixel_unchecked
. Note that the generic implementation provided by the trait does not in fact call any unsafe method, it defaults to a purely safe fallback. This is correct and intended; since there's nothingunsafe
about the trait, the implementor has no obligations to 'do the right thing'. There's no inherent property ofin_bounds
that the generic implementation could rely on for any effect; so calling the safe fallback is indeed the best useful implementation we can provide.Note to self:
ImageBuffer
is still dubious if the user chooses a non-default container. Damn.