[Gambas-user] Grabing an image from a drawingarea ? (Benoit Minisini)
serge bouc
serge.bouc at ...402...
Wed Sep 27 18:43:19 CEST 2006
>
> On Wednesday 27 September 2006 01:53, serge bouc wrote:
>> > Hello everybody,
>> >
>> > I am trying to use gambas to create a drawing software for some
>> > mathematical objects. My problem is the following : I can create
>> > images in large drawingareas (I mean larger than the screen),
>> > and view them in a scrollview. This works fine.
>> > The problem is now to save these images to disk : for this, I have
>> > to create an *image* in Gambas, but all I can do is "grab" a *picture*
>> > from the drawing area, and then convert it to an image. And when
>> > I do this, the image is clipped to the part of the drawingarea which
>> > is actually drawn on the screen, so I don't recover the whole image
>> > present on the drawingarea.
>> > And this seems to be a normal behaviour, since if I understand the
>> > documentation correctly, a "picture" in Gambas is drawn on the screen,
>> > whereas an "image" is in memory.
>>
>
> Grab() just returns what is visible on the screen.
>
>
>> > So is there a way to recover the image directly from the memory of
>> > a drawingarea, without drawing it to the screen, to avoid clipping ?
>> >
>>
>
> I think you use a cached DrawingArea. To be able to control the picture you
> display, you must used an uncached DrawingArea, have the Picture you display
> in a variable, and display it in the Draw event of the DrawingArea. Then you
> will be able to save the Picture easily.
>
> Regards,
>
> -- Benoit Minisini
Thanks for this suggestion. I am not sure if this is exactly what you
meant, but I did the following, which at least seems to solve
my problem :
- create a new picture called say, "mondessin".
- draw the figures I want with e.g.
draw.begin(mondessin)
draw.line(x,y,z,t)
...
draw.end
- and then show the figure on the dawing area called "graphe" with
draw.begin(graphe)
draw.picture(mondessin,0,0)
draw.end
It works : now I can easily save "mondessin" to disk.
It stills seems to me that this is a waste of time and memory, since
the drawingarea "graphe" has its own memory area (maybe not ?), and
since it is possible to draw the figure directly in *this* memory, with
draw.begin(graphe)
draw.line(...)
draw.end
The above procedure amounts to drawing the figure *somewhere else
in memory* (in the new picture "mondessin"), and next copy it where I want.
It would be easier and faster to have the possibility of accessing directly
to the memory area used by "graphe".
But I am far from a specialist of computer programming, so maybe the way
I imagine these objects is completely wrong.
Anyway, thanks again for this quick answer.
Best regards.
Serge.
More information about the User
mailing list