mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-26 08:50:55 +00:00
(ATM broken) support for PNG highpal files; their dimensions must be the same as the TGA ones.
git-svn-id: https://svn.eduke32.com/eduke32@1749 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
3d2bcbfba8
commit
002ac54ca8
2 changed files with 65 additions and 18 deletions
|
@ -1436,6 +1436,8 @@ static int32_t defsparser(scriptfile *script)
|
||||||
char *fn = NULL, *tfn = NULL;
|
char *fn = NULL, *tfn = NULL;
|
||||||
char *highpalend;
|
char *highpalend;
|
||||||
char *highpaldata;
|
char *highpaldata;
|
||||||
|
static const uint8_t pngheaderref[8] = { 137, 80, 78, 71, 13, 10, 26, 10 };
|
||||||
|
uint8_t pngheader[8];
|
||||||
|
|
||||||
static const tokenlist highpaltokens[] =
|
static const tokenlist highpaltokens[] =
|
||||||
{
|
{
|
||||||
|
@ -1489,9 +1491,15 @@ static int32_t defsparser(scriptfile *script)
|
||||||
// load the highpalookup and send it to polymer
|
// load the highpalookup and send it to polymer
|
||||||
datasize = PR_HIGHPALOOKUP_DATA_SIZE;
|
datasize = PR_HIGHPALOOKUP_DATA_SIZE;
|
||||||
|
|
||||||
|
fd = kopen4load(fn, 0);
|
||||||
|
|
||||||
|
if (kread(fd, pngheader, sizeof(pngheader))!=sizeof(pngheader))
|
||||||
|
break;
|
||||||
|
|
||||||
highpaldata = Bmalloc(datasize);
|
highpaldata = Bmalloc(datasize);
|
||||||
|
|
||||||
fd = kopen4load(fn, 0);
|
if (Bmemcmp(pngheader, pngheaderref, sizeof(pngheader))) // blindly assume TGA
|
||||||
|
{
|
||||||
// skip the TGA header
|
// skip the TGA header
|
||||||
klseek(fd, 18, SEEK_SET);
|
klseek(fd, 18, SEEK_SET);
|
||||||
|
|
||||||
|
@ -1505,6 +1513,45 @@ static int32_t defsparser(scriptfile *script)
|
||||||
|
|
||||||
// ignore whatever image editors might have put after the interesting stuff
|
// ignore whatever image editors might have put after the interesting stuff
|
||||||
kclose(fd);
|
kclose(fd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char *filebuf, *tmpbuf;
|
||||||
|
int32_t xsiz, ysiz, filesize, i;
|
||||||
|
|
||||||
|
filesize = kfilelength(fd);
|
||||||
|
|
||||||
|
filebuf = Bmalloc(filesize);
|
||||||
|
if (!filebuf) { Bfree(highpaldata); break; }
|
||||||
|
|
||||||
|
klseek(fd, 0, SEEK_SET);
|
||||||
|
if (kread(fd, filebuf, filesize)!=filesize)
|
||||||
|
{ Bfree(highpaldata); initprintf("Error: didn't read all of '%s'.\n", fn); break; }
|
||||||
|
|
||||||
|
kclose(fd);
|
||||||
|
kpgetdim(filebuf, filesize, &xsiz, &ysiz);
|
||||||
|
|
||||||
|
if (xsiz*ysiz != PR_HIGHPALOOKUP_DATA_SIZE/4)
|
||||||
|
{
|
||||||
|
initprintf("Error: product of image dimensions of '%s' must equal %d.\n",
|
||||||
|
fn, PR_HIGHPALOOKUP_DATA_SIZE/4);
|
||||||
|
Bfree(filebuf); Bfree(highpaldata);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
i = kprender(filebuf, filesize, (intptr_t)highpaldata, xsiz*sizeof(coltype), xsiz, ysiz, 0, 0);
|
||||||
|
Bfree(filebuf);
|
||||||
|
if (i)
|
||||||
|
{ Bfree(highpaldata); initprintf("Error: failed rendering '%s': code %d.\n", fn, i); break; }
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
for (i=0; i<PR_HIGHPALOOKUP_DATA_SIZE/4; i++)
|
||||||
|
{
|
||||||
|
char *col = &highpaldata[i*4];
|
||||||
|
swapchar(&col[0], &col[2]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
polymer_definehighpalookup(pal, highpaldata);
|
polymer_definehighpalookup(pal, highpaldata);
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ static int32_t ccind[19] = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
|
||||||
static int32_t hxbit[59][2], ibuf0[288], nbuf0[32], ibuf1[32], nbuf1[32];
|
static int32_t hxbit[59][2], ibuf0[288], nbuf0[32], ibuf1[32], nbuf1[32];
|
||||||
static const uint8_t *filptr;
|
static const uint8_t *filptr;
|
||||||
static uint8_t slidebuf[32768], opixbuf0[4], opixbuf1[4];
|
static uint8_t slidebuf[32768], opixbuf0[4], opixbuf1[4];
|
||||||
static uint8_t pnginited = 0, olinbuf[65536] ASMNAME("olinbuf"); //WARNING:max xres is: 65536/bpp-1
|
static uint8_t pnginited = 0, olinbuf[131072] ASMNAME("olinbuf"); //WARNING:max xres is: 131072/bpp-1
|
||||||
static int32_t gotcmov = -2, abstab10[1024] ASMNAME("abstab10");
|
static int32_t gotcmov = -2, abstab10[1024] ASMNAME("abstab10");
|
||||||
|
|
||||||
//Variables to speed up dynamic Huffman decoding:
|
//Variables to speed up dynamic Huffman decoding:
|
||||||
|
|
Loading…
Reference in a new issue