From 444d40db678915717b1dfb0d3f508870249fff5f Mon Sep 17 00:00:00 2001 From: Spoike Date: Wed, 5 Jan 2005 08:07:55 +0000 Subject: [PATCH] Added support for loading an alternate sort of sort of tga git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@730 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/image.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/engine/client/image.c b/engine/client/image.c index f578d927d..b38ef5786 100644 --- a/engine/client/image.c +++ b/engine/client/image.c @@ -182,7 +182,7 @@ qbyte *ReadTargaFile(qbyte *buf, int length, int *width, int *height, int asgrey { return ReadGreyTargaFile(data, length, &tgaheader, asgrey); } - else if (tgaheader.version == 10) + else if (tgaheader.version == 10 || tgaheader.version == 11) { #undef getc #define getc(x) *data++ @@ -191,7 +191,8 @@ qbyte *ReadTargaFile(qbyte *buf, int length, int *width, int *height, int asgrey qbyte blue, red, green, alphabyte; - if (tgaheader.bpp == 8) return NULL; + if (tgaheader.version == 10 && tgaheader.bpp == 8) return NULL; + if (tgaheader.version == 11 && tgaheader.bpp != 8) return NULL; for(row=rows-1; row>=0; row--) { @@ -207,6 +208,11 @@ qbyte *ReadTargaFile(qbyte *buf, int length, int *width, int *height, int asgrey { // run-length packet switch (tgaheader.bpp) { + case 8: //we made sure this was version 11 + blue = green = red = *data++; + alphabyte = 255; + break; + case 16: inrow = data; data+=2; @@ -287,6 +293,13 @@ qbyte *ReadTargaFile(qbyte *buf, int length, int *width, int *height, int asgrey { switch (tgaheader.bpp) { + case 8: + blue = green = red = *data++; + *pixbuf++ = red; + *pixbuf++ = green; + *pixbuf++ = blue; + *pixbuf++ = 255; + break; case 16: inrow = data; data+=2; @@ -347,6 +360,9 @@ qbyte *ReadTargaFile(qbyte *buf, int length, int *width, int *height, int asgrey { switch (tgaheader.bpp) { + case 8: + *pixbuf++ = *data++; + break; case 16: inrow = data; data+=2;