mirror of https://github.com/aap/librw.git
fixed tex reading bug
This commit is contained in:
parent
990a7e21dd
commit
65d14730da
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue