-
> when running png_read_image function I got an error " impossible to convert unsigned short to png_bytep "
Are all the casts indicating you're using a C++ compiler to compile C code?
You might need to cast your row_pointers into some suitable type (void*).
I think your allocations are off.
Code:
unsigned short **row_pointers = NULL;
row_pointers = malloc (sizeof (*row_pointers) * Map.Height); // Or whatever tells you there are 1025 rows
for (i = 0; i < Map.Height; ++i) {
row_pointers[i] = malloc( sizeof (*row_pointers[i]) * Map.Width ); // Or whatever tells you there are 1025 pixels per row
}
If you want to go with the single contiguous block you have in your code, with pointers to the start of each row, then this is simpler.
Code:
unsigned short *block = malloc( width * height * sizeof(*block) );
unsigned short **rows = malloc( height * sizeof(*rows) );
for ( i = 0 ; i < height ; i++, blocks += width ) {
rows[i] = block;
}
///
free( rows[0] );
free( rows );
-
I have told you before Salem this heightmap will drive me crazy ;) this time I have got three errors :
1- for row_pointers[i] = malloc( sizeof (*row_pointers[i]) * Map.width ); the problem was : impossible to convert void* to unsigned short**
2- for row_pointers = malloc (sizeof (*row_pointers) * Map.length); the problem was the same: impossible to convert void* to unsigned short**
3- and for png_read_image (png_ptr, row_pointers);the problem was impossible to converte unsigned short ** to png_bytepp
-
Great, so you ARE using a C++ compiler to compile C code.
How about using the right tool for the job to begin with.
-
In fact I use visual studio 2008 and if I change the c++ compiler to C I will have other problems :frown: .... I'm sur that if it could be running with C compiler there will be a way to do it in C++ compiler :) Do you have any idea ?
I'm very grateful to you Salem