Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve color operations performance (#1263)
* Update phash.js - improve intToRGBA performance Converted to bitwise operators to improve performance at high volumes. * Update index.js - Improve performance of rgbaToInt Converted math to bitwise operators to improve performance at high volumes. * Update index.js - Improve performance of hasAlpha Moved any repetitive mathematical operations outside the core loop and simplified accessors to allow for maximum JIT compile optimizations to take place. * Update index.js - Improve performance of get/setPixelColor Remove redundant calls to Math.round as it is called again within getPixelIndex in both cases. * Update index.js - Fix high bit on color conversion can cause negative number Added operation to ensure 32-bit color output is interpreted as a positive integer. * Update index.js - Fix negative color value (again) Final operation can "re-negate" the value - moved the conversion to unsigned int to be after alpha integration into the value. * Update phash.js - fixed negatives the other way Also issues with high-bit values going from int to RGBA - fixed. * force build --------- Co-authored-by: Andrew Lisowski <[email protected]>
- Loading branch information