0

I want to pre-render a scene in different positions and store the color an depth images in a png. I do this with PNGWriter.

pngwriter image(640, 480, 0.0, path.c_str());

for(int i = 0;  i < 640*480 ; ++i){
    int x = i % 640;
    int y = i/640;

    image.plot(x, y, data[i*3], data[i*3+1], data[i*3+2]);
}

image.close();

and in a different application I want to load this informations with SOIL.

int width, height;
    unsigned char* image = SOIL_load_image(path.c_str(), &width, &height, 0, SOIL_LOAD_RGB);

But here my image is NULL, also width and height is 0.

Are there different kind of png formats? Can someone explain how to load the image with SOIL?

Dominick
  • 291
  • 2
  • 13
  • Depending on your view, either there are *many* PNG formats (bit depths, number of colors, alpha presence and type) ... or only 1 - the [Official One](http://www.w3.org/TR/PNG/). If you doubt your code is creating a correct PNG, write it to a file and test with `pngcheck`. If the file in itself is correctly formed, the error lies at the other end, reading it in again. – Jongware Dec 04 '16 at 16:46
  • pngcheck is saying (640x480, 48-bit RGB, non-interlaced, 96.7%). – Dominick Dec 04 '16 at 17:09
  • Can I somehow write with PNGwriter a 24bit version? – Dominick Dec 04 '16 at 17:28
  • [The documentation](http://pngwriter.sourceforge.net/) seems to suggest you cannot: various references to converting *to* 16-bit such as "New instances of PNGwriter are 16-bit by default ..", but not in the opposite direction. Convert an image "manually" to 8-bit (use any way possible) and see if it solves the problem of importing into your database. – Jongware Dec 05 '16 at 11:19

0 Answers0