Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 35fe0a6

Browse filesBrowse files
committed
fix for issue #11316
1 parent 5e01393 commit 35fe0a6
Copy full SHA for 35fe0a6

File tree

Expand file treeCollapse file tree

1 file changed

+14
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-1
lines changed

‎lib/matplotlib/image.py

Copy file name to clipboardExpand all lines: lib/matplotlib/image.py
+14-1Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,16 +486,29 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
486486
raise ValueError("Invalid dimensions, got %s" % (A.shape,))
487487

488488
output = np.zeros((out_height, out_width, 4), dtype=A.dtype)
489+
output_a = np.zeros((out_height, out_width), dtype=A.dtype)
489490

490491
alpha = self.get_alpha()
491492
if alpha is None:
492-
alpha = 1.0
493+
alpha = 1
494+
495+
#resample alpha channel
496+
alpha_channel = A[...,3]
497+
_image.resample(
498+
alpha_channel, output_a, t, _interpd_[self.get_interpolation()],
499+
self.get_resample(), alpha,
500+
self.get_filternorm(), self.get_filterrad())
493501

502+
#resample rgb channels
503+
A = _rgb_to_rgba(A[...,:3])
494504
_image.resample(
495505
A, output, t, _interpd_[self.get_interpolation()],
496506
self.get_resample(), alpha,
497507
self.get_filternorm(), self.get_filterrad())
498508

509+
#recombine rgb and alpha channels
510+
output[...,3] = output_a
511+
499512
# at this point output is either a 2D array of normed data
500513
# (of int or float)
501514
# or an RGBA array of re-sampled input

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.