Puget sound heightmap discription

This is a discussion on Puget sound heightmap discription within the Game Programming forums, part of the General Programming Boards category; > when running png_read_image function I got an error " impossible to convert unsigned short to png_bytep " Are all ...

  1. #16
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    > 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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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

Page 2 of 2 FirstFirst 12
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, 03: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, 03:24 PM
  5. Sound
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 03-27-2002, 11:42 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21