Skip to content

Commit

Permalink
mksprite: add mipmap generation for I4/I8
Browse files Browse the repository at this point in the history
  • Loading branch information
rasky committed Jun 5, 2023
1 parent c33adbd commit e4c88e6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tools/mksprite/mksprite.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,18 @@ void spritemaker_calc_lods(spritemaker_t *spr, int algo) {
}
}
break;
case LCT_GREY:
mipmap = malloc(mw * mh);
for (int y=0;y<mh;y++) {
uint8_t *src1 = prev->image + y*prev->width*2;
uint8_t *src2 = src1 + prev->width;
uint8_t *dst = mipmap + y*mw;
for (int x=0;x<mw;x++) {
dst[0] = (src1[0] + src1[1] + src2[0] + src2[1]) / 4;
dst += 1; src1 += 2; src2 += 2;
}
}
break;
default:
fprintf(stderr, "WARNING: mipmap calculation for format %s not implemented yet", tex_format_name(spr->outfmt));
done = true;
Expand Down

0 comments on commit e4c88e6

Please sign in to comment.