> 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 );