Add IPython display support#389
Merged
Merged
Conversation
Member
|
This will need to be rebased to account for the recent removal of Other than the image data in the example notebook, I have no big issues with this change. |
dc407ac to
35c9bdd
Compare
Contributor
Author
|
This now has tests, so presuming test pass OK, this is probably ready for a proper review. |
jwiggins
approved these changes
Mar 11, 2021
Member
jwiggins
left a comment
There was a problem hiding this comment.
LGTM. Please strip the data out of the notebook before merging.
Comment on lines
+875
to
+886
| pixels = self.gc.array | ||
| if self.pix_format.startswith('bgra'): | ||
| # Data is BGRA; Convert to RGBA | ||
| data = np.empty(pixels.shape, dtype=np.uint8) | ||
| data[..., 0] = pixels[..., 2] | ||
| data[..., 1] = pixels[..., 1] | ||
| data[..., 2] = pixels[..., 0] | ||
| data[..., 3] = pixels[..., 3] | ||
| else: | ||
| data = pixels | ||
|
|
||
| return Image.fromarray(data, 'RGBA') |
Member
There was a problem hiding this comment.
It hasn't been a problem yet, but we might want to add support for formats without alpha at some point.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds two things:
_repr_svg_and_repr_png_respectively).to_imagemethod for Agg and Celiagg backends which generates a PIL/Pillow Image object from the GC.It also includes a drive-by fix for saving RGBA vs. BGRA format Celiagg graphics contexts, which fixes #304.