Re: [Lazarus] Alpha transparency on GTK2 widgetset

2014-01-05 Thread Juha Manninen
On Sun, Jan 5, 2014 at 3:47 AM, Bart bartjun...@gmail.com wrote:
 On 1/5/14, Michael Fuchs freepas...@ypa-software.de wrote:

 Will this patch go into the upcoming 1.2 Version?

 If you want to make sure it is at least considered, then add it to the
 merge requests on
 http://wiki.lazarus.freepascal.org/Lazarus_1.2_fixes_branch

I added it there right after committing. Now Martin has apparently
merged all pending commits there.
This was good timing. Lazarus 1.2 RC2 will come after a week. It will
be the last RC version and not many changes should be merged any more
after it.
I will see if I can fix some more issues targeted for 1.2 before that.

This GTK2 transparency fix was a major improvement. It affects also
the IDE itself and resolves many reports.

Juha

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Alpha transparency on GTK2 widgetset

2014-01-05 Thread zeljko

On 01/05/2014 02:47 AM, Bart wrote:

On 1/5/14, Michael Fuchs freepas...@ypa-software.de wrote:


Will this patch go into the upcoming 1.2 Version?


If you want to make sure it is at least considered, then add it to the
merge requests on
http://wiki.lazarus.freepascal.org/Lazarus_1.2_fixes_branch


Commiter should add it there (Juha in this case).

zeljko


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Alpha transparency on GTK2 widgetset

2014-01-05 Thread Marc Weustink

Nice job.
I had a different approach in mind, but that required a rewrite of 
gtk2devicecontext and a lot of cairo stuff. This effectively would be 
similar to gtk3 and take a lot of time.
After some initial rewrites, life changed and my time became limited. At 
the same time I heard rumors about a start of a gtk3 interface. So the 
interest of changing gtk2 dropped.

I'm glad you wrote this patch.

Marc



On 4-1-2014 19:22, Kostas Michalopoulos wrote:

I've made a patch that fixes the common cases (drawing an image with
an alpha channel with optional scaling and flipping). It can be
downloaded here:

http://bugs.freepascal.org/view.php?id=25491

Here is also an image showing what this fixes:

http://i.imgur.com/FH8wbX0.png

The test program (attached on the bug report) shows the toolbar,
image/icon and generated bitmap with TLazIntfImage/TRawImage. The
latter is drawn normally, stretched, flipped and both stretched and
flipped (as a side note the flipping doesn't seem to work under
Windows but the API seems to support it and the unpatched GTK2 also
supported that, so this is probably a bug in the Win32 widgetset).

Also the watches toolbar in Lazarus is shown before and after the
patch (notice the jaggies and missing pixels in the unpatched
version).


On Sat, Jan 4, 2014 at 4:38 PM, Juha Manninen juha.mannine...@gmail.com wrote:

On Sat, Jan 4, 2014 at 5:20 PM, Kostas Michalopoulos
badsectorac...@gmail.com wrote:

Looking in the code, I think i see the problem.
[...]


Impressive. I still mostly don't understand GTK2 bindings code.



For now i'm looking into trying to use the pixbuf when an image
operation is requested and see if that helps for solving the most
glaring issues with toolbars having no transparency and converting
between tbitmap to tlazintfimage and back losing the alpha channel. It
wont solve the issue of other operations (f.e. drawing a line, arc,
rectangle, etc over an image with alpha channel), but that would
require a complete rewrite of the GTK2 graphics context code to use
Cairo (which will be necessary for GTK3 anyway).


A patch for GTK2 bindings would surely be welcome.
Do you know that GTK3 bindings also exist. They have a different
architecture than GTK2 bindings.
Zeljan has started them but they are in alpha state now.
Contributions are welcome there, too.

Juha

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus




--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Alpha transparency on GTK2 widgetset

2014-01-05 Thread Kostas Michalopoulos
Yeah, the proper approach would be to make a Cairo-based
gtk2devicecontext implementation and it might still be a valid goal,
depending on how long the gtk3 interface will be in development (after
all it took years for the gtk2 interface to become the default in
Linux). Also i think that with gtk2 and gtk3 being incompatible, we'll
see gtk2 to remain around for a while, especially in non-GNOME-based
desktop environments (such as MATE, the GNOME2 fork, XFCE, etc).

But for the short term, this solves some common issues. Some of the
stuff mentioned in the related bugs seem to require a more solid
conversion to Cairo since currently there is a lot of information
lost with the conversions between pixmaps and pixbufs.


