www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Need help with DLANGUI

reply "Eric" <eric makechip.com> writes:
I have been trying out dlanui, and I am able to create an image
with FreeImage and display it with an ImageWidget.  However this
requires that I write the image out to disk, and then load it 
again
to display it.  Is there any way I can update or create the image
in memory without going to disk?

Thanks,

Eric
Feb 23 2015
parent reply "Vadim Lopatin" <coolreader.org gmail.com> writes:
On Monday, 23 February 2015 at 19:41:30 UTC, Eric wrote:
 I have been trying out dlanui, and I am able to create an image
 with FreeImage and display it with an ImageWidget.  However this
 requires that I write the image out to disk, and then load it 
 again
 to display it.  Is there any way I can update or create the 
 image
 in memory without going to disk?

 Thanks,

 Eric
Hello, Sorry for delayed answer. Is your question still actual? You can use something like // create RGBA8888 drawing buffer ColorDrawBuffer buf = new ColorDrawBuffer(width, height); // copy pixels into buf from your custom image // ......... // put into DrawBufRef DrawBufRef imageDrawBuf = buf; // create image drawable DrawableRef myCustomImageDrawable = new ImageDrawable(imageDrawBuf); // set drawable of ImageWidget imageWidget.drawable = myCustomImageDrawable; There was code in dlangui.graphics.image which could copy FreeImage images to ColorDrawBuf, but in recent version it's removed. You can check github revision history to get proper code. BTW, why do you need FreeImage to create image? Isn't it just possible inside dlangui?
Mar 24 2015
parent reply "Eric" <eric makechip.com> writes:
 BTW, why do you need FreeImage to create image? Isn't it just 
 possible inside dlangui?
This is basically my question. Is there a drawing engine that can draw lines, circles, and shapes as well as single pixels? -Eric
Mar 24 2015
next sibling parent Rikki Cattermole <alphaglosined gmail.com> writes:
On 25/03/2015 2:31 a.m., Eric wrote:
 BTW, why do you need FreeImage to create image? Isn't it just possible
 inside dlangui?
This is basically my question. Is there a drawing engine that can draw lines, circles, and shapes as well as single pixels? -Eric
If you have some way to draw you might be interested in my LineGraph[0]. It only handles getting coordinates to draw by. But I don't see why shapes couldn't be added. [0] https://github.com/Devisualization/util/blob/master/source/core/devisualization/util/core/linegraph.d
Mar 24 2015
prev sibling parent "Vadim Lopatin" <coolreader.org gmail.com> writes:
On Tuesday, 24 March 2015 at 13:31:06 UTC, Eric wrote:
 BTW, why do you need FreeImage to create image? Isn't it just 
 possible inside dlangui?
This is basically my question. Is there a drawing engine that can draw lines, circles, and shapes as well as single pixels? -Eric
Hello, I've implemented CanvasWidget today as convenient way of custom drawing, and added drawPixel and drawLine methods to DrawBuf. See example1 / Canvas tab. Sample code: CanvasWidget canvas = new CanvasWidget("canvas"); canvas.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT); canvas.onDrawListener = delegate(CanvasWidget canvas, DrawBuf buf, Rect rc) { buf.fill(0xFFFFFF); int x = rc.left; int y = rc.top; buf.fillRect(Rect(x+20, y+20, x+150, y+200), 0x80FF80); buf.fillRect(Rect(x+90, y+80, x+250, y+250), 0x80FF80FF); canvas.font.drawText(buf, x + 40, y + 50, "fillRect()"d, 0xC080C0); buf.drawFrame(Rect(x + 400, y + 30, x + 550, y + 150), 0x204060, Rect(2,3,4,5), 0x80704020); canvas.font.drawText(buf, x + 400, y + 5, "drawFrame()"d, 0x208020); canvas.font.drawText(buf, x + 300, y + 100, "drawPixel()"d, 0x000080); for (int i = 0; i < 80; i++) buf.drawPixel(x+300 + i * 4, y+140 + i * 3 % 100, 0xFF0000 + i * 2); canvas.font.drawText(buf, x + 200, y + 250, "drawLine()"d, 0x800020); for (int i = 0; i < 40; i+=3) buf.drawLine(Point(x+200 + i * 4, y+290), Point(x+150 + i * 7, y+420 + i * 2), 0x008000 + i * 5); };
Mar 24 2015