1

I am trying to write a simple program that would read in a grayscale PNG image using Boost's GIL Image I/O library and then obtain each pixel's information. I have downloaded and extracted the libpng and zlib, included them in my makefile, and linked them.

When trying to execute the following code:

#include <boost/gil/gil_all.hpp>
#include <boost/gil/extension/io/png_dynamic_io.hpp>
#include <iostream>

int main()
{
    using std::cout;
    using std::endl;
    boost::gil::gray16_image_t image;
    cout << "TEST";
    boost::gil::png_read_and_convert_image("png16_example.png", image);
    cout << "test";
    return 0;
}

Neither of the "test" print statements work. In fact, nothing happens at all. I commented out the line:

boost::gil::png_read_and_convert_image("png16_example.png", image);

And it runs fine again. I'm not sure what I am doing wrong, as it seems like I've included and linked everything correctly.

Also, if anyone knows of an easier/better way to load in a PNG, I'm also open for suggestions.

TMGunter
  • 137
  • 1
  • 4
  • 12
  • 1
    First of all you should do `cout << "TEST" << endl;` to ensure that the output buffer is flushed immediately after filling it. If you don't do that, chances are that your debug output is deferred and you make wrong assumptions. – ypnos Apr 16 '13 at 17:13
  • I just tried that and obtained the same result. Any thoughts? – TMGunter Apr 16 '13 at 23:53

0 Answers0