The PNG library I started working on a month ago is finished! It is a free library for decoding and displaying PNG images in MASM32 and (Visual) C programs. The whole code for the library is written in assembly and included in the package as well. It does not have all the possible optimisations yet but I thought I'd release it first so you can use it already.
The package includes the library in source and binary form (safe & non-safe builds, in .lib files), includes and headers for MASM32 and Visual C, nice documentation (htmlhelp) and several C and asm examples of using the library.
Finally it contains a 29kb PNG viewer that uses the library.. I use it as my default viewer now :)

Features:

    [*]Support for all types of interlacing available in version 1.0:
    - Method 0: No interlacing
    - Method 1: Adam7 interlacing
    [*]Support for all color types:
    - Color type 0: Grayscale, bit depth 1,2,4,8 or 16
    - Color type 2: RGB triples, bit depth 8 or 16
    - Color type 3: Palette index, bit depth 1,2,4 or 8
    - Color type 4: Grayscale & alpha, bit depth 8 or 16
    - Color type 6: RGB triples & alpha, bit depth 8 or 16
    [*]All filter types in filter set 0 (None,sub,up,average and Paeth)
    [*]Many output formats for use with Windows bitmaps (DIBs or DDBs) or custom
    procedures
    [*]Functionality to easily generate a Windows bitmap handle
    [*]Functionality to get the original color precision even when not supported
    by DIBs
    [*]Load PNG data from file location, resource or custom data (pointer + length)
    [*]Several build modes
    - Safe mode: checks data to prevent crashing on invalid PNG
    - Non-safe mode: for internal use, use on valid PNGs only. Slightly faster
    than safe mode.
    - Custom mode: for creating your own build, leaving out unwanted things


    Download it at my site now!
    www.MadWizard.org/view.php?page=downloads

    Any comments and suggestions are appreciated..

    Thomas
Posted on 2002-04-13 05:23:42 by Thomas
Great job Thomas!

The package is as complete as it can be, very well documented too.. very nice :)

thank you :alright:
Posted on 2002-04-13 06:00:08 by savage
I must say I'm amazed at how professional this package is. You know this is better made than 90% of the commercial components you can buy for programming :alright:
It's finished alright, not counting any optimizations of course.

I know I'll be using it a lot in future programs, seeing that if you use a lot of bitmaps it can really decrease size.

I think you'd be declared a god if you also made a png encoder ;)
Posted on 2002-04-13 06:38:52 by Qweerdy
great work!
thanks for sharing
Posted on 2002-04-13 08:06:05 by adapix
Clap clap clap clap clap ! :alright:
I agree with Qweerdy, it is a very professionnal package, better than many expensive ones...

Keep up the good work on it : it is really worth it. ;)

Thanks.
Posted on 2002-04-13 09:29:55 by JCP
Thanks guys :), I hope you can use it.

Thomas
Posted on 2002-04-13 09:46:21 by Thomas
Awesome, Thomas! If I every start a own software company, can I hire you? :)
Posted on 2002-04-13 15:04:02 by bazik
Great++ work, Thomas!!

IMHO the most "useful" gfx formats:

TIFF, PNG, JPEG

now what about a loader of the other two formats? ;)
Posted on 2002-04-13 17:42:06 by Maverick

Awesome, Thomas! If I every start a own software company, can I hire you? :)


sorry I have first pick :grin:

damn fine job
:alright:
Posted on 2002-04-13 18:06:32 by Hiroshimator
Thanks again to all!

I just spend an hour trying to find the bug that prevented one image from being decoded.. I've tested the library on nearly every PNG file on my harddisk and everytime I get a new image somewhere I test it with it.
I had downloaded some kind of mp3 tag utility (only to throw it away again immediately) which had two sample images to put in the id3v2 tags. One of them was a PNG and I tried to open it.. no luck. "Invalid or corrupt PNG file".
So I decommented all the debug info and tried to find the bug. It turned out it wasn't a bug, but a badly encoded PNG.
PNG compression works partly by referring to an earlier part of the output stream, and copying that (using a length and distance pair). Although the zlib specifications clearly states:

"Note that a duplicated string reference may refer to a string in a previous block; i.e., the backward distance
may cross one or more block boundaries. However a distance cannot refer past the beginning of the output
stream.
"


This PNG did. It assumed the bytes before the output stream (which was just random garbage, I was surprised it didn't even crash), were not copied but zeroes were to be used instead. After I did this the image decoded fine and even the adler32 cheksum was correct.

I don't know if I keep this change, as it goes against the specifications. The stupid thing is that all other image viewers I could find (IE, opera, netscape, paint shop pro, irfan view) all decoded the image perfectly..

Oh well, at least it wasn't my fault :)

Thomas
P.S. here's the stupid image :grin: :
Posted on 2002-04-15 10:23:11 by Thomas

Great++ work, Thomas!!

IMHO the most "useful" gfx formats:

TIFF, PNG, JPEG

now what about a loader of the other two formats? ;)


JPEG is already supported by Windows (OleLoadPicture), I don't think it is JPEG2000 compliant tough...
Ernie made a great library (ImageLib) based on COM to decode gif, wmf, jpeg, etc...

About TIFF, I was considering making a lib to decode these pictures, don't know when I will have the time, so if Thomas wants to do it, he's more than welcome to. ;)

*EDIT* : Uhmm, TIFF format seems to be very complete (many compressions) : if somebody wants to give a try :
Posted on 2002-04-15 10:38:24 by JCP

I don't know if I keep this change, as it goes against the specifications. The stupid thing is that all other image viewers I could find (IE, opera, netscape, paint shop pro, irfan view) all decoded the image perfectly.
It seems like an elegant way to recover from an errored image, but certainly a matter to comment on in the source code. It would be nice to have a warning in some applications.
Posted on 2002-04-15 10:41:04 by bitRAKE
The TIFF v6 specification ;)
Posted on 2002-04-15 10:50:00 by JCP
REAL men code their own image format :)
Posted on 2002-04-15 10:50:16 by bazik
smart programmers use an existing format if it suits the task.
Posted on 2002-04-15 10:52:07 by f0dder
About TIFF, I was considering making a lib to decode these pictures, don't know when I will have the time, so if Thomas wants to do it, he's more than welcome to.


TIFF doesn't look fun :(.. PNG is a lot easier to code :)

bitRAKE: I think I will do something like that.

Thomas
Posted on 2002-04-15 11:04:13 by Thomas

TIFF doesn't look fun :(.. PNG is a lot easier to code :)


Yup, last time I read the TIFF specifications, I seem to remember it was much simpler. ;)

REAL men code their own image format


When you think of it, it is funny and flexible : just encode a whole bmp file using a compression, and reorganize a bit your header and you have a new image format. :grin:
Posted on 2002-04-15 11:21:15 by JCP

REAL men code their own image format :)


Yes, when they dont want the art to be used by some other person, and only read by the program you want it to read it.

Also when you are daling with gameboy color and want to squeeze every possible memory :)
Posted on 2002-04-15 16:27:00 by dxantos
OMG! What an amazing product!

How could windows have survived this long with out such a tool for developers! :grin:

PS: None of you vultures can have Thomas till hez done working with ME... ( :grin: LoL :grin: )

...This response has been stratigically paced to place this thread at the top again!.

Seriously tho, Good job Thomas!
:alright:
NaN
Posted on 2002-04-17 14:15:52 by NaN
OMG?

Object Management Group? :P

Oh My God? :grin:
Posted on 2002-04-17 17:04:18 by Maverick