in tjunittest.c [893:943]
static int cmpBitmap(void *buf, int width, int pitch, int height, int pf,
int bottomUp, int gray2rgb)
{
int roffset = tjRedOffset[pf];
int goffset = tjGreenOffset[pf];
int boffset = tjBlueOffset[pf];
int aoffset = tjAlphaOffset[pf];
int ps = tjPixelSize[pf];
int i, j;
for (j = 0; j < height; j++) {
int row = bottomUp ? height - j - 1 : j;
for (i = 0; i < width; i++) {
int r = (i * (maxSample + 1) / width) % (maxSample + 1);
int g = (j * (maxSample + 1) / height) % (maxSample + 1);
int b = (j * (maxSample + 1) / height +
i * (maxSample + 1) / width) % (maxSample + 1);
if (pf == TJPF_GRAY) {
if (getVal(buf, row * pitch + i * ps) != b)
return 0;
} else if (pf == TJPF_CMYK) {
int rf, gf, bf;
cmyk_to_rgb(getVal(buf, row * pitch + i * ps + 0),
getVal(buf, row * pitch + i * ps + 1),
getVal(buf, row * pitch + i * ps + 2),
getVal(buf, row * pitch + i * ps + 3), &rf, &gf, &bf);
if (gray2rgb) {
if (rf != b || gf != b || bf != b)
return 0;
} else if (rf != r || gf != g || bf != b) return 0;
} else {
if (gray2rgb) {
if (getVal(buf, row * pitch + i * ps + roffset) != b ||
getVal(buf, row * pitch + i * ps + goffset) != b ||
getVal(buf, row * pitch + i * ps + boffset) != b)
return 0;
} else if (getVal(buf, row * pitch + i * ps + roffset) != r ||
getVal(buf, row * pitch + i * ps + goffset) != g ||
getVal(buf, row * pitch + i * ps + boffset) != b)
return 0;
if (aoffset >= 0 &&
getVal(buf, row * pitch + i * ps + aoffset) != maxSample)
return 0;
}
}
}
return 1;
}