Something wrong while reading PNG images?

Started by
1 comment, last by Deebo 19 years, 6 months ago
HI,Everyone, I wanan use PNG images in my game, but 'libpng' is too complicated to handle. According to the specification, i am trying to my own simple PNG reader based on the source code of 'libpng' and 'zlib'. When i come to the compressed image bytes, i failed to overwhelm it. No matter the data is coded using Dynamic Huffman Code or Fixed Huffman Code, the last 3 bytes is always skipped. Say, only 361 bytes of 364 are processed. Another problem, the decompressed data always looks like, 1, 255, 0, 0, 0, 0,..., although with different input images. I've been feazed for 5 days, anybody Help! Thanks a lot!
More...
Advertisement
To circumvent the problem you could use a library... A good OpenGL one is DevIL at http://openil.sourceforge.net/ works great for me.

It can hide almost all work where you just pass in a string with the filename and it will give you back a GLuint. Or you can write a 5 line function so it will give you mipmapped GLuint.

It can also help you and give you data for DirectX I believe.
I had the same frustrations while using zlib and jpeglib. I suggest that you read all documentation and examples that come with the libraries, and then use them to write you class. There is really no point in trying to "re-code" what already works. You will give your self even more headaches doing that.

This topic is closed to new replies.

Advertisement