I am actually implementing a small and rather limited but still commercially usable PNG decoder. This might be the first truly hard task I've ever undertaken (especially since I started around 10PM last night, it's 6AM now, and I'm trying to finish in in about another 8 hours or so, though it's not a hard-and-fast requirement).
We're only supporting 16- and 256- color, paletted, non-interlaced images right now, and ignoring all non-crucial blocks (like gamma correction), which is almost a microscopic subset of all possible PNG images. PNG is a very flexible and in my opinion pretty bad-ass format. Still, writing a decoder is tough - I'm having to learn about LZ77 compression on the fly, and I still have the defiltering step afterwards. PNG data achieves the great compression it does partially because before compressing its pixel data, it rearranges each scanline (a scanline is a horizontal line in the image) according to one of a few predictable algorithms that improve the compressibility of the data. However, after it's uncompressed, it has to be defiltered as well, by applying the algorithm that was originally applied to the scanline in reverse, and this can be different for each scanline. (Though, actually, it seems like compared to LZ77 compression/decompression, the filtering/defiltering steps are cake.)
Anyway, for anyone who doesn't care about this kind of thing (quite possibly most of you), the thing I really wanted to convey is that I actually finally feel like I'm earning the wings for my "serious programmer" credential, so to speak.
As for why I'm not using one of the existing decoder libraries, I'd rather not waste code space implementing a complete decoder given mobile phone requirements, and I have no guarantee that any we'd use wouldn't be unusable due to a static or global variable of some kind (illegal in BREW) anyway. We actually need a decoder that only supports this limited subset of PNG, and I don't know of any decoder that would fit.
What's great is that I'm quite excited, and am starting to be pretty happy to be becoming the kind of geek that is thrilled to be pulling an all-nighter doing this. I suppose that makes me rather different, but really, who gives a pair of rat's asses...just wanted to share some exuberance with you all.
We're only supporting 16- and 256- color, paletted, non-interlaced images right now, and ignoring all non-crucial blocks (like gamma correction), which is almost a microscopic subset of all possible PNG images. PNG is a very flexible and in my opinion pretty bad-ass format. Still, writing a decoder is tough - I'm having to learn about LZ77 compression on the fly, and I still have the defiltering step afterwards. PNG data achieves the great compression it does partially because before compressing its pixel data, it rearranges each scanline (a scanline is a horizontal line in the image) according to one of a few predictable algorithms that improve the compressibility of the data. However, after it's uncompressed, it has to be defiltered as well, by applying the algorithm that was originally applied to the scanline in reverse, and this can be different for each scanline. (Though, actually, it seems like compared to LZ77 compression/decompression, the filtering/defiltering steps are cake.)
Anyway, for anyone who doesn't care about this kind of thing (quite possibly most of you), the thing I really wanted to convey is that I actually finally feel like I'm earning the wings for my "serious programmer" credential, so to speak.
As for why I'm not using one of the existing decoder libraries, I'd rather not waste code space implementing a complete decoder given mobile phone requirements, and I have no guarantee that any we'd use wouldn't be unusable due to a static or global variable of some kind (illegal in BREW) anyway. We actually need a decoder that only supports this limited subset of PNG, and I don't know of any decoder that would fit.
What's great is that I'm quite excited, and am starting to be pretty happy to be becoming the kind of geek that is thrilled to be pulling an all-nighter doing this. I suppose that makes me rather different, but really, who gives a pair of rat's asses...just wanted to share some exuberance with you all.