-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
RendererAgg.tostring_rgb merely truncates alpha #5336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
There is an algorithm for the solution found on stackoverflow http://stackoverflow.com/questions/2049230/convert-rgba-color-to-rgb, which agrees with the solution given on wikipedia. The solution can be easily modified for our case where our RGB values are from 0-255 as opposed to 0-1 as found in wikipedia:
I took a quick look at
Unfortunately there is no mechanism to specify the background color, which would require extending the Py wrapper to include an optional parameter for specifying the background color. But eitherway, it seems unlikely to hope for getting the proper |
Should we just get rid of |
I don't know. I guess I had a hope that we could fix My Looking at the source, it seems that simply passing a 3-dimensional array to write_png will default to 24-bit RGB algorithms: Line 112 in c32bde5
I thought that we could possibly add a kwarg to force RGB (as I believe the conversion has to be done here, or as an init variable to the renderer?) here:
tostring_rgb , or really, a to_rgb_flattened or something to pass along to write_png .
I don't know, I'd have to trace through the steps some more as I'm still trying to learn how all of this works, and there probably is a better way. |
I just encountered this issue. I'm using I see this issue was opened in 2015, so clearly not many people are getting bitten by it. Is there another way that I'm missing to extract the pixels of a Figure (without saving it to a file and then loading the file)? |
You can probably do something like |
@anntzer Good idea. Solved the problem. Thanks! |
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
As suggested #5324 (comment), it might be a good idea to have it actually blend onto some background color instead.
The text was updated successfully, but these errors were encountered: