X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-test.git;a=blobdiff_plain;f=pctb%2Fpages.c;h=d298ac4597cd7096e7f733b65d97228fdc25a52a;hp=a0a52b45e4da60e653a73dc76d67bef6226399de;hb=dac0bb3ca1c725ef968a07bb89fa96ebdc7fb0b9;hpb=fcb77d1400e798c5154251b44aabdecfc37bf839 diff --git a/pctb/pages.c b/pctb/pages.c index a0a52b4..d298ac4 100644 --- a/pctb/pages.c +++ b/pctb/pages.c @@ -497,24 +497,18 @@ static void set_focus_commodity(void) { static CanonImage *convert_page(Snapshot *sn, RgbImage *ri) { CanonImage *im; - fprintf(screenshot_file, - "P6\n" - "%d %d\n" - "255\n", sn->w, sn->h); + fwrite_ppmraw(screenshot_file, sn); + if (ri) memcpy(ri->data, sn->data, ri->h * ri->w * 3); + unsigned char *pixel= sn->data; CANONICALISE_IMAGE(im, sn->w, sn->h, { - int i; - rgb= 0; - for (i=0; i<3; i++) { - rgb <<= 8; - unsigned long sample= RI_PIXEL(sn,x,y)[i]; - rgb |= sample; - fputc(sample, screenshot_file); - } - if (ri) - CANONIMG_ALSO_STORERGB(ri); + rgb= + (pixel[0] << 16) | + (pixel[1] << 8) | + (pixel[2] ); + pixel += 3; }); - + sysassert(!ferror(screenshot_file)); sysassert(!fflush(screenshot_file));