chiark / gitweb /
Faster, by more in-bulk processing of incoming pixels
[ypp-sc-tools.db-test.git] / pctb / pages.c
index a0a52b45e4da60e653a73dc76d67bef6226399de..d298ac4597cd7096e7f733b65d97228fdc25a52a 100644 (file)
@@ -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));