Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i create an offscreen image in smart mobile studio?

When working with graphics, how do i create an offscreen image in smart mobile studio? I want to paint to create the image, paint to the canvas - and then copy that graphics onto the display in a game project.

like image 359
Jon Lennart Aasenden Avatar asked Oct 07 '22 19:10

Jon Lennart Aasenden


1 Answers

http://op4js.optimalesystemer.no/2012/01/10/how-do-i-move-graphics-from-the-canvas-to-an-image/

So in short:

var image  := TW3Image.Create(self);
//create temp graphic and canvas to draw on
var graph  := TW3GraphicContext.Create(NIL);
graph.Allocate(image.Width, image.Height);
var canvas := TW3Canvas.Create(graph);
// Draw some text on the canvas
canvas.font:='10pt verdana';
canvas.FillStyle:='rgb(255,255,255)';
canvas.FillTextF('This was generated on a canvas!',10,20,MAXINT);
//You can load it in as a picture
image.LoadFromUrl(canvas.toDataUrl(''));
like image 137
André Avatar answered Oct 13 '22 00:10

André