chiark
/
gitweb
/
~yarrgweb
/
ypp-sc-tools.web-live.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Recompress the tsv (and err make it work again??)
[ypp-sc-tools.web-live.git]
/
pctb
/
rgbimage.c
diff --git
a/pctb/rgbimage.c
b/pctb/rgbimage.c
index 81eddf9898e83427a83f7376bef93868e8a4dc56..dc9fa68996069fbc3518b5d445f6b1766622cf20 100644
(file)
--- a/
pctb/rgbimage.c
+++ b/
pctb/rgbimage.c
@@
-85,14
+85,16
@@
static int identify1(const RgbImage *base, Rect portion,
int x,y,i;
for (y=0; y<h; y++) {
for (x=0; x<w; x++) {
int x,y,i;
for (y=0; y<h; y++) {
for (x=0; x<w; x++) {
+ uint32_t rgb=0;
for (i=0; i<3; i++) {
int c;
dbassert( dbfile_scanf("%d",&c) == 1);
dbassert(c>=0 && c<=255);
for (i=0; i<3; i++) {
int c;
dbassert( dbfile_scanf("%d",&c) == 1);
dbassert(c>=0 && c<=255);
- int px= portion.tl.x + x, py= portion.tl.y + y;
- diff |= px > portion.br.x || py > portion.br.y ||
- (c != RI_PIXEL(base,px,py)[i]);
+ rgb |= (Rgb)c << (i*8);
}
}
+ int px= portion.tl.x + x, py= portion.tl.y + y;
+ diff |= px > portion.br.x || py > portion.br.y ||
+ rgb != ri_rgb(base,px,py);
}
}
if (!diff) {
}
}
if (!diff) {
@@
-116,12
+118,17
@@
static int identify(const RgbImage *base, Rect portion,
}
void fwrite_ppmraw(FILE *f, const RgbImage *ri) {
}
void fwrite_ppmraw(FILE *f, const RgbImage *ri) {
+ int i;
fprintf(f,
"P6\n"
"%d %d\n"
"255\n", ri->w, ri->h);
fprintf(f,
"P6\n"
"%d %d\n"
"255\n", ri->w, ri->h);
- int count= ri->w * ri->h * 3;
- sysassert( fwrite(ri->data, 1, count, f) == count );
+ 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));
}
sysassert(!ferror(f));
sysassert(!fflush(f));
}
@@
-132,8
+139,9
@@
static void fwrite_ppm(FILE *f, const RgbImage *base, Rect portion) {
for (y=portion.tl.y; y<=portion.br.y; y++) {
for (x=portion.tl.x; x<=portion.br.x; x++) {
putc(' ',f);
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++)
for (i=0; i<3; i++)
- fprintf(f," %3d",
RI_PIXEL(base,x,y)[i]
);
+ fprintf(f," %3d",
(rgb>>(i*8)) & 0xff
);
}
putc('\n',f);
}
}
putc('\n',f);
}
@@
-173,7
+181,7
@@
void identify_rgbimage(const RgbImage *base, Rect portion,
RgbImage *alloc_rgb_image(int w, int h) {
RgbImage *ri;
RgbImage *alloc_rgb_image(int w, int h) {
RgbImage *ri;
- ri= mmalloc(sizeof(*ri) + w*h*
3
);
+ ri= mmalloc(sizeof(*ri) + w*h*
sizeof(ri->data[0])
);
ri->w= w;
ri->h= h;
return ri;
ri->w= w;
ri->h= h;
return ri;