chiark
/
gitweb
/
~yarrgweb
/
ypp-sc-tools.db-test.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of ijackson@chiark:things/ypp-sc-tools
[ypp-sc-tools.db-test.git]
/
pctb
/
structure.c
diff --git
a/pctb/structure.c
b/pctb/structure.c
index bab3520dae05a4b7b0ff34c2081dd955c638884d..5a21f0cc4a94b8488ebca7892f8dd1a2e2d5c95b 100644
(file)
--- a/
pctb/structure.c
+++ b/
pctb/structure.c
@@
-27,7
+27,7
@@
#include "structure.h"
#include "structure.h"
-static CanonImage *cim;
+static
const
CanonImage *cim;
static inline char get(int x, int y) { return cim->d[y * cim->w + x]; }
static inline char get_p(Point p) { return get(p.x,p.y); }
static inline char get(int x, int y) { return cim->d[y * cim->w + x]; }
static inline char get_p(Point p) { return get(p.x,p.y); }
@@
-93,7
+93,8
@@
static void mustfail1(const char *file, int line, const char *what) {
" Check that your client is logged in has the correct display.\n"
" If that isn't the problem, please report this as a fault.\n\n"
"Technical details:"
" Check that your client is logged in has the correct display.\n"
" If that isn't the problem, please report this as a fault.\n\n"
"Technical details:"
- " %s:%d: requirement failed: %s\n",
+ " %s:%d: requirement failed:\n"
+ " %s\n",
file, line, what);
}
static void mustfail2(void) NORET;
file, line, what);
}
static void mustfail2(void) NORET;
@@
-173,9
+174,9
@@
static void debug_rect(const char *what, int whati, Rect rr) {
LIMIT_MUST( (search).tl.XY != (search).br.XY && \
(search).tl.XY != (lim), \
MR((search));MSB(#TLBR);MSB(#XY) ); \
LIMIT_MUST( (search).tl.XY != (search).br.XY && \
(search).tl.XY != (lim), \
MR((search));MSB(#TLBR);MSB(#XY) ); \
- int got
;
\
- Point p
;
\
- for (p
=(search).tl, got=0;
\
+ int got
=0;
\
+ Point p
=(search).tl;
\
+ for (p
.XY=(search).TLBR.XY;
\
p.OTHERCOORD_##XY <= (search).br.OTHERCOORD_##XY; \
p.OTHERCOORD_##XY++) \
got += !!strchr(insidechrs, get_p(p)); \
p.OTHERCOORD_##XY <= (search).br.OTHERCOORD_##XY; \
p.OTHERCOORD_##XY++) \
got += !!strchr(insidechrs, get_p(p)); \
@@
-184,7
+185,7
@@
static void debug_rect(const char *what, int whati, Rect rr) {
(search).TLBR.XY += increm; \
}
(search).TLBR.XY += increm; \
}
-void find_structure
_commod(
CanonImage *im, int *max_relevant_y_r) {
+void find_structure
(const
CanonImage *im, int *max_relevant_y_r) {
cim= im;
Rect whole = { {0,0}, {cim->w-1,cim->h-1} };
cim= im;
Rect whole = { {0,0}, {cim->w-1,cim->h-1} };
@@
-342,6
+343,7
@@
static void file_read_image_ppm(FILE *f) {
struct pam inpam;
unsigned char rgb_buf[3];
CanonImage *im;
struct pam inpam;
unsigned char rgb_buf[3];
CanonImage *im;
+ RgbImage *ri=0;
pnm_readpaminit(f, &inpam, sizeof(inpam));
if (!(inpam.maxval == 255 &&
pnm_readpaminit(f, &inpam, sizeof(inpam));
if (!(inpam.maxval == 255 &&
@@
-349,6
+351,9
@@
static void file_read_image_ppm(FILE *f) {
inpam.format == RPPM_FORMAT))
fatal("PNM screenshot(s) file must be 8bpp 1 byte per sample RGB");
inpam.format == RPPM_FORMAT))
fatal("PNM screenshot(s) file must be 8bpp 1 byte per sample RGB");
+ if (!npages)
+ page0_rgbimage= ri= alloc_rgb_image(inpam.width, inpam.height);
+
CANONICALISE_IMAGE(im, inpam.width, inpam.height, {
int r= fread(&rgb_buf,1,3,f);
sysassert(!ferror(f));
CANONICALISE_IMAGE(im, inpam.width, inpam.height, {
int r= fread(&rgb_buf,1,3,f);
sysassert(!ferror(f));
@@
-358,6
+363,9
@@
static void file_read_image_ppm(FILE *f) {
((unsigned long)rgb_buf[0]<<16) |
((unsigned long)rgb_buf[1]<<8) |
(rgb_buf[2]);
((unsigned long)rgb_buf[0]<<16) |
((unsigned long)rgb_buf[1]<<8) |
(rgb_buf[2]);
+
+ if (ri)
+ CANONIMG_ALSO_STORERGB(ri);
});
sysassert(!ferror(screenshot_file));
});
sysassert(!ferror(screenshot_file));
@@
-452,7
+460,7
@@
void analyse(FILE *tsv_output) {
int page, tryrect, colno;
for (page=0; page<npages; page++) {
int page, tryrect, colno;
for (page=0; page<npages; page++) {
- find_structure
_commod
(page_images[page], 0);
+ find_structure(page_images[page], 0);
if (!page)
check_correct_commodities();
if (!page)
check_correct_commodities();
@@
-484,32
+492,36
@@
void analyse(FILE *tsv_output) {
}
}
}
}
-#if 0
+//static Rect islandnamer;
-static Rect islandnamer;
-
-void find_structure_islandname(CanonImage *im, RawImage *ri) {
+void find_islandname(void) {
Rect sunshiner;
Rect sunshiner;
+ char sunshine[MAXIMGIDENT];
+ const RgbImage *ri= page0_rgbimage;
+ cim= page_images[0];
+
sunshiner.tl.x= cim->w - 1034 + 885;
sunshiner.br.x= cim->w - 1034 + 1020;
sunshiner.tl.y= 227;
sunshiner.tl.x= cim->w - 1034 + 885;
sunshiner.br.x= cim->w - 1034 + 1020;
sunshiner.tl.y= 227;
- sunshiner.br.y= 22
7
;
+ sunshiner.br.y= 22
8
;
ADJUST_BOX(sunshiner,"o*",30, 100,MUST, tl,y,-1);
ADJUST_BOX(sunshiner,"o*",30, 100,MUST, tl,y,-1);
- ADJUST_BOX(sunshiner,"o*",30, 100,MUST,
tl,y,-
1);
+ ADJUST_BOX(sunshiner,"o*",30, 100,MUST,
br,y,+
1);
debug_rect("sunshiner",0, sunshiner);
debug_rect("sunshiner",0, sunshiner);
- MUST(sunshiner.br.y - sunshiner.tl.y > 20);
- sunshiner.tl.y++;
+ MUST(sunshiner.br.y - sunshiner.tl.y > 20, MR(sunshiner));
sunshiner.br.y--;
ADJUST_BOX(sunshiner,"o",20, (cim->w - 1034 + 700), MUST, tl,x,-1);
sunshiner.br.y--;
ADJUST_BOX(sunshiner,"o",20, (cim->w - 1034 + 700), MUST, tl,x,-1);
- ADJUST_BOX(sunshiner,"o",20, cim->w, MUST,
tl
,x,+1);
+ ADJUST_BOX(sunshiner,"o",20, cim->w, MUST,
br
,x,+1);
debug_rect("sunshiner",1, sunshiner);
debug_rect("sunshiner",1, sunshiner);
- lookup_rect();
+ identify_rgbimage(ri, sunshiner, sunshine, "sunshine widget");
+ fprintf(stderr,"sunshine: `%s'",sunshine);
+#if 0
+
islandnamer.tl.x= cim->w - 1034 + 885;
islandnamer.br.x= cim->w - 1034 + 1020;
islandnamer.tl.x= cim->w - 1034 + 885;
islandnamer.br.x= cim->w - 1034 + 1020;
@@
-536,6
+548,6
@@
void find_structure_islandname(CanonImage *im, RawImage *ri) {
abort();
abort();
-}
#endif
#endif
+}