On Sun, Jan 5, 2014 at 3:56 PM, Marc Weustink m...@dommelstein.net wrote:
 Nice job.
 I had a different approach in mind, but that required a rewrite of
 gtk2devicecontext and a lot of cairo stuff. This effectively would be
 similar to gtk3 and take a lot of time.
 After some initial rewrites, life changed and my time became limited. At the
 same time I heard rumors about a start of a gtk3 interface. So the interest
 of changing gtk2 dropped.
 I'm glad you wrote this patch.

 Marc




 On 4-1-2014 19:22, Kostas Michalopoulos wrote:

 I've made a patch that fixes the common cases (drawing an image with
 an alpha channel with optional scaling and flipping). It can be
 downloaded here:

 http://bugs.freepascal.org/view.php?id=25491

 Here is also an image showing what this fixes:

 http://i.imgur.com/FH8wbX0.png

 The test program (attached on the bug report) shows the toolbar,
 image/icon and generated bitmap with TLazIntfImage/TRawImage. The
 latter is drawn normally, stretched, flipped and both stretched and
 flipped (as a side note the flipping doesn't seem to work under
 Windows but the API seems to support it and the unpatched GTK2 also
 supported that, so this is probably a bug in the Win32 widgetset).

 Also the watches toolbar in Lazarus is shown before and after the
 patch (notice the jaggies and missing pixels in the unpatched
 version).


 On Sat, Jan 4, 2014 at 4:38 PM, Juha Manninen juha.mannine...@gmail.com
 wrote:

 On Sat, Jan 4, 2014 at 5:20 PM, Kostas Michalopoulos
 badsectorac...@gmail.com wrote:

 Looking in the code, I think i see the problem.
 [...]


 Impressive. I still mostly don't understand GTK2 bindings code.


 For now i'm looking into trying to use the pixbuf when an image
 operation is requested and see if that helps for solving the most
 glaring issues with toolbars having no transparency and converting
 between tbitmap to tlazintfimage and back losing the alpha channel. It
 wont solve the issue of other operations (f.e. drawing a line, arc,
 rectangle, etc over an image with alpha channel), but that would
 require a complete rewrite of the GTK2 graphics context code to use
 Cairo (which will be necessary for GTK3 anyway).


 A patch for GTK2 bindings would surely be welcome.
 Do you know that GTK3 bindings also exist. They have a different
 architecture than GTK2 bindings.
 Zeljan has started them but they are in alpha state now.
 Contributions are welcome there, too.

 Juha

 --
 ___
 Lazarus mailing list
 Lazarus@lists.lazarus.freepascal.org
 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


 --
 ___
 Lazarus mailing list
 Lazarus@lists.lazarus.freepascal.org
 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus



 --
 ___
 Lazarus mailing list
 Lazarus@lists.lazarus.freepascal.org
 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Alpha transparency on GTK2 widgetset

2014-01-04 Thread Juha Manninen
On Sat, Jan 4, 2014 at 3:00 PM, Kostas Michalopoulos
badsectorac...@gmail.com wrote:
 What is the problem with (full) transparency in GTK2?

I have no idea.

 Is anyone working on this?

Unfortunately not. There are only few people who know the GTK2
bindings code. We would need more contributors for it.

Right now I am going through Mantis issues with target 1.2. There are
 270 of them. Uhhh!
Most of them must be postponed but maybe we can make it down to 250 before that.
Anybody who is interested, please look at the issues.
Find the ones already fixed and provide patches for the ones that are
not. Thanks. :)

Juha

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Alpha transparency on GTK2 widgetset

2014-01-04 Thread Kostas Michalopoulos
Looking in the code, I think i see the problem. The graphics
operations for GTK2 use GDK drawables which do not support alpha
blending. The bitmaps can be stored in 32bit pixbufs, but those are
not drawables and when a graphics operation is needed (drawing to a
canvas or blitting from one image to another), the graphics context
contains a generated pixmap (which only holds RGB data) and a mask
(which is 1bit). So all drawing operations are limited to 1bit
transparency.

However GDK does offer functionality for drawing pixbufs to drawables
but it is incompatible with the rest of the GDK graphics operations
(f.e. you can't draw an arc to a pixbuf so pixbufs cannot be used for
everything).

For now i'm looking into trying to use the pixbuf when an image
operation is requested and see if that helps for solving the most
glaring issues with toolbars having no transparency and converting
between tbitmap to tlazintfimage and back losing the alpha channel. It
wont solve the issue of other operations (f.e. drawing a line, arc,
rectangle, etc over an image with alpha channel), but that would
require a complete rewrite of the GTK2 graphics context code to use
Cairo (which will be necessary for GTK3 anyway).


On Sat, Jan 4, 2014 at 2:24 PM, Juha Manninen juha.mannine...@gmail.com wrote:
 On Sat, Jan 4, 2014 at 3:00 PM, Kostas Michalopoulos
 badsectorac...@gmail.com wrote:
 What is the problem with (full) transparency in GTK2?

 I have no idea.

 Is anyone working on this?

 Unfortunately not. There are only few people who know the GTK2
 bindings code. We would need more contributors for it.

 Right now I am going through Mantis issues with target 1.2. There are
 270 of them. Uhhh!
 Most of them must be postponed but maybe we can make it down to 250 before 
 that.
 Anybody who is interested, please look at the issues.
 Find the ones already fixed and provide patches for the ones that are
 not. Thanks. :)

 Juha

 --
 ___
 Lazarus mailing list
 Lazarus@lists.lazarus.freepascal.org
 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Alpha transparency on GTK2 widgetset

2014-01-04 Thread Kostas Michalopoulos
I've made a patch that fixes the common cases (drawing an image with
an alpha channel with optional scaling and flipping). It can be
downloaded here:

http://bugs.freepascal.org/view.php?id=25491

Here is also an image showing what this fixes:

http://i.imgur.com/FH8wbX0.png

The test program (attached on the bug report) shows the toolbar,
image/icon and generated bitmap with TLazIntfImage/TRawImage. The
latter is drawn normally, stretched, flipped and both stretched and
flipped (as a side note the flipping doesn't seem to work under
Windows but the API seems to support it and the unpatched GTK2 also
supported that, so this is probably a bug in the Win32 widgetset).

Also the watches toolbar in Lazarus is shown before and after the
patch (notice the jaggies and missing pixels in the unpatched
version).


On Sat, Jan 4, 2014 at 4:38 PM, Juha Manninen juha.mannine...@gmail.com wrote:
 On Sat, Jan 4, 2014 at 5:20 PM, Kostas Michalopoulos
 badsectorac...@gmail.com wrote:
 Looking in the code, I think i see the problem.
 [...]

 Impressive. I still mostly don't understand GTK2 bindings code.


 For now i'm looking into trying to use the pixbuf when an image
 operation is requested and see if that helps for solving the most
 glaring issues with toolbars having no transparency and converting
 between tbitmap to tlazintfimage and back losing the alpha channel. It
 wont solve the issue of other operations (f.e. drawing a line, arc,
 rectangle, etc over an image with alpha channel), but that would
 require a complete rewrite of the GTK2 graphics context code to use
 Cairo (which will be necessary for GTK3 anyway).

 A patch for GTK2 bindings would surely be welcome.
 Do you know that GTK3 bindings also exist. They have a different
 architecture than GTK2 bindings.
 Zeljan has started them but they are in alpha state now.
 Contributions are welcome there, too.

 Juha

 --
 ___
 Lazarus mailing list
 Lazarus@lists.lazarus.freepascal.org
 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Alpha transparency on GTK2 widgetset

2014-01-04 Thread Juha Manninen
On Sat, Jan 4, 2014 at 8:22 PM, Kostas Michalopoulos
badsectorac...@gmail.com wrote:
 I've made a patch that fixes the common cases (drawing an image with
 an alpha channel with optional scaling and flipping).

It works well and I applied it. Thanks!
I also attached many related bug reports to yours.
Could you and maybe other graphics programmers look at them.
I plan to resolve them all if they actually are resolved.

Earlier mainly Marc and Felipe have taken care of graphics but they
are busy with other things.
Your contribution was very much needed. Many people have reported
about the transparency issues but nobody provided a patch until you.

Juha

P.S.
I added you to the contributor list.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Alpha transparency on GTK2 widgetset

2014-01-04 Thread Michael Fuchs
Am 04.01.2014 19:22, schrieb Kostas Michalopoulos:
 I've made a patch that fixes the common cases (drawing an image with
 an alpha channel with optional scaling and flipping).

Wow, thank you very much for this patch. This bug was a steady annoyance.


Will this patch go into the upcoming 1.2 Version?

Michael




--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Alpha transparency on GTK2 widgetset

2014-01-04 Thread Bart
On 1/5/14, Michael Fuchs freepas...@ypa-software.de wrote:

 Will this patch go into the upcoming 1.2 Version?

If you want to make sure it is at least considered, then add it to the
merge requests on
http://wiki.lazarus.freepascal.org/Lazarus_1.2_fixes_branch

Bart

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus