0

I need to work on png pictures for a school project using c++. I found png++ which seems pretty easy to use but I had some really hard time setting up everything to make it work (which it doesn't). I used Cygwin to properly install zlib and libpng. I properly included the png++ headers in my project (I'm using Eclipse). Here are some things that are not properly working:

If I try this line of code (as seen here ):

image img(1024,768);

I get this error after compiling on eclipse:

#error Byte-order could not be detected.

I read this answer here, but the solution is not working for me (I'm on windows 8 64 bit), and I get this other error (which is my main problem because Byte-order can be "brutally" fixed):

missing template arguments before 'img'

But even if I type a valid template argument (like < png::rgb_pixel> < png::rgba_pixel > < png::gray_pixel > < png::ga_pixel >) it says it's invalid.

I'm clearly not an expert on this and I wouldn't know what else to try. Any help would be much appreciated. If you need more info write a comment and I'll provide.

Community
  • 1
  • 1
G4bri3l
  • 4,996
  • 4
  • 31
  • 53
  • What template arguments did you try? Also, `png.hpp` isn't on your include path. That's what that second error means. – Qix - MONICA WAS MISTREATED May 13 '14 at 16:22
  • 2
    You should find an example that isn't so dated. – Captain Obvlious May 13 '14 at 16:35
  • @Qix I tried < png::rgb_pixel> < png::rgba_pixel > < png::gray_pixel > < png::ga_pixel >, and I stil get the Byte-order error. Compiling the tests on eclipse instead of cygwin I only get the Byte-order error and nothing about png.hpp missing. But even if I somehow find a workaround for the Byte-order error, the template problem is still there. So right now that's the only thing stopping me from making simple code working. – G4bri3l May 14 '14 at 08:52
  • @CaptainObvlious I tried tests included in the png++ tar getting the above errors. – G4bri3l May 14 '14 at 08:53
  • Make sure to put those into the answer with an edit :) – Qix - MONICA WAS MISTREATED May 14 '14 at 17:00
  • Just did, good call. I feel like I'm gonna learn to use another library to handle png files but this one seemed very easy to use. Any suggestion ? – G4bri3l May 14 '14 at 17:17

1 Answers1

0

For the template arguments, I think that is actually just an Eclipse issue, it should have compiled fine. But in order to get rid of the Eclipse errors, you can see my answer here: https://stackoverflow.com/a/28400902/583620.

For the byte-order problem an easy way to solve this is to just go into the png++ header folder location (probably under /usr/local/include), open config.hpp, and put

#define _WIN32

before the // Endianness test comment. That should do it. Alternatively you can try what was mentioned in the answer you posted earlier and change _WIN32 to WIN32 although in my case WIN32 was not defined either so it was quicker to just define _WIN32.

Community
  • 1
  • 1