if( file==NULL ||fread(TGAcompare,1,sizeof(TGAcompare),file)!=sizeof(TGAcompare) || memcmp(TGAheader,TGAcompare,sizeof(TGAheader))!=0 || fread(header,1,sizeof(header),file)!=sizeof(header))
{
if (file == NULL)
return false;
else // <======== this else statement executes, resulting in a value of false being returned
{
fclose(file);
return false;
}
}
Edited several times to make Targa code more readable
Creating Targa Files in PSP 8.0?
I'm trying to create some Targa files for a project I'm currently working on, but I can't seem to get them to work using NeHe's Targa image loader from lesson 24("Initialization Failed." error). Looking around a little bit on the Internet has yielded no help either. Can anybody tell or point me in the direction of the proper way to create 32-bit Targa files using Paint Shop Pro 8.0? Or a compatible loader?
The code that creates the "Initialization Failed." error is ...
Go here and download the TGA specification (the one from Truevision).
I assume the problem is the memcmp function, which returns non-zero. This is because you're comparing the actual header with a pre-defined header, a pre-defined header which does not work with TGAs exported from PSP8. PSP8 writes some extra information, which is not handled by your loader.
The files written by PSP8 are correct according to the specification, so you just have to make a more generic loader to handle the extra information.
I assume the problem is the memcmp function, which returns non-zero. This is because you're comparing the actual header with a pre-defined header, a pre-defined header which does not work with TGAs exported from PSP8. PSP8 writes some extra information, which is not handled by your loader.
The files written by PSP8 are correct according to the specification, so you just have to make a more generic loader to handle the extra information.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement