JPG and PNG decoder

Philippe Sigaud philippe.sigaud at gmail.com
Sun Jun 17 05:33:40 PDT 2012


On Sun, Jun 17, 2012 at 9:55 AM, cal <callumenator at gmail.com> wrote:
> On Sunday, 17 June 2012 at 07:07:35 UTC, Philippe Sigaud wrote:
>>
>> Still, I'm interested in writing a JPEG/PNG to disk from a
>> ubyte[3][][], or whatever.
>
>
> Do you mean that you want to encode a ubyte array to disk as JPEG/PNG?
> Encoding a JPEG would be a bit of work I think, the format's kind of a
> monster. PNG should be easier, depending on how good you want the
> compression to be. If you don't care too much about compression level, you
> simply zlib compress the data, write it out by image row/scanline, include
> appropriate header and chunk info, and you're done. I'll give a simple
> encoder a go if you think you could use it.

Years ago, one of the first programs I did in D was a raytracer. It
was a good test for OOP, structs, 3D vectors, foreach loops (which
were all the rage 4-5 years ago, even before ranges). It was nice and
fun, but I then discovered that, at the time, I had no easy way to
write my pixel 2D arrays to disk. I had to code a small BMP writer.
Nowdays, I'm playing with the idea to write a new tutorial for D,
using a raytracer and new D technics like CTFE / templates /
std.algorithms. This time, I would like to save the images as JPEG /
PNG.

I guess it's possible to wrap some C lib to do the work, but it's be
nice to have a D module to do that.

Anyway, nice work with the loader!


More information about the Digitalmars-d-announce mailing list