Sign in to follow this  
Cypher777

Creating Targa Files in PSP 8.0?

Recommended Posts

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 ...
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



Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this