dbfile_close();
return !!result[0];
}
-
+
+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);
+ for (i=0; i<3; i++)
+ fprintf(f," %3d", RI_PIXEL(base,x,y)[i]);
+ }
+ putc('\n',f);
+ }
+ sysassert(!ferror(f));
+ sysassert(!fflush(f));
+}
+
void identify_rgbimage(const RgbImage *base, Rect portion,
char result[MAXIMGIDENT], const char *what) {
- int ok= identify(base, portion, result, what);
- if (ok) return;
+ for (;;) {
+ int ok= identify(base, portion, result, what);
+ if (ok) return;
+
+ if (DEBUGP(pixmap))
+ fwrite_ppm(stderr,base,portion);
- 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);
- }
+ FILE *resolver= resolve_start();
+ if (!resolver)
+ fatal("Image recognition failed - unrecognised island.\n"
+ "See FIXME.FIXME\n");
+
+ fprintf(resolver, "pixmap\n" "%s\n", what);
+ fwrite_ppm(resolver, base, portion);
+ putc('\n',resolver);
+
+ resolve_finish();
}
- fatal("Unrecognised pixmap for %s.", what);
}
RgbImage *alloc_rgb_image(int w, int h) {