Balázs Sáros
Balázs Sáros

Reputation: 493

How to implement a PNG decoder completely from scratch

I started to work on a PNG encoding/decoding library for learning purposes so I want to implement every part of it by hand.

I got pretty long with it but now I'm a bit stuck. Here are the things I succesfully implemented already:

And here is where I got stuck. I vaguely know the steps from here which are:

My questions are:

Upvotes: 1

Views: 3641

Answers (1)

Mark Adler
Mark Adler

Reputation: 112349

  1. Yes. You can look at puff.c, which is an inflate implementation written with the express purpose of being a guide to how to decode a deflate stream.

  2. Each line of the image can use a different filter, which is specified in the first byte of the decompressed line.

  3. Yes, if you get it all right, then you will have a sequence of pixels, where each pixel is a grayscale value, G, that with an alpha channel, GA, RGB (red-green-blue, in that order), or RGBA.

Upvotes: 5

Related Questions