8000 Colormap alpha by efiring · Pull Request #660 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Colormap alpha #660

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

Merged
merged 7 commits into from
Jan 8, 2012
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
image: modify alpha premultiply to work with modified to_rgba
The earlier version of the premultiplication step did not work
with numpy 2, and required additional dtype conversion steps in
the common case of a colormapped image.
  • Loading branch information
efiring committed Jan 7, 2012
commit 95e6fcda1cecff1e9dd6c3d264bbb09e240d08a2
9 changes: 7 additions & 2 deletions lib/matplotlib/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,14 @@ def _get_unsampled_image(self, A, image_extents, viewlim):
im.is_grayscale = False
else:
if self._rgbacache is None:
x = self.to_rgba(self._A, bytes=True)
x = self.to_rgba(self._A, bytes=False)
# Avoid side effects: to_rgba can return its argument
# unchanged.
if np.may_share_memory(x, self._A):
x = x.copy()
# premultiply the colors
x[...,0:3] *= x[...,3:4] / 255.0
x[...,0:3] *= x[...,3:4]
x = (x * 255).astype(np.uint8)
self._rgbacache = x
else:
x = self._rgbacache
Expand Down
0