How to read heightmaps as bmps or targas..?
How do I get height values of the heightmap represented by bmp or targa file? I mean, how do I read pixel values line by line?
Please help..
" Do we need us? "
" Do we need us? "Ionware Productions - Games and Game Tools Development
Not sure what you mean, but if the problem is reading a tga file you can have a look at this code:
This only reads 24 bit TGA:s but it wouldn''t be very hard to modify for 32 or something else. Just ask if there''s any problems with the code.
FILE *file = fopen(path, "rb"); BYTE header[12]; BYTE correct[12] = {0,0,2,0,0,0,0,0,0,0,0,0,}; BYTE headerInfo[6]; fread(header, sizeof(BYTE), 12, file); if(memcmp(header, correct, sizeof(correct)) != 0) Debug("Invalid header"); fread(headerInfo, sizeof(headerInfo),1,file); width = headerInfo[1] * 256 + headerInfo[0]; height = headerInfo[3] * 256 + headerInfo[2]; if(headerInfo[4] != 24) Debug("Invalid map bpp"); byte *tempHeightData = new byte[width*height*3]; fread(tempHeightData, sizeof(byte), width*height*3, file);
This only reads 24 bit TGA:s but it wouldn''t be very hard to modify for 32 or something else. Just ask if there''s any problems with the code.
-----------------------------Reporter: Are they slow-moving, chief?Sheriff: Yeah, they're dead. They're all messed up.-Night of the living dead
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement