[reportlab-users] RGBA Colors

Kevin D Smith Kevin.Smith at sixquickrun.com
Wed Dec 2 13:28:46 EST 2009


On Dec 2, 2009, at 12:02 PM, Robin Becker wrote:

> Kevin D Smith wrote:

>> On Dec 2, 2009, at 8:37 AM, Robin Becker wrote:

>>> 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.

Kevin D Smith
Kevin.Smith at sixquickrun.com





More information about the reportlab-users mailing list