[Gambas-devel] Flaw in GTK+ 2 / 3

Benoît Minisini gambas at ...1...
Wed Jan 2 17:21:18 CET 2013


Since a few revision, all drawings are done in gb.gtk with cairo ; as 
requested by GTK+, which has deprecated the old drawing API.

Fine. But there is a problem with images.

Images in GTK+ are managed by the GdkPixbuf class, which stores the 
image data in memory with the RGBA format. (As x86 is little endian, in 
memory you have actually R-G-B-A, and if you read it as a 32 bits 
integer, R is in the lowest bits and A in the highest).

But Cairo only handles images in the pre-multiplied BGRP format (like Qt4).

So each time you call Draw.Image() or Paint.DrawImage(), a costly 
conversion is needed.

I'm currently searching for some sort of workaround for this design flaw 
in GTK+.

That flaw has not been fixed in GTK+ 3 apparently. Why didn't they 
change GdkPixbuf so that it uses the same format as Cairo, or why didn't 
they deprecated GdkPixbuf for a new image class using that format? That 
is the question...

Any suggestion is welcome!

Benoît Minisini

More information about the Devel mailing list