JPG and PNG decoder

cal callumenator at
Sun Jun 17 16:49:11 PDT 2012

On Sunday, 17 June 2012 at 23:17:54 UTC, Stewart Gordon wrote:
>> You two should fuse it into one module, to give us 
>> loading/writing.
>> That would be quite cool.
> I don't know how much of the code will need rewriting in order 
> to support interlacing or all PNG colour types/depths.
> But I also began writing a PNG library a while back - with the 
> intention that it will be a full PNG editing library, not just 
> encoding/decoding of the image data.  But I haven't had much 
> time to work on it recently.  And it would help a lot if we 
> could have the replacement for some time soon.
> Stewart.

I just pushed an update which implements a PNG encoder. It is 
implemented in the Image class as a write method. If you have a 
raw buffer, and want to encode it, you can do something like this:

ubyte[] data = some data;
Image img = new Img!(Px.R8G8B8)(width, height, data);

It uses adaptive filtering, and should work with the pixel 
formats supported by the image class (except for the 16 bit ones 
I've just realised). I've only tested it on images that I have 
previously loaded in however.

Stewart, I used your makepng.d as a template for this, can I add 
you to the author list?

Also, if preferred, I can keep the master branch as a single 
merged module, just let me know.


More information about the Digitalmars-d-announce mailing list