- if (DEBUGP(pixmap)) {
- int x,y,i;
- fprintf(stderr,"P3\n%d %d\n255\n", RECT_W(portion), RECT_H(portion));
- for (y=portion.tl.y; y<=portion.br.y; y++) {
- for (x=portion.tl.x; x<=portion.br.x; x++) {
- putc(' ',stderr);
- for (i=0; i<3; i++)
- fprintf(stderr," %3d", RI_PIXEL(base,x,y)[i]);
- }
- putc('\n',stderr);
+static int identify(const RgbImage *base, Rect portion,
+ char result[MAXIMGIDENT], const char *what) {
+ return identify1(base,portion,result,what, "master", dbfile_gzopen) ||
+ identify1(base,portion,result,what, "local", dbfile_open);
+}
+
+void fwrite_ppmraw(FILE *f, const RgbImage *ri) {
+ int i;
+ fprintf(f,
+ "P6\n"
+ "%d %d\n"
+ "255\n", ri->w, ri->h);
+ for (i=0; i < ri->w * ri->h; i++) {
+ Rgb rgb= ri->data[i];
+ fputc_unlocked(rgb >> 0, f);
+ fputc_unlocked(rgb >> 8, f);
+ fputc_unlocked(rgb >> 16, f);
+ }
+ 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));
+ for (y=portion.tl.y; y<=portion.br.y; y++) {
+ for (x=portion.tl.x; x<=portion.br.x; x++) {
+ putc(' ',f);
+ Rgb rgb= ri_rgb(base,x,y);
+ for (i=0; i<3; i++)
+ fprintf(f," %3d", (rgb>>(i*8)) & 0xff);