Thread: Puget sound heightmap discription

  1. #16
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    > 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 );
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  2. #17
    Registered User
    Join Date
    Sep 2011
    Posts
    14
    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

  3. #18
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    Great, so you ARE using a C++ compiler to compile C code.
    How about using the right tool for the job to begin with.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #19
    Registered User
    Join Date
    Sep 2011
    Posts
    14
    In fact I use visual studio 2008 and if I change the c++ compiler to C I will have other problems .... 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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Is it a good method (BMP heightmap to raw) ?
    By fleurdelys77 in forum Game Programming
    Replies: 7
    Last Post: 09-11-2011, 05:17 AM
  2. Displaying a heightmap
    By Dark_Phoenix in forum Game Programming
    Replies: 6
    Last Post: 11-11-2006, 04:24 PM
  3. hi,sound example
    By ABitLazy in forum C# Programming
    Replies: 2
    Last Post: 06-29-2004, 10:23 AM
  4. Abstract Base Class discription.
    By curlious in forum C++ Programming
    Replies: 8
    Last Post: 11-08-2003, 04:24 PM
  5. Sound
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 03-27-2002, 12:42 PM