Archived

This topic is now archived and is closed to further replies.

Reading .raw files for height maps...

Recommended Posts

shoudlnt this load a raw file ?? i keep gettin errors saying i cant access the blah huge number...

#define SIZE 1024

unsigned char MAP[SIZE*SIZE];

bool Load_RAW (char *filename, int size, unsigned char *Texture)
{
FILE * File = NULL
File = fopen (filename,"rb");

if (File == NULL)
{
fclose (File);
return false;
}

int result = ferror (File);

if (result)
{
fclose (File);
return false;
}

fclose (File);
return true;
}

..................... som where on the code



Share on other sites
When you read in the file, you are only reading in 1 row of data. You want to do this:

Edit: My bad. Got confused between function parameter "size" and the define "SIZE".

[edited by - Estese on August 14, 2002 1:38:43 PM]

Share on other sites
You should be more precise about your error, and where you call the code from.

Also, the above poster isn''t correct, as you specify the size argument properly.

How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions

Share on other sites
Hmm, I had the same problem...
fread()''s size parameters are short int, and you are trying to read 1024*1024=2^20 wich is larger than 2^16 (maximum number that can be retained using short). You should use something like

This way both parameters (count and size) from fread are smaller than the maximum value. Oh, another thing: if you have to read something (size smaller than 2^16) it''s faster to use

than

Good luck!

Share on other sites
fread should take size_t as parameters, which as far as I know on VC++ is a 32 bit int.

What compiler are you using?

How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions

• Forum Statistics

• Total Topics
628388
• Total Posts
2982403

• 10
• 9
• 16
• 24
• 11