[Gambas-user] Using an Image in a PictureBox or help with my issue

Benoit Minisini gambas at ...1...
Sat Nov 29 20:25:21 CET 2008


On samedi 29 novembre 2008, John Harrold wrote:
> I'm no Gambas expert but as far as I understand you can't reference the
> image that way.
>
> you would need to do:
>
> DIM myImg as Image
> myImg=PicBox.Picture.Image
>
> Even then I think it will make a copy of the image and not be an alias. If
> you make changes to myImg to have them reflected in the original you would
> have to write back the image:
>
> PicBox.Picture.Image=myImg
>
> Dont think that makes things any easier.
>
> Budgieboy
>

To understand why thing are not easier, you must know that on X-Window 
systems, an image can be stored:

- In the program (the process that uses the GUI), an "Image" in Gambas.

- Or directly in the X-Window process, a "Picture" in Gambas.

Alas, you can only use X-Window drawing commands on Pictures, not on Images. 
On the contrary, you can only access individual pixels on Images, not on 
Pictures.

The Picture.Image and Image.Picture properties actually move the image data 
between the X-Window server and your program. It is a relatively heavy 
process, especially when the image is big. But there is no other way!

This is not really true with gb.gtk, as in gb.gtk the conversion is not done 
when you use the Picture.Image or Image.Picture property, but only when it is 
really needed. 

For example, if you really access individual pixels, then the image data will 
be moved to your process. Not when you will use the Picture.Image property.

I hope I was clear enough!

Regards,
-- 
Benoit Minisini




More information about the User mailing list