#define OTHERCOORD_x y
#define OTHERCOORD_y x
-const CanonColourInfo canoncolourinfos[]= {
+typedef struct {
+ Rgb rgb; /* on screen */
+ char c; /* canonical */
+} CanonColourInfo;
+
+const CanonColourInfo canoncolourinfo_table[]= {
{ 0x475A5E, '*' }, /* edge */
{ 0x2C5F7A, '*' }, /* edge just under box heading shadow */
{ 0xC5C7AE, '*' }, /* blank area of partial commodities list */
{ 0,0 }
};
+CanonColourInfoReds canoncolourinfo_tree;
+
+void canon_colour_prepare(void) {
+ const CanonColourInfo *cci;
+ for (cci=canoncolourinfo_table; cci->c; cci++) {
+ unsigned char r= cci->rgb >> 16;
+ unsigned char g= cci->rgb >> 8;
+ unsigned char b= cci->rgb;
+
+ CanonColourInfoGreens *greens= canoncolourinfo_tree.red2[r];
+ if (!greens) {
+ greens= canoncolourinfo_tree.red2[r]= mmalloc(sizeof(*greens));
+ FILLZERO(*greens);
+ }
+
+ CanonColourInfoBlues *blues= greens->green2[g];
+ if (!blues) {
+ blues= greens->green2[g]= mmalloc(sizeof(*blues));
+ memset(blues, '?', sizeof(blues));
+ }
+
+ blues->blue2[b]= cci->c;
+ }
+}
+
static void mustfail1(const char *file, int line, const char *what) {
fprintf(stderr,
fatal("PNM screenshot(s) file must be 8bpp 1 byte-per-sample RGB raw");
CANONICALISE_IMAGE(im, inpam.width, inpam.height, {
- int r= fread(&rgb_buf,1,3,f);
+ int rr= fread(&rgb_buf,1,3,f);
sysassert(!ferror(f));
- if (r!=3) fatal("PNM screenshot(s) file ends unexpectedly");
-
- rgb=
- ((unsigned long)rgb_buf[0]<<16) |
- ((unsigned long)rgb_buf[1]<<8) |
- (rgb_buf[2]);
+ if (rr!=3) fatal("PNM screenshot(s) file ends unexpectedly");
+ r= rgb_buf[0];
+ g= rgb_buf[1];
+ b= rgb_buf[2];
});
sysassert(!ferror(screenshot_file));