Hi Everyone,
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.Code:bool CTerrain::LoadHeightMap(char* fileName, int length, int width) { FILE *file; file = fopen(fileName, "rb"); //check to see if there is data if (file == NULL) return false; BYTE Heights = ( BYTE *)malloc(length*width*sizeof( BYTE )); fread(Heights,sizeof( BYTE ),length*width,file); fclose(file); ////check to see if there is data if( Heights != NULL ) { return true; } else return false; }
My question is : Is the method that I used correct ?
Thanks in advance