Sunday, October 11, 2020

How to Code PNG? FAIL!

 PNG stands for Portable Network Graphic. It was a mystery to me then, and it is a mystery to me now. The problem lies in the compression method. The PNG standard specifies compression as a necessary element. Specifically INFLATE/DEFLATE method. If you want to store uncompressed data, you need to use the uncompressed data block of DEFLATE method.

I was shocked to see that in PNG specification. Common sense design means that uncompressed data should be included in the specification. That way, you can implement the program to deal with the simple case before investing in further effort. 

So, what's the problem? The fact that the compression/decompresion algorithm isn't part of PNG standard means that there is a dependency that is needed to be resolved before I can code my own PNG encoder. That's bad.

Especially since the reference for such code is located in some FTP site, and it was busted. I don't think the site even exists anymore. Hence, broken dependency. All I know about the algorithm is that it is a variant of LZ77 with Huffman encoding, which can be extremely varied depending upon implementation. How am I supposed to implement PNG program?


I am aware that there is a PNG lib somewhere out there. I'm not using that. I want to code it from scratch. That way, I know that the specification is good. The way it is now, the specification is no good. It is too complicated and incomplete. There is no way to specify multiple images, for example. 

I suspect that I should just abandon the endeavor entirely, and focus on improving something easier to do, such as PBM, Portable BitMap format.

No comments: