[Gambas-user] How to save the contents of a drawingarea and a GLArea

Tobias Boege taboege at ...626...
Mon Mar 10 17:34:06 CET 2014


On Mon, 10 Mar 2014, martin p cristia wrote:
> Hi:
> 
> I need to save the contents of a drawingarea and a GLArea as a JPG, how 
> to do it?
> 

AFAIK, there is no way to access the internal buffer of a DrawingArea. So
what I do is: define a routine that fills my DrawingArea but is agnostic
about the drawing device (i.e. uses Paint.Device to refer to it instead of
a fixed object like the DrawingArea), let's call it DrawIt() and then I do:

  Public Sub dwgArea_Draw()
    DrawIt()
  End

and the drawing will be in the DrawingArea whenever needed. If you want to
save it you just do:

  Dim hPicture As New Picture(dwgArea.W, dwgArea.H)

  Paint.Begin(hPicture)
    DrawIt()
  Paint.End()
  hPicture.Save(...)

Does that help you? If not, you should be more precise about your code and
your experience with Gambas next time. My assumptions when writing this
were:

 - you are familiar with drawing in Gambas
 - you use the Draw event
 - your drawing is not a function of external variables, like time (so that
   you can call DrawIt() at any time in your program and produce the same
   result as before)

For the GLArea: no idea. Never used that but maybe you can adapt the idea
above.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list