tneva82
March 20th, 2009, 09:33 AM
Another day, another question it seems. Anyway I'm trying to get heightmaps working and to test them I need some heightmaps. So I figured converter should be easy enough to do. However either I'm screwing up with setting palette(custom palete, trying to get the 256 colours all be different. I try to create one big block there of second lowest index(1) amidst lowest level.With multiplier of 0.3(value in the heightmap*0,3 should therefore give me the height) I still get oddly high blocks. 10+ infact(and in openGL that's pretty darned high). And for added fun when I tried adding second block where I used what's supposed to be highest index gives me only about twice as long block. What the? Should be more like 200 times higher!
So somewhere I'm not getting it right. Is the error in how I set up palet in the paint program or in how I convert BMP to RAW file? Code below.
int main(int argc, char **argv) {
char *input=new char[256];
char *output=new char[256];
strcpy(input, argv[1]);
strcpy(output, argv[1]);
strcat(input, ".bmp");
strcat(output, ".raw");
FILE *pFile=fopen(output, "wb");
SDL_Surface *TextureImage;
if (( TextureImage = SDL_LoadBMP(input) )) {
char *pixels=(char*)TextureImage->pixels;
for(int i=0;i<TextureImage->w*TextureImage->h;i++) {
fputc(pixels[i], pFile);
}
}
// Free up any memory we may have used
if (TextureImage) {
SDL_FreeSurface(TextureImage);
}
fclose(pFile);
delete[] input;
delete[] output;
}
So somewhere I'm not getting it right. Is the error in how I set up palet in the paint program or in how I convert BMP to RAW file? Code below.
int main(int argc, char **argv) {
char *input=new char[256];
char *output=new char[256];
strcpy(input, argv[1]);
strcpy(output, argv[1]);
strcat(input, ".bmp");
strcat(output, ".raw");
FILE *pFile=fopen(output, "wb");
SDL_Surface *TextureImage;
if (( TextureImage = SDL_LoadBMP(input) )) {
char *pixels=(char*)TextureImage->pixels;
for(int i=0;i<TextureImage->w*TextureImage->h;i++) {
fputc(pixels[i], pFile);
}
}
// Free up any memory we may have used
if (TextureImage) {
SDL_FreeSurface(TextureImage);
}
fclose(pFile);
delete[] input;
delete[] output;
}