Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Fix wxcairo byteorder.#10429
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Fix wxcairo byteorder.#10429
Uh oh!
There was an error while loading.Please reload this page.
Conversation
DietmarSchwertberger commentedFeb 14, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I can only try this next weekend. If the bitmap has the right size already, I would suggest to re-use the buffer of the bitmap. |
It's really not that hard to do it in python, see e.g. alsohttps://github.com/matplotlib/matplotlib/pull/10436/files#diff-8b813556cc81b4a1a066f8d62e6519aeR28 which is perhaps an even better way to do this (and if both PRs come in I'll factor that out in a common function). I'm not too worried about inefficiency of the numpy version (pure C may beslightly more efficient but that's true for everything using numpy and this specific part is no worse than a bunch of other places where we use numpy). cairo can render to a user-supplied buffer (https://pycairo.readthedocs.io/en/latest/reference/surfaces.html#cairo.ImageSurface.create_for_data) but I'm not sure whether wx can expose access to the bitmap buffer? Note also that the cairo buffer requires specific data alignment (although the doc is not totally clear on whether alignment is only required for performance or also just for correctness). In any case I'd say the current cairo backend is so unefficient that an extra buffer copy is the last of my worries. |
It seems that wx.Bitmap does not expose the memory buffer, even though that would be an obvious feature. But there's this method which could be used if the size did not change:https://wxpython.org/Phoenix/docs/html/wx.Bitmap.html#wx.Bitmap.CopyFromBuffer Maybe one of the formats does already the required reordering:
In that case,
That's a bit inefficient as the Bitmap's memory will be initialized, but most of the time it saves allocation/deallocation. |
The seemingly normal
gives me (py2.7 wx 3.0.2.0; don't have phoenix installed now)
|
It might actually be trivial: there's
|
I can't easily test on Windows. Looks like you have access to a wider range of setups than I do, so feel free to push a better solution to this PR or open another one. |
OK, the version with |
Backport PR#10429 on branch v2.2.x
Uh oh!
There was an error while loading.Please reload this page.
PR Summary
I'm still not sure what I'm supposed to do with premultiplication (https://wxpython.org/Phoenix/docs/html/wx.Bitmap.html#wx.Bitmap.FromBufferRGBA is not very clear...) but at least this should get the byteorders correct).
See#10395 (comment).
PR Checklist