[reportlab-users] RGBA Colors
robin at reportlab.com
Thu Dec 3 05:08:04 EST 2009
Kevin D Smith wrote:
>>>>> I think I tripped across an issue with using alphas. I was drawing a box with borders (each component done with rect(...)). The background had an alpha set using an RGBA color, but the borders had an alpha value of 1. For whatever reason, the background and the top, right, and bottom borders came out with the alpha. The left border came out completely opaque. I'm not sure why just the left border came out opaque. I drew the objects in the order: background, left, top, right, bottom. In order to get the behavior I wanted, I had to save the state before drawing the background, then restore it afterward. This seems to be an issue with the alpha implementation even without the patch since I was setting the alpha explicitly for each of the components and it still happened.
>>>>> I've attached the test PDF that I created. The code is part of a much larger program so it would be tricky to separate it out, but I could probably work up a test case if needed.
>>> Here is a simplified test program the demonstrates the problem. You'll see that each color has an explicit alpha set. The top, right, and bottom borders come out with an alpha of 0.5 even though I am explicitly setting it to 1 for each of those. This program was run using an unpatched version of ReportLab, so this is an issue with the current implementation in the svn repository
>> unfortunately I don't think it's even an issue with our method.
>> you have put the setFillAlpha(1) inside a saveState/restoreState pair
> I did wonder if it was something that I was doing. Can you clarify why this is wrong? I thought the save and restore state methods were simply there to reset the canvas state back to what it was before doing an operation.
Looking at this again I think there is something wrong, I didn't notice that you
appear to be setting the alpha for every border line. Certainly the alpha is
only set twice once to 0.5 and once to 1 in the first drawn border line. I think
there must be a bug in the save/restore pair ie the first restore is not setting
alpha back to 0.5 (in our canvas variables). I'll take a look later today.
More information about the reportlab-users