}
}
- if(!dedup || (tid = matchtile(img, tileoffs, th)) == -1) {
- tmap->map[tileno] = tileno;
- tileoffs += th; /* destination Y offset, inc by th for every tile */
+ if(dedup) {
+ if((tid = matchtile(img, tileoffs, th)) == -1) {
+ if(tmap) {
+ tmap->map[tileno++] = tileoffs / th;
+ }
+ tileoffs += th; /* destination Y offset, inc by th for every tile */
+ } else {
+ if(tmap) {
+ tmap->map[tileno++] = tid;
+ }
+ }
} else {
- tmap->map[tileno] = tid;
+ tileoffs += th; /* destination Y offset, inc by th for every tile */
}
- tileno++;
x += tw;
}
y += th;
}
+ if(dedup) {
+ putchar('\n');
+ img->height = tileoffs;
+ }
+
free(orig.pixels);
return 0;
}
tilesz = img->pitch * th;
pa = (unsigned char*)img->pixels;
- pb = (unsigned char*)img->pixels + toffs * tilesz;
+ pb = (unsigned char*)img->pixels + toffs * img->pitch;
for(i=0; i<ntiles; i++) {
if(memcmp(pa, pb, tilesz) == 0) {