Add an option to omit the mipmap from extracted textures.

This is at the request of Spirit (quaddicted). Great idea.
This commit is contained in:
Bill Currie 2011-10-05 20:43:40 +09:00
parent 940476dce1
commit 6b62b850a7
2 changed files with 28 additions and 17 deletions

View file

@ -74,6 +74,7 @@ static const struct option long_options[] = {
{"pad", no_argument, 0, 'p'}, {"pad", no_argument, 0, 'p'},
{"quiet", no_argument, 0, 'q'}, {"quiet", no_argument, 0, 'q'},
{"verbose", no_argument, 0, 'v'}, {"verbose", no_argument, 0, 'v'},
{"nomip", no_argument, 0, 256},
{NULL, 0, NULL, 0}, {NULL, 0, NULL, 0},
}; };
@ -94,6 +95,7 @@ usage (int status)
printf ("Options:\n" printf ("Options:\n"
" -f, --file ARCHIVE Use ARCHIVE for archive filename\n" " -f, --file ARCHIVE Use ARCHIVE for archive filename\n"
" -p, --pad Pad file space to a 32-bit boundary\n" " -p, --pad Pad file space to a 32-bit boundary\n"
" --nomip Do not output mipmaps with textures\n"
" -q, --quiet Inhibit usual output\n" " -q, --quiet Inhibit usual output\n"
" -v, --verbose Display more output than usual\n"); " -v, --verbose Display more output than usual\n");
exit (status); exit (status);
@ -148,6 +150,9 @@ decode_args (int argc, char **argv)
case 'v': // increase verbosity case 'v': // increase verbosity
options.verbosity++; options.verbosity++;
break; break;
case 256:
options.nomip = 1;
break;
default: default:
usage (1); usage (1);
} }
@ -328,24 +333,29 @@ wad_extract (wad_t *wad, lumpinfo_t *pf)
image = calloc (1, miptex->width * miptex->height * 3 / 2); image = calloc (1, miptex->width * miptex->height * 3 / 2);
memcpy (image, buffer + miptex->offsets[0], memcpy (image, buffer + miptex->offsets[0],
miptex->width * miptex->height); miptex->width * miptex->height);
for (u = 0; u < miptex->height * 1 / 2; u++) { if (!options.nomip) {
i = miptex->height + u; for (u = 0; u < miptex->height * 1 / 2; u++) {
memcpy (image + i * miptex->width, i = miptex->height + u;
buffer + miptex->offsets[1] + u * miptex->width / 2, memcpy (image + i * miptex->width,
miptex->width / 2); buffer + miptex->offsets[1] + u * miptex->width / 2,
if (u >= miptex->height * 1 / 4) miptex->width / 2);
continue; if (u >= miptex->height * 1 / 4)
memcpy (image + i * miptex->width + miptex->width / 2, continue;
buffer + miptex->offsets[2] + u * miptex->width / 4, memcpy (image + i * miptex->width + miptex->width / 2,
miptex->width / 4); buffer + miptex->offsets[2] + u * miptex->width / 4,
if (u >= miptex->height * 1 / 8) miptex->width / 4);
continue; if (u >= miptex->height * 1 / 8)
memcpy (image + i * miptex->width + miptex->width * 3 / 4, continue;
buffer + miptex->offsets[2] + u * miptex->width / 8, memcpy (image + i * miptex->width + miptex->width * 3 / 4,
miptex->width / 8); buffer + miptex->offsets[2] + u * miptex->width / 8,
miptex->width / 8);
}
pcx = EncodePCX (image, miptex->width, miptex->height * 3 / 2,
miptex->width, default_palette, false, &len);
} else {
pcx = EncodePCX (image, miptex->width, miptex->height,
miptex->width, default_palette, false, &len);
} }
pcx = EncodePCX (image, miptex->width, miptex->height * 3 /2,
miptex->width, default_palette, false, &len);
free (image); free (image);
free (buffer); free (buffer);
if (Qwrite (file, pcx, len) != len) { if (Qwrite (file, pcx, len) != len) {

View file

@ -49,6 +49,7 @@ typedef struct {
int verbosity; // 0=silent int verbosity; // 0=silent
qboolean compress; // for the future qboolean compress; // for the future
qboolean pad; // pad area of files to 4-byte boundary qboolean pad; // pad area of files to 4-byte boundary
qboolean nomip; // exclude mipmaps from output textures.
char *wadfile; // wad file to read/write/test char *wadfile; // wad file to read/write/test
} options_t; } options_t;