Skip to content

Commit 9c79686

Browse files
committed
Deprecate tostring_rgb.
As noted previously, silently dropping alpha can be confusing. Also, directly accessing the buffer array is more efficient (it does not involve copying to a string buffer) and should cover most use cases.
1 parent 9700f74 commit 9c79686

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
``RendererAgg.tostring_rgb`` and ``FigureCanvasAgg.tostring_rgb``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
... are deprecated with no replacement.

lib/matplotlib/backends/backend_agg.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ def buffer_rgba(self):
280280
def tostring_argb(self):
281281
return np.asarray(self._renderer).take([3, 0, 1, 2], axis=2).tobytes()
282282

283+
@_api.deprecated("3.8")
283284
def tostring_rgb(self):
284285
return np.asarray(self._renderer).take([0, 1, 2], axis=2).tobytes()
285286

@@ -414,6 +415,7 @@ def get_renderer(self, cleared=False):
414415
self.renderer.clear()
415416
return self.renderer
416417

418+
@_api.deprecated("3.8")
417419
def tostring_rgb(self):
418420
"""
419421
Get the image as RGB `bytes`.

0 commit comments

Comments
 (0)