bmp/png libs?
Adam D. Ruppe
destructionator at gmail.com
Sat May 16 21:20:48 PDT 2009
Well, I've been doing some more work on it today. The biggest new function
is BMP.display(), which pops up a window displaying the bmp on the screen.
I also cleaned up the code a little, put in a preliminary load from file
function, and added some ddocs.
Download here:
http://arsdnet.net/bmpstuff.zip
DDoc here:
http://arsdnet.net/bmp.html
See also the bottom of bmp.d for some examples (also see the commented code in that main function).
A short example program:
----
import bmp;
void main() {
auto i = new BMP("picture.bmp"); // note this MUST be a 24 bit bmp
i.display(); // show it on screen!
i.setPixel(10, 10, Color(255,255,255)); // add a white pixel at 10,10
i.save("hacked.bmp"); // save it back to a file
}
-------
Writing to a file is useful, but showing it right there is really cool.
The display function I've written is still somewhat buggy and is very slow on
X11, but works reasonably well on Windows. (I really need to brush up on my
xlib.)
But what I imagine this being useful for is whipping up quick graphs and such.
Saving to a bmp is fun, but this seems useful too.
I also had to read the PNG spec yesterday for work, and am starting on adding
basic png read/write support too. I already have the chunks read into D
structs for easy processing (not in that zip), but haven't coded the
compression, so it can't actually work with the image data.
I probably won't get around to finishing this until at least next weekend.
Off topic:
I also have some D + C code for playing and doing light work with .wav
and .mid files too. As I have the time, I'll see about posting that somewhere
too. These basic file formats are nice things to have.
--
Adam D. Ruppe
http://arsdnet.net
More information about the Digitalmars-d
mailing list