mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-10-01 18:50:16 +03:00
Implemented the Image::diff() optimization.
- Added exact RGB equality and alpha-only fast paths. - Added optional createDiffImage, defaulting to true. - Updated screenshot comparisons to compare-only first and generate visual output only on failure. - Flattened iteration into a pointer-walking loop. - Added a 256-entry sRGB-to-linear lookup table. - Preserved CIEDE2000, thresholds, alpha comparison, maxDeltaE, and visual rendering semantics. - Added six focused correctness tests in src/tests/unit_tests/image_diff_tests.cpp.
This commit is contained in:
@@ -432,7 +432,7 @@ class EE_API Image {
|
||||
const FormatConfiguration& getImageFormatConfiguration() const;
|
||||
|
||||
struct DiffResult {
|
||||
Image* diffImage{ nullptr }; ///< The visual diff image. Null if dimensions mismatched.
|
||||
Image* diffImage{ nullptr }; ///< Null when visual output was disabled or cannot be created.
|
||||
long long numDifferentPixels{ 0 }; ///< The number of pixels that exceeded the threshold.
|
||||
double maxDeltaE{ 0.0 }; ///< The maximum perceptual difference (Delta E) found.
|
||||
bool areSame() const { return numDifferentPixels == 0; }
|
||||
@@ -450,10 +450,13 @@ class EE_API Image {
|
||||
* A value of 1.0 is roughly the limit of human perception.
|
||||
* A common default for tests is 2.3 (a "just noticeable difference").
|
||||
* @param diffColor The color used to highlight differing pixels in the output image.
|
||||
* @param createDiffImage Whether to create the visual diff image. Disable this for comparisons
|
||||
* that only need statistics.
|
||||
* @return A DiffResult struct containing the diff image and statistics.
|
||||
*/
|
||||
DiffResult diff( const Image& other, float threshold = 2.3f,
|
||||
const Color& diffColor = Color( 255, 0, 255, 255 ) ) const;
|
||||
const Color& diffColor = Color( 255, 0, 255, 255 ),
|
||||
bool createDiffImage = true ) const;
|
||||
|
||||
protected:
|
||||
Uint8* mPixels;
|
||||
|
||||
Reference in New Issue
Block a user