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));