1
0
Fork 0
forked from fte/fteqw

'dir textures/*/*.wal' can now show previews.

This commit is contained in:
Shpoike 2024-04-14 04:54:07 +01:00
parent 3da900073e
commit fd387f3e99
2 changed files with 42 additions and 1 deletions

View file

@ -7516,6 +7516,46 @@ qbyte *ReadRawImageFile(qbyte *buf, int len, int *width, int *height, uploadfmt_
}
#endif
#ifdef Q2BSPS
if (len >= sizeof(q2miptex_t)) //.lmp has no magic id. guess at it.
{
const q2miptex_t *wal = (const q2miptex_t *)buf;
size_t w = LittleLong(wal->width), h = LittleLong(wal->height);
size_t sz = sizeof(*wal) +
(w>>0)*(h>>0) +
(w>>1)*(h>>1) +
(w>>2)*(h>>2) +
(w>>3)*(h>>3);
if (sz == len)
{
if (force_rgba8)
{
qboolean foundalpha = false;
qbyte *in = buf+sizeof(*wal);
data = BZ_Malloc(w * h * sizeof(int));
for (i = 0; i < w * h; i++)
{
// if (in[i] == 255)
// foundalpha = true;
((unsigned int*)data)[i] = d_8to24rgbtable[in[i]];
}
*width = w;
*height = h;
*format = foundalpha?PTI_RGBA8:PTI_RGBX8;
}
else
{
data = BZ_Malloc(w * h);
memcpy(data, buf+sizeof(*wal), w*h);
*width = w;
*height = h;
*format = TF_SOLID8;
}
return data;
}
}
#endif
TRACE(("dbg: Read32BitImageFile: life sucks\n"));
return NULL;

View file

@ -1585,7 +1585,8 @@ static int QDECL COM_Dir_List(const char *name, qofs_t size, time_t mtime, void
else if (!Q_strcasecmp(ext, "tga") || !Q_strcasecmp(ext, "png") || !Q_strcasecmp(ext, "jpg") || !Q_strcasecmp(ext, "jpeg")|| !Q_strcasecmp(ext, "lmp") || !Q_strcasecmp(ext, "ico") ||
!Q_strcasecmp(ext, "pcx") || !Q_strcasecmp(ext, "bmp") || !Q_strcasecmp(ext, "dds") || !Q_strcasecmp(ext, "ktx") || !Q_strcasecmp(ext, "ktx2")|| !Q_strcasecmp(ext, "vtf") ||
!Q_strcasecmp(ext, "astc")|| !Q_strcasecmp(ext, "htga")|| !Q_strcasecmp(ext, "exr") || !Q_strcasecmp(ext, "xcf") || !Q_strcasecmp(ext, "psd") || !Q_strcasecmp(ext, "iwi") ||
!Q_strcasecmp(ext, "pbm") || !Q_strcasecmp(ext, "ppm") || !Q_strcasecmp(ext, "pgm") || !Q_strcasecmp(ext, "pam") || !Q_strcasecmp(ext, "pfm") || !Q_strcasecmp(ext, "hdr") )
!Q_strcasecmp(ext, "pbm") || !Q_strcasecmp(ext, "ppm") || !Q_strcasecmp(ext, "pgm") || !Q_strcasecmp(ext, "pam") || !Q_strcasecmp(ext, "pfm") || !Q_strcasecmp(ext, "hdr") ||
!Q_strcasecmp(ext, "wal") )
{
//FIXME: image replacements are getting in the way here.
Q_snprintfz(link, sizeof(link), "\\tiprawimg\\%s\\tip\\(note: image replacement rules are context-dependant, including base path, sub path, extension, or complete replacement via a shader)", name);