GUI library for D
Michel Fortin
michel.fortin at michelf.com
Wed Apr 6 08:35:30 PDT 2011
On 2011-04-06 10:25:42 -0400, Matthias Pleh <jens at konrad.net> said:
> Am 06.04.2011 14:49, schrieb Michel Fortin:
>> final class Bitmap(Color) : Image {
>> void opIndexAssign(int x, int y, Color color) {
>> pixels[y * width + x] = Color(color);
>> }
>>
>> size_t width, height;
>> Color[] pixels;
>> }
>
> Yep, exactly. I would implement it as template.
>
> About the render backend, Nick mentioned.
> In the first step, I would just draw all objects (lines, boxes,
> circles) to the buffer and then render it as image per gdi/xlib.
>
> this render should ideally be in a single file, so other backends can
> be implemented (gdi/direct2d/cairo/xcb/cocoa/..)
Since you're at it, have you considered making the API flexible enough
so it could support vector images too?
// return an object derived from image depending on the actual file type
Image im = loadImage("filename");
// creating a bitmap for on-screen rendering
auto bitmap = new Bitmap!RGBColor(im.width, im.height);
// base image class has a virtual function to draw itself on a bitmap at
// a given location, so it's easy to draw it on screen
im.draw(10, 10, bitmap);
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list