fixed tex reading bug

This commit is contained in:
aap 2020-07-16 11:35:41 +02:00
parent 990a7e21dd
commit 65d14730da
4 changed files with 4 additions and 14 deletions

View File

@ -1102,7 +1102,7 @@ findPointer(void *p, void **list, int32 num)
}
uint8*
getFileContents(char *name, uint32 *len)
getFileContents(const char *name, uint32 *len)
{
FILE *cf = fopen(name, "rb");
assert(cf != nil);

View File

@ -73,11 +73,10 @@ BMPheader::write(Stream *stream)
}
Image*
readBMP(const char *afilename)
readBMP(const char *filename)
{
ASSERTLITTLE;
Image *image;
char *filename;
uint32 length;
uint8 *data;
StreamMemory file;
@ -86,11 +85,7 @@ readBMP(const char *afilename)
bool32 noalpha;
int pad;
filename = Image::getFilename(afilename);
if(filename == nil)
return nil;
data = getFileContents(filename, &length);
rwFree(filename);
if(data == nil)
return nil;
file.open(data, length);

View File

@ -695,5 +695,5 @@ bool readChunkHeaderInfo(Stream *s, ChunkHeaderInfo *header);
bool findChunk(Stream *s, uint32 type, uint32 *length, uint32 *version);
int32 findPointer(void *p, void **list, int32 num);
uint8 *getFileContents(char *name, uint32 *len);
uint8 *getFileContents(const char *name, uint32 *len);
}

View File

@ -73,19 +73,14 @@ TGAHeader::write(Stream *stream)
}
Image*
readTGA(const char *afilename)
readTGA(const char *filename)
{
TGAHeader header;
Image *image;
char *filename;
int depth = 0, palDepth = 0;
filename = Image::getFilename(afilename);
if(filename == nil)
return nil;
uint32 length;
uint8 *data = getFileContents(filename, &length);
assert(data != nil);
rwFree(filename);
StreamMemory file;
file.open(data, length);
header.read(&file);