[Gambas-user] Gambas2 Grab in Gambas3

Fabien Bodard gambas.fr at ...626...
Wed Nov 9 18:53:54 CET 2016


2016-11-09 17:45 GMT+01:00 Richard Welch <richardpa608 at ...626...>:
> Fabien, thank you for your reply.
>
> There are snags with each of these...
>
> First approach:
>
> Although the DrawingArea is often fully visible on screen, sometimes it
> will be too big.
> I can think of a way round this but it is not very elegant!
>
> Second approach:
>
> The image is sometimes highly complex and can comprise hundreds of
> rectangles and lines as well as text.  I already do use generic
> functions as you describe, with variable-driven adjustments to cope with
> the differences between printing and screen display.  There are many
> places in the code which may build a display.
>
> I found in G2 that there were times when the image in a DrawingArea was
> not restored if it was partially covered by a window from another
> application and then exposed once more.  This mechanism enabled it to be
> restored easily without having to rebuild it from scratch.  Maybe the
> DrawingArea in G3 is more robust?
And why not using cached mode ?
>
> Richard
>
>
> On 08/11/16 17:31, Fabien Bodard wrote:
>> Well... there is two answers.
>>
>> First :
>>
>> Use the Desktop.ScreenShot Function
>> (http://gambaswiki.org/wiki/comp/gb.qt4/desktop/screenshot).
>> But your widget must be visible on the screen... This is why it is a
>> SCREEN shot.
>>
>>
>> Second :
>>
>> When you are drawing something in a drawingarea you use a generic
>> drawing function.
>>
>> Exemple :
>>
>>
>> Public sub DrawingArea_Draw()
>>
>> DrawARect()
>>
>> End
>>
>>
>> Private Sub DrawARect()
>>
>>    Paint.Brush = Brush.Color(Color.Yellow)
>>    Paint.Rectangle(10,10,Paint.Width - 20, Paint.Height - 20)
>>    Paint.Fill
>>
>> End
>>
>>
>> Public Function MakeImage(iWidth as integer, iHeight as integer) as Image
>>
>>    Dim hImage a new Image(iWidth, iHeight, Color.White)
>>
>>    Paint.Begin(hImage)
>>       DrawARect()
>>    Paint.End
>>
>> End
>>
>>
>> With that you have only one drawing function (DrawARect) able to draw
>> every where ... even on a printer. This is the way used in most of the
>> components too
>>
>> 2016-11-08 12:52 GMT+01:00 Richard Welch <richardpa608 at ...626...>:
>>> I need a simple way to copy the current image in a visible DrawingArea
>>> to a hidden PictureBox.
>>>
>>> The project was written in Gambas2, where a simple Grab method did the
>>> trick, but in G3 this does something different so the converted code
>>> does not function fully.
>>>
>>> FMain.pbxPicture.W = FMain.drwRep.W
>>> FMain.pbxPicture.H = FMain.drwRep.H
>>> FMain.pbxPicture.Background = FMain.drwRep.Background
>>> FMain.pbxPicture.Picture = FMain.drwRep.Grab()
>>>
>>> With what do I replace the Grab method?
>>>
>>> (The DrawingArea is painted in many different pieces of code, depending
>>> on context, so I want to make the change which will have the smallest
>>> impact possible on the source code)
>>>
>>> There is a gambas-user thread started around 19 April 2012.
>>> Is this fully relevant?
>>> Is this the /simplest/ answer?
>>> It would need some very tedious testing in my context.....
>>>
>>> ------------------------------------------------------------------------------
>>> Developer Access Program for Intel Xeon Phi Processors
>>> Access to Intel Xeon Phi processor-based developer platforms.
>>> With one year of Intel Parallel Studio XE.
>>> Training and support from Colfax.
>>> Order your platform today. http://sdm.link/xeonphi
>>> _______________________________________________
>>> Gambas-user mailing list
>>> Gambas-user at lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
>>
>
>
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user



-- 
Fabien Bodard




More information about the User mailing list