FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

2.x: Cairo backends cannot render images · Issue #6562 · matplotlib/matplotlib · GitHub

Repository navigation

2.x: Cairo backends cannot render images #6562

Description

In testing #6540, I can see that neither Cairo backend is able to render images correctly.

With GTKCairo:

Traceback (most recent call last):
  File ".../lib/matplotlib/backends/backend_gtk.py", line 438, in expose_event
    self._render_figure(self._pixmap, w, h)
  File ".../lib/matplotlib/backends/backend_gtk.py", line 426, in _render_figure
    self.figure.draw (self._renderer)
  File ".../lib/matplotlib/artist.py", line 63, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File ".../lib/matplotlib/figure.py", line 1129, in draw
    renderer, self, dsu, self.suppressComposite)
  File ".../lib/matplotlib/image.py", line 139, in _draw_list_compositing_images
    a.draw(renderer)
  File ".../lib/matplotlib/artist.py", line 63, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File ".../lib/matplotlib/axes/_base.py", line 2353, in draw
    mimage._draw_list_compositing_images(renderer, self, dsu)
  File ".../lib/matplotlib/image.py", line 163, in _draw_list_compositing_images
    flush_images()
  File ".../lib/matplotlib/image.py", line 147, in flush_images
    image_group[0].draw(renderer)
  File ".../lib/matplotlib/artist.py", line 63, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File ".../lib/matplotlib/image.py", line 464, in draw
    renderer.draw_image(gc, l, b, im)
  File ".../lib/matplotlib/backends/backend_cairo.py", line 180, in draw_image
    im.shape[1]*4)
TypeError: expected a writeable buffer object

With GTK3Cairo:

Traceback (most recent call last):
  File ".../lib/matplotlib/backends/backend_gtk3cairo.py", line 45, in on_draw_event
    self._render_figure(w, h)
  File ".../lib/matplotlib/backends/backend_gtk3cairo.py", line 34, in _render_figure
    self.figure.draw (self._renderer)
  File ".../lib/matplotlib/artist.py", line 63, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File ".../lib/matplotlib/figure.py", line 1129, in draw
    renderer, self, dsu, self.suppressComposite)
  File ".../lib/matplotlib/image.py", line 139, in _draw_list_compositing_images
    a.draw(renderer)
  File ".../lib/matplotlib/artist.py", line 63, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File ".../lib/matplotlib/axes/_base.py", line 2353, in draw
    mimage._draw_list_compositing_images(renderer, self, dsu)
  File ".../lib/matplotlib/image.py", line 163, in _draw_list_compositing_images
    flush_images()
  File ".../lib/matplotlib/image.py", line 147, in flush_images
    image_group[0].draw(renderer)
  File ".../lib/matplotlib/artist.py", line 63, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File ".../lib/matplotlib/image.py", line 464, in draw
    renderer.draw_image(gc, l, b, im)
  File ".../lib/matplotlib/backends/backend_cairo.py", line 180, in draw_image
    im.shape[1]*4)
TypeError: expected a writeable buffer object

Bisect points to 6595139, the backport of #5718.

Activity

  1. added this to the milestone on Jun 8, 2016
  2. QuLogic commented on Jun 8, 2016

    MemberAuthor

    Bisect on the original branch points to one of c9cae50, 3b7d1bb, 4a05302, 0aa222a, cf11aea, 0793aa2; perhaps that's narrow enough to figure it out.

    cc @mdboom

  3. jenshnielsen commented on Jun 14, 2016

    Member

    Interestingly enough this seems to be a python2 issue only. I can reproduce the error on python 2.7 but not on 3.5

    The following reproduces the error without matplotlib

    try:
        import cairocffi as cairo
    except:
        import cairo
    import numpy as np
    im = np.random.rand(100,100,4)
    cairo.ImageSurface.create_for_data(memoryview(im.flatten()),
                                       cairo.FORMAT_ARGB32,
                                       im.shape[1],
                                       im.shape[0], im.shape[1]*4)
  4. jenshnielsen commented on Jun 14, 2016

    Member

    So a in cairocffi this is fundamentally because ctypes.c_char.from_buffer_copy(memoryview(data))
    doesn't work. Regardless of the type of data. Numpy array, bytesarray ...

  5. jenshnielsen commented on Jun 14, 2016

    Member
  6. QuLogic commented on Jun 22, 2016

    MemberAuthor

    Fixed by #6602.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL