18 {
19 if (argc != 3) {
20 const char usage[] =
"\nUsage:\n %s {FILE1}.png {FILE2}.png\n\n";
22 return 1;
23 }
25 for (
int i = 0;
i < 2; ++
i) {
27 if (std::unique_ptr<SkCodec> codec =
29 bm[
i].
allocN32Pixels(codec->dimensions().fWidth, codec->dimensions().fHeight);
31 continue;
32 }
33 }
34 fprintf(stderr,
"\nBad file: '%s'.\n\n",
path);
35 return 2;
36 }
38 if (dim != bm[1].dimensions()) {
39 fprintf(stderr, "\nImages must be same size: (%d,%d) != (%d,%d)\n\n",
40 dim.
fWidth, dim.
fHeight, bm[1].dimensions().fWidth, bm[1].dimensions().fHeight);
41 return 3;
42 }
43 int64_t totalDiffs = 0;
45 const uint8_t* row1 =
reinterpret_cast<const uint8_t*
>(bm[0].
pixmap().
addr32(0,
y));
46 const uint8_t* row2 =
reinterpret_cast<const uint8_t*
>(bm[1].
pixmap().
addr32(0,
y));
47 for (
size_t i = 0;
i < (size_t)dim.
fWidth * (
size_t)4; ++
i) {
48 totalDiffs +=
std::abs((
int)row1[
i] - (
int)row2[
i]);
49 }
50 }
51 printf(
"%g\n", (
double)totalDiffs /
52 ((uint64_t)255 * 4 * (uint64_t)dim.
fWidth * (uint64_t)dim.
fHeight));
53 return 0;
54}
SkISize dimensions() const
const SkPixmap & pixmap() const
void allocN32Pixels(int width, int height, bool isOpaque=false)
static std::unique_ptr< SkCodec > MakeFromData(sk_sp< SkData >, SkSpan< const SkCodecs::Decoder > decoders, SkPngChunkReader *=nullptr)
static sk_sp< SkData > MakeFromFileName(const char path[])
const uint32_t * addr32() const
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
SIN Vec< N, float > abs(const Vec< N, float > &x)
static void usage(char *argv0)