Transparent Histogram

I saw this topic already on the forum but still it seems unsolved… I try again hoping that some ROOT guru can give me a hint.

I use root to produce lot of plots (last version on cygwin) and then save them as gif file. Then I import these plots on my Powerpoint presentation.

What I would like is the trasparant option working. I attach 4 files: First is a simple macro (test1.c) which produce a plot with the right trasparant option activate (SetFillStyle(4000) ) and saving on disk as gif file. The gif file produced (which is not trasperent…) The gif file modified using photopaint (this is the only way to get what I want). And one page presentation where the 2 files have been imported.

It’s clear that the GIF file produced by root only is not trasparent, while the one edited using photopaint is exactly what I need.

Because I’m using a lot of plots I really would appreciate the possibility to avoid the photpaint phase and have ROOT producing directly the trasparent file… is there any way?

Thank you for helping

Attilio (81.7 KB)

What we call “transparent” in ROOT is not the same a what is called “transparent” in a gif file. In ROOT it means that the background of a TPad (for instance) is not drawn as a filled polygon, that way what is already drawn in the window is not erased. In that sense this new TPad is transparent because you still can see what was displayed in the window before the TPad was drawn.
In gif files the transparency is a kind if special color. To change a color (white for instance) to transparent you can use a tool like “giftrans” (you can find it with google).

Under Win32, a small program that I used to run when I needed to make transparent gif’s was Lview (I believe you can also find it on google).

I noticed that setting the fill colour of pad and frame to -1 - rather than setting the fill style to 4000 - works (at least in the eps/ps case).

Here we are speaking about gif files … PS and EPS is an other matter !

OK, I have done a lot of test and I have few ideas… which didn’t work:

For GIF files (and also PNG) there are 4 byte which define the color of a pixel: the well known RGB and the alpha channel which allows for transarency.

Looking at the root code the key class is TASImage. This is the class which call the library AfterImage to process and write the canvas to a file. This class has a methods (GetArgbArray) which in principe allows for reading and writing value for ARGB on a pixel level. I checked the value for all the pixel and the alpha channel is always 255 (which means no transparency). I manually changed this value to 0 (full transparency) for all the white pixel of my canvas, read back to cross-check and then I wrote the file.

I tought to have solved my problem but it’s not working. What I don’t understand is that in the methods TASImage::WriteImage which is called to write the file, one of the parameter passed seems the right one:

  parms.png.flags = EXPORT_ALPHA;

I guess that this means “write the alpha channel to the file” but the script I have doesn’t work.

I’m stucked.

Any other comment/idea?


test1.c (1.8 KB)

I forgot to say that I know how to change the transparancy with external programs (2 were suggested: Lview and giftrans), I can add also photopaint and GIMP… this post is meant to find a way to do through root (avoiding to use external programs…)

Cheers again