Skip to content
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

Improve color operations performance #1263

Merged

Conversation

DLiblik
Copy link
Contributor

@DLiblik DLiblik commented Oct 27, 2023

What's Changing and Why

Some functions have operations within loops that don't need to be and/or use floating point math where bitwise operators are faster. Performance is impacted when doing intense operations on large images.

What else might be affected

Nothing. The logic is exactly equivalent.

Tasks

None required - changes are entirely internal.

DLiblik and others added 8 commits October 27, 2023 14:48
Converted to bitwise operators to improve performance at high volumes.
Converted math to bitwise operators to improve performance at high volumes.
Moved any repetitive mathematical operations outside the core loop and simplified accessors to allow for maximum JIT compile optimizations to take place.
Remove redundant calls to Math.round as it is called again within getPixelIndex in both cases.
… number

Added operation to ensure 32-bit color output is interpreted as a positive integer.
Final operation can "re-negate" the value - moved the conversion to unsigned int to be after alpha integration into the value.
Also issues with high-bit values going from int to RGBA - fixed.
@hipstersmoothie hipstersmoothie added the patch Increment the patch version when merged label Feb 23, 2024
@hipstersmoothie hipstersmoothie merged commit 65e3792 into jimp-dev:main Feb 23, 2024
6 of 7 checks passed
Copy link
Contributor

🚀 PR was released in v0.22.12 🚀

@github-actions github-actions bot added the released This issue/pull request has been released. label Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Increment the patch version when merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants