After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 591525 - Transparent objects by adding alpha to Color structure.
Transparent objects by adding alpha to Color structure.
Status: RESOLVED FIXED
Product: dia
Classification: Other
Component: general
devel
Other All
: Normal enhancement
: 0.98
Assigned To: Dia maintainers
Dia maintainers
Depends on:
Blocks:
 
 
Reported: 2009-08-12 04:07 UTC by Jason Childs
Modified: 2011-04-03 16:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Adds transparency to objects (530.60 KB, patch)
2009-08-12 04:09 UTC, Jason Childs
needs-work Details | Review
Cleans up some unnecessary printf's from the first patch (1.24 KB, patch)
2009-08-12 04:10 UTC, Jason Childs
none Details | Review
Example dia file with new Color objects with alpha transparency!!! (957 bytes, application/octet-stream)
2009-08-12 04:30 UTC, Jason Childs
  Details
Example cairo pdf export file with new Color objects with alpha transparency!!! (5.42 KB, application/pdf)
2009-08-12 04:31 UTC, Jason Childs
  Details
Example png file with new Color objects with alpha transparency!!! (10.35 KB, image/png)
2009-08-12 04:31 UTC, Jason Childs
  Details
Example svg file with new Color objects with alpha transparency!!! (7.95 KB, image/svg+xml)
2009-08-12 04:32 UTC, Jason Childs
  Details
Cleaned patch with no whitespace changes (62.51 KB, patch)
2009-08-20 01:05 UTC, Jason Childs
none Details | Review
Opacity support for SVG import and custom shapes (8.69 KB, patch)
2009-08-22 10:25 UTC, Hans Breuer
none Details | Review
Emulate color.alpha with gdk_gc_set_stipple() (3.14 KB, patch)
2009-08-22 14:09 UTC, Hans Breuer
none Details | Review
DiaGdkRenderer on render-test-alpha.dia (39.77 KB, image/png)
2009-08-22 14:17 UTC, Hans Breuer
  Details
PyDia_set_Color() allow 3 or 4 tuple to set color.alpha (1.32 KB, patch)
2009-08-22 17:23 UTC, Jason Childs
none Details | Review

Description Jason Childs 2009-08-12 04:07:22 UTC
Dia should allow for cairo transparency to be used by objects and also save in the native file format.  Any import/export/renderer's that don't support transparency should use an alpha of 1.0 to default to normal behavior. 

Other information:
Patch will be attached to this bug!
Comment 1 Jason Childs 2009-08-12 04:09:37 UTC
Created attachment 140517 [details] [review]
Adds transparency to objects

This closes out bug #402113...
Cleanup patch to remove a couple printf's to follow...
Comment 2 Jason Childs 2009-08-12 04:10:23 UTC
Created attachment 140518 [details] [review]
Cleans up some unnecessary printf's from the first patch
Comment 3 Jason Childs 2009-08-12 04:12:30 UTC
These changes can also be pulled from github : http://github.com/oblivian/dia/
Comment 4 Jason Childs 2009-08-12 04:30:28 UTC
Created attachment 140522 [details]
Example dia file with new Color objects with alpha transparency!!!
Comment 5 Jason Childs 2009-08-12 04:31:00 UTC
Created attachment 140523 [details]
Example cairo pdf export file with new Color objects with alpha transparency!!!
Comment 6 Jason Childs 2009-08-12 04:31:25 UTC
Created attachment 140524 [details]
Example png file with new Color objects with alpha transparency!!!
Comment 7 Jason Childs 2009-08-12 04:32:23 UTC
Created attachment 140525 [details]
Example svg file with new Color objects with alpha transparency!!!
Comment 8 Hans Breuer 2009-08-18 17:41:08 UTC
Comment on attachment 140517 [details] [review]
Adds transparency to objects

the patch contains an unbearable amount of pure whitespace changes (I'd estimate about 80%).
Comment 9 Jason Childs 2009-08-18 18:00:42 UTC
Sorry about that Hans, I had eclipse on auto whitespace fix for another project and didn't turn it off.  I'll fix it up and resubmit.
Comment 10 Jason Childs 2009-08-20 01:05:36 UTC
Created attachment 141203 [details] [review]
Cleaned patch with no whitespace changes
Comment 11 Hans Breuer 2009-08-21 13:14:06 UTC
Thanks for the patch an the cleanup. I now have a local branch testing it, with also some follow-up modification, e.g. regarding bug #591911 and (stroke|fill)-opacity. 
There are some more things I want to tackle, but the main reason I hesitate to push it to master is the lack of alpha support for the main display renderer: DiaGdkRenderer. With bug #568168 there is the idea of DiaRenderer::is_capable_to(RENDER_ALPHA) but I can't come up with a good fallback behaviour for alpha not being supported.

Here are my notes of other things to check:

bindings/dia-properties.cpp 
  allow to set rgb(a?)?
lib/dia_svg.c
  missing handling for opacity (roundtrip check!)
  also check shape-export with alpha and use of shapes with alpha
lib/diasvgrenderer.c 
  fill-opacity: %f; stroke-width: %s", colour->alpha
  use g_ascii_formatd and stroke-opacity => DONE
lib/widgets.c(dia_color_selector_create_string_item)
  do we really want the alpha part in the string?
gtk_color_selection_get_current_color
  superfluous printf() => REMOVED
plug-ins/cairo/diacairo-renderer.c 
  there was an if differening in alpha 0:1, now both get renderer->dia->bg_color.alpha
plug-ins/python/pydia-property.c 
  it should be possible to set from tuple of 3 or 4, currently no alpha possible to set?
plug-ins/svg/svg-import.c 
  should turn (stroke|fill)-opacity into alpha
Comment 12 Hans Breuer 2009-08-22 10:25:54 UTC
Created attachment 141391 [details] [review]
Opacity support for SVG import and custom shapes
Comment 13 Hans Breuer 2009-08-22 14:09:49 UTC
Created attachment 141420 [details] [review]
Emulate color.alpha with gdk_gc_set_stipple()

Of course the emulation is far from perfect, but maybe it is good enough to dispel concerns ;)
Comment 14 Hans Breuer 2009-08-22 14:17:04 UTC
Created attachment 141421 [details]
DiaGdkRenderer on render-test-alpha.dia

The emulation of two overlapping transparent objects is especially weak.
Comment 15 Jason Childs 2009-08-22 17:23:55 UTC
Created attachment 141434 [details] [review]
PyDia_set_Color() allow 3 or 4 tuple to set color.alpha
Comment 16 Hans Breuer 2009-10-11 13:48:26 UTC
I still hesitate to merge the 'alpha' stuff to master, but the recently rebased branch is now available at http://git.gnome.org/cgit/dia/log/?h=alpha

Things stopping me to merge:
 - the selection of the diagram background color must not include transparency
(see my comment in bug #402113 
 and http://bugzilla-attachments.gnome.org/attachment.cgi?id=141350 )

 - there should be a way to tweak the opacity independent of the color and
 the recent color menu should not include the alpha part. This would allow
 to change the transparency of multiple different colored objects without
 destroying the color value. At least my playing with the opacity of the
 objects involved quite some changes to get the desired effect. Doing so
 did "pollute" the recent color menu
Comment 17 Hans Breuer 2011-04-03 16:54:19 UTC
I've implmented the missing piece today and merged the resilt back to master branch. Thanks for the patches.

http://git.gnome.org./browse/dia/commit/?id=782c60e0767203ac7ee502fec3a1dca29fdd8129