#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 "core/fxcrt/numerics/safe_conversions.h"
#include "testing/image_diff/image_diff_png.h"
#include "testing/utils/path_service.h"
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif
constexpr int kStatusSame = …;
constexpr int kStatusDifferent = …;
constexpr int kStatusError = …;
constexpr uint32_t RGBA_RED = …;
constexpr uint32_t RGBA_ALPHA = …;
class Image { … };
float CalculateDifferencePercentage(const Image& actual, int pixels_different) { … }
void CountImageSizeMismatchAsPixelDifference(const Image& baseline,
const Image& actual,
int* pixels_different) { … }
struct UnpackedPixel { … };
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[]) { … }