Ok, this isn't a complete decoder, as it doesn't support a lot of the PNG image format's features yet. However, the parts that are done do work.
Actually, decoding a pNG iamge is a lot easier than one would think, my biggest problem is that the language I'm using (perl) much prefers to treat bytes as ASCII characters rather than binary data, so there's a lot of conversions going on.
I'm testing it on a small (4x4 pixel) image that's just a bunch of random colors. The hex values for each of the pixels are output at the bottom of the output.
Here's a sample output screen:
C:\>png.pl test.png
File Looks like a valid PNG
image contains 5 chunks
Chunk types (in order):
IHDR
gAMA
cHRM
IDAT
IEND
Header information (from IHDR):
Width: 4px
Height: 4px
Bit Depth: 8bpp
Color type: 6 (color used, alpha used)
Compression Method: 0 (only type 0 is defined)
Filtering Method: 0 (only type 0 is defined)
Interlace method: 0 (no interlace)
Filter type of scanline 1: 0
FF0000 FFFFFF F6FF00 FF00F6
Filter type of scanline 2: 0
810025 00FF0C 000000 0006FF
Filter type of scanline 3: 0
2FEE8D 2024CC 0006FF 000000
Filter type of scanline 4: 0
FF0000 FF00B4 FF00F6 880060
What do you think? I think this is pretty cool. (I like messing with pictures). After I get the decoder done, I plan to write an encoder to go along with it (the encoder will be easier I think, it has fewer required features to implement). and then some resizing algorithms.
Does anyone else find this kind of stuff interesting?
BTW, here's the test image I'm using.
Actually, decoding a pNG iamge is a lot easier than one would think, my biggest problem is that the language I'm using (perl) much prefers to treat bytes as ASCII characters rather than binary data, so there's a lot of conversions going on.
I'm testing it on a small (4x4 pixel) image that's just a bunch of random colors. The hex values for each of the pixels are output at the bottom of the output.
Here's a sample output screen:
C:\>png.pl test.png
File Looks like a valid PNG
image contains 5 chunks
Chunk types (in order):
IHDR
gAMA
cHRM
IDAT
IEND
Header information (from IHDR):
Width: 4px
Height: 4px
Bit Depth: 8bpp
Color type: 6 (color used, alpha used)
Compression Method: 0 (only type 0 is defined)
Filtering Method: 0 (only type 0 is defined)
Interlace method: 0 (no interlace)
Filter type of scanline 1: 0
FF0000 FFFFFF F6FF00 FF00F6
Filter type of scanline 2: 0
810025 00FF0C 000000 0006FF
Filter type of scanline 3: 0
2FEE8D 2024CC 0006FF 000000
Filter type of scanline 4: 0
FF0000 FF00B4 FF00F6 880060
What do you think? I think this is pretty cool. (I like messing with pictures). After I get the decoder done, I plan to write an encoder to go along with it (the encoder will be easier I think, it has fewer required features to implement). and then some resizing algorithms.
Does anyone else find this kind of stuff interesting?
BTW, here's the test image I'm using.