Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
image_diff.cpp File Reference

(3dce9b5818576f04ce21cec4b3686eda012e5b65)

#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <vector>
#include "core/fxcrt/fx_memory.h"
#include "testing/image_diff/image_diff_png.h"
#include "testing/utils/path_service.h"
#include "third_party/base/numerics/safe_conversions.h"
+ Include dependency graph for image_diff.cpp:

Go to the source code of this file.

Classes

class  Image
 
struct  UnpackedPixel
 

Functions

float CalculateDifferencePercentage (const Image &actual, int pixels_different)
 
void CountImageSizeMismatchAsPixelDifference (const Image &baseline, const Image &actual, int *pixels_different)
 
uint8_t ChannelDelta (uint8_t baseline_channel, uint8_t actual_channel)
 
uint8_t MaxPixelPerChannelDelta (const UnpackedPixel &baseline_pixel, const UnpackedPixel &actual_pixel)
 
float PercentageDifferent (const Image &baseline, const Image &actual, uint8_t max_pixel_per_channel_delta)
 
float HistogramPercentageDifferent (const Image &baseline, const Image &actual)
 
void PrintHelp (const std::string &binary_name)
 
int CompareImages (const std::string &binary_name, const std::string &file1, const std::string &file2, bool compare_histograms, bool reverse_byte_order, uint8_t max_pixel_per_channel_delta)
 
bool CreateImageDiff (const Image &image1, const Image &image2, Image *out)
 
bool SubtractImages (const Image &image1, const Image &image2, Image *out)
 
int DiffImages (const std::string &binary_name, const std::string &file1, const std::string &file2, const std::string &out_file, bool do_subtraction, bool reverse_byte_order)
 
int main (int argc, const char *argv[])
 

Variables

constexpr int kStatusSame = 0
 
constexpr int kStatusDifferent = 1
 
constexpr int kStatusError = 2
 
constexpr uint32_t RGBA_RED = 0x000000ff
 
constexpr uint32_t RGBA_ALPHA = 0xff000000
 

Function Documentation

◆ CalculateDifferencePercentage()

float CalculateDifferencePercentage ( const Image & actual,
int pixels_different )

Definition at line 119 of file image_diff.cpp.

References Image::h(), and Image::w().

Referenced by HistogramPercentageDifferent(), and PercentageDifferent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ChannelDelta()

uint8_t ChannelDelta ( uint8_t baseline_channel,
uint8_t actual_channel )

Definition at line 159 of file image_diff.cpp.

Referenced by MaxPixelPerChannelDelta().

+ Here is the caller graph for this function:

◆ CompareImages()

int CompareImages ( const std::string & binary_name,
const std::string & file1,
const std::string & file2,
bool compare_histograms,
bool reverse_byte_order,
uint8_t max_pixel_per_channel_delta )

Definition at line 258 of file image_diff.cpp.

References Image::CreateFromFilename(), Image::CreateFromFilenameWithReverseByteOrder(), HistogramPercentageDifferent(), kStatusDifferent, kStatusError, kStatusSame, and PercentageDifferent().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CountImageSizeMismatchAsPixelDifference()

void CountImageSizeMismatchAsPixelDifference ( const Image & baseline,
const Image & actual,
int * pixels_different )

Definition at line 131 of file image_diff.cpp.

References Image::h(), and Image::w().

Referenced by HistogramPercentageDifferent(), and PercentageDifferent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreateImageDiff()

bool CreateImageDiff ( const Image & image1,
const Image & image2,
Image * out )

Definition at line 303 of file image_diff.cpp.

References Image::Image(), Image::h(), Image::operator=(), Image::pixel_at(), RGBA_ALPHA, RGBA_RED, Image::set_pixel_at(), and Image::w().

Referenced by DiffImages().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DiffImages()

int DiffImages ( const std::string & binary_name,
const std::string & file1,
const std::string & file2,
const std::string & out_file,
bool do_subtraction,
bool reverse_byte_order )

Definition at line 367 of file image_diff.cpp.

References Image::CreateFromFilename(), Image::CreateFromFilenameWithReverseByteOrder(), CreateImageDiff(), kStatusDifferent, kStatusError, kStatusSame, and SubtractImages().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HistogramPercentageDifferent()

float HistogramPercentageDifferent ( const Image & baseline,
const Image & actual )

Definition at line 201 of file image_diff.cpp.

References CalculateDifferencePercentage(), CountImageSizeMismatchAsPixelDifference(), Image::h(), Image::pixel_at(), and Image::w().

Referenced by CompareImages().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ main()

int main ( int argc,
const char * argv[] )

Definition at line 416 of file image_diff.cpp.

References CompareImages(), DiffImages(), FX_InitializeMemoryAllocators(), kStatusError, and PrintHelp().

+ Here is the call graph for this function:

◆ MaxPixelPerChannelDelta()

uint8_t MaxPixelPerChannelDelta ( const UnpackedPixel & baseline_pixel,
const UnpackedPixel & actual_pixel )

Definition at line 165 of file image_diff.cpp.

References UnpackedPixel::alpha, UnpackedPixel::blue, ChannelDelta(), UnpackedPixel::green, and UnpackedPixel::red.

Referenced by PercentageDifferent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PercentageDifferent()

float PercentageDifferent ( const Image & baseline,
const Image & actual,
uint8_t max_pixel_per_channel_delta )

Definition at line 173 of file image_diff.cpp.

References UnpackedPixel::UnpackedPixel(), CalculateDifferencePercentage(), CountImageSizeMismatchAsPixelDifference(), Image::h(), MaxPixelPerChannelDelta(), Image::pixel_at(), and Image::w().

Referenced by CompareImages().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PrintHelp()

void PrintHelp ( const std::string & binary_name)

Definition at line 235 of file image_diff.cpp.

Referenced by main().

+ Here is the caller graph for this function:

◆ SubtractImages()

bool SubtractImages ( const Image & image1,
const Image & image2,
Image * out )

Definition at line 330 of file image_diff.cpp.

References Image::Image(), Image::h(), Image::pixel_at(), RGBA_ALPHA, Image::set_pixel_at(), and Image::w().

Referenced by DiffImages().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ kStatusDifferent

int kStatusDifferent = 1
constexpr

Definition at line 32 of file image_diff.cpp.

Referenced by CompareImages(), and DiffImages().

◆ kStatusError

int kStatusError = 2
constexpr

Definition at line 33 of file image_diff.cpp.

Referenced by CompareImages(), DiffImages(), and main().

◆ kStatusSame

int kStatusSame = 0
constexpr

Definition at line 31 of file image_diff.cpp.

Referenced by CompareImages(), and DiffImages().

◆ RGBA_ALPHA

uint32_t RGBA_ALPHA = 0xff000000
constexpr

Definition at line 37 of file image_diff.cpp.

Referenced by CreateImageDiff(), and SubtractImages().

◆ RGBA_RED

uint32_t RGBA_RED = 0x000000ff
constexpr

Definition at line 36 of file image_diff.cpp.

Referenced by CreateImageDiff().