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*
|
uint8*
|
||||||
getFileContents(char *name, uint32 *len)
|
getFileContents(const char *name, uint32 *len)
|
||||||
{
|
{
|
||||||
FILE *cf = fopen(name, "rb");
|
FILE *cf = fopen(name, "rb");
|
||||||
assert(cf != nil);
|
assert(cf != nil);
|
||||||
|
|
|
@ -73,11 +73,10 @@ BMPheader::write(Stream *stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
Image*
|
Image*
|
||||||
readBMP(const char *afilename)
|
readBMP(const char *filename)
|
||||||
{
|
{
|
||||||
ASSERTLITTLE;
|
ASSERTLITTLE;
|
||||||
Image *image;
|
Image *image;
|
||||||
char *filename;
|
|
||||||
uint32 length;
|
uint32 length;
|
||||||
uint8 *data;
|
uint8 *data;
|
||||||
StreamMemory file;
|
StreamMemory file;
|
||||||
|
@ -86,11 +85,7 @@ readBMP(const char *afilename)
|
||||||
bool32 noalpha;
|
bool32 noalpha;
|
||||||
int pad;
|
int pad;
|
||||||
|
|
||||||
filename = Image::getFilename(afilename);
|
|
||||||
if(filename == nil)
|
|
||||||
return nil;
|
|
||||||
data = getFileContents(filename, &length);
|
data = getFileContents(filename, &length);
|
||||||
rwFree(filename);
|
|
||||||
if(data == nil)
|
if(data == nil)
|
||||||
return nil;
|
return nil;
|
||||||
file.open(data, length);
|
file.open(data, length);
|
||||||
|
|
|
@ -695,5 +695,5 @@ bool readChunkHeaderInfo(Stream *s, ChunkHeaderInfo *header);
|
||||||
bool findChunk(Stream *s, uint32 type, uint32 *length, uint32 *version);
|
bool findChunk(Stream *s, uint32 type, uint32 *length, uint32 *version);
|
||||||
|
|
||||||
int32 findPointer(void *p, void **list, int32 num);
|
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*
|
Image*
|
||||||
readTGA(const char *afilename)
|
readTGA(const char *filename)
|
||||||
{
|
{
|
||||||
TGAHeader header;
|
TGAHeader header;
|
||||||
Image *image;
|
Image *image;
|
||||||
char *filename;
|
|
||||||
int depth = 0, palDepth = 0;
|
int depth = 0, palDepth = 0;
|
||||||
filename = Image::getFilename(afilename);
|
|
||||||
if(filename == nil)
|
|
||||||
return nil;
|
|
||||||
uint32 length;
|
uint32 length;
|
||||||
uint8 *data = getFileContents(filename, &length);
|
uint8 *data = getFileContents(filename, &length);
|
||||||
assert(data != nil);
|
assert(data != nil);
|
||||||
rwFree(filename);
|
|
||||||
StreamMemory file;
|
StreamMemory file;
|
||||||
file.open(data, length);
|
file.open(data, length);
|
||||||
header.read(&file);
|
header.read(&file);
|
||||||
|
|
Loading…
Reference in New Issue