X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=pctb%2Frgbimage.c;h=720e5dce78d398ed7f8fdfc8f1dde353a1532cf4;hb=931cd6cc43566d531b5f87e36effae44566ed4ae;hp=d0ba6b797442ef7e7b5c64f6d6d1f557c0c9cafd;hpb=0487d41d9c7796c6efebb8235c9aa39fe580ccf9;p=ypp-sc-tools.db-test.git diff --git a/pctb/rgbimage.c b/pctb/rgbimage.c index d0ba6b7..720e5dc 100644 --- a/pctb/rgbimage.c +++ b/pctb/rgbimage.c @@ -89,7 +89,9 @@ static int identify1(const RgbImage *base, Rect portion, int c; dbassert( dbfile_scanf("%d",&c) == 1); dbassert(c>=0 && c<=255); - diff |= (c != RI_PIXEL(base, portion.tl.x + x, portion.tl.y + y)[i]); + int px= portion.tl.x + x, py= portion.tl.y + y; + diff |= px > portion.br.x || py > portion.br.y || + (c != RI_PIXEL(base,px,py)[i]); } } } @@ -113,6 +115,17 @@ static int identify(const RgbImage *base, Rect portion, identify1(base,portion,result,what, "local"); } +void fwrite_ppmraw(FILE *f, const RgbImage *ri) { + fprintf(f, + "P6\n" + "%d %d\n" + "255\n", ri->w, ri->h); + int count= ri->w * ri->h * 3; + sysassert( fwrite(ri->data, 1, count, f) == count ); + sysassert(!ferror(f)); + sysassert(!fflush(f)); +} + static void fwrite_ppm(FILE *f, const RgbImage *base, Rect portion) { int x,y,i; fprintf(f,"P3\n%d %d\n255\n", RECT_W(portion), RECT_H(portion));