Is it a good method (BMP heightmap to raw) ?
I'm trying to model a terrain (Puget sound) by using its Heightmap Model : Puget Sound
To read that PNG file in my program I used this function
But unfortunately the results is completely disaster. So, I convert PNG file to RAW using photoshop (read PNG file in photoshop than exported as RAW file) and I used the same function to read that RAW file and the result was good.
bool CTerrain::LoadHeightMap(char* fileName, int length, int width)
file = fopen(fileName, "rb");
//check to see if there is data
if (file == NULL)
BYTE Heights = ( BYTE *)malloc(length*width*sizeof( BYTE ));
fread(Heights,sizeof( BYTE ),length*width,file);
////check to see if there is data
if( Heights != NULL )
My question is : Is the method that I used correct ?
Thanks in advance