Skip to content

add a few simple helpers to Image #930

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cyrgani
Copy link
Contributor

@cyrgani cyrgani commented Mar 31, 2025

This PR adds the public helper method pixel_amount, which is simpler than always having to write image.width as usize * image.height as usize.
It also adds the private helper assert_same_size to avoid repeating the following larger assertion several times:

assert!(
    self.width as usize * self.height as usize
        == other.width as usize * other.height as usize
);

Both helpers are used in the other Image methods when possible.
Part of #748.

@cyrgani cyrgani force-pushed the simple-image-helpers branch from 2f10fa5 to d4d48b3 Compare March 31, 2025 11:30
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

Successfully merging this pull request may close these issues.

1 participant