[Gambas-devel] gb3: possible addition of image "modes", as in The GIMP

Benoît Minisini gambas at ...1...
Sat Feb 12 20:42:17 CET 2011


> On 02/12/2011 02:01 PM, Benoît Minisini wrote:
> >> But in all seriousness, does that sound like a good idea? You can tell
> >> I've been trying to beef up gb's graphics capabilities, and that one
> >> might be the nail in the coffin to make it pretty robust.
> > 
> > I don't know. I won't do that now for sure.
> 
> I know you're busy fixing bugs, which I've always thought was more
> important than adding new features, so I understand. I'm pretty busy too
> and while learning C/C++ isn't something I have a lot of time to do I
> will try to get some groundwork done if possible by comparing gb3's Draw
> method code with GIMP's compositing code. I wish I did know C/C++
> because as a programmer it's a little embarrassing to keep asking for
> bugs to be fixed and features to be added without contributing much else.
> 
> > Please check the latest revision and your issues. You have fixes for your
> > bugs.
> 
> Awesome, I'm doing that right now. Thanks!

You must understand the internal behaviour of gb.image in Gambas to see the 
difficulties of what you want to do.

Each library has its own way of storing an image of memory: gb.gtk, gb.qt4, 
gb.image.imlib, gb.image.effect, gb.image, gb.v4l...

So that all these libraries can be used together, I decided that:

- gb.image will centralize the creation of Image objects.

- An Image has an internal format, that describes how images pixels are stored 
in memory. There are 14 formats supported at the moment.

- An Image can be -owned- by a component. It means that the component owns the 
data of the image, and is responsible of freeing it. The format of that image 
depends on the component. Qt4 uses its own format, GTK+ another one, and so 
on. Only gb.image can deal with the 14 formats (and not all of its methods!).

- An Image can be -temporarily- owned by another component. This is useful if 
you call a method that is implemented by one component only, but the image has 
been created by another component. That works only if the two components use 
the same internal format. Otherwise the ownership of the image is transferred 
to gb.image.

So, when you are using several components (gb.gtk + gb.image + gb.image.imlib 
+ gb.image.effect), you are subject to a lot of internal image conversions 
depending on what you do with your images: what methods you call, in which 
order, and so on.

So I suggest you take the previous into account, so that you can optimize your 
drawing routines by not doing too many internal conversions.

I added an Image.Format routine so that you can check when the format changes 
(it means that a conversion occured).

At the moment, there is no way to force an image to use the format of a 
specified component, so doing that optimization is tricky.

Regards,

-- 
Benoît Minisini




More information about the Devel mailing list