Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

cairo rendering for wx#9202

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
anntzer wants to merge17 commits intomatplotlib:masterfromanntzer:wxcairo
Closed
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
17 commits
Select commitHold shift + click to select a range
2abdcea
Qt5Cairo backend.
anntzerJun 15, 2017
d4957ec
Qt4Cairo backend.
anntzerJun 18, 2017
d2f2bc0
Update backends docs.
anntzerJun 18, 2017
f884ffa
Update backends API docs.
anntzerJun 18, 2017
bcb08e9
Let cairo track surface size; fix Pyside refcnt bug.
anntzerJun 19, 2017
2eac3fa
Fix mandelbrot example.
anntzerJun 20, 2017
138ba58
Make sure only one cairo binding is ever used; fix docs.
anntzerJun 20, 2017
d96d104
No need to process_updates in gtk3.
anntzerJul 23, 2017
5087c05
Qt dpi handling should be renderer-agnostic.
anntzerAug 1, 2017
89a87d0
Fix vector output from cairo.
anntzerAug 3, 2017
56854ae
In QtCairo, also save figures using cairo.
anntzerAug 3, 2017
ab61783
Fix doc builds.
anntzerAug 26, 2017
8946c38
Fix hidpi in qt5cairo.
anntzerDec 29, 2017
89a3ca8
Cleanup gtk3cairo.
anntzerSep 19, 2017
ecc9143
Cleanup wxagg.
anntzerSep 18, 2017
28ccff8
Unify wx toolbars.
anntzerSep 18, 2017
82e8360
WXCairo backend.
anntzerSep 18, 2017
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
PrevPrevious commit
NextNext commit
Let cairo track surface size; fix Pyside refcnt bug.
  • Loading branch information
@anntzer
anntzer committedJan 9, 2018
commitbcb08e93a7a82441d58bc2ed3035a1f4a3db6558
11 changes: 1 addition & 10 deletionslib/matplotlib/backends/backend_cairo.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,14 +102,11 @@ def __init__(self, dpi):

def set_ctx_from_surface(self, surface):
self.gc.ctx = cairo.Context(surface)
self.set_width_height(surface.get_width(), surface.get_height())

def set_width_height(self, width, height):
self.width = width
self.height = height
self.matrix_flipy = cairo.Matrix(yy=-1, y0=self.height)
# use matrix_flipy for ALL rendering?
# - problem with text? - will need to switch matrix_flipy off, or do a
# font transform?

def _fill_and_stroke(self, ctx, fill_c, alpha, alpha_overrides):
if fill_c is not None:
Expand DownExpand Up@@ -303,11 +300,6 @@ def _draw_mathtext(self, gc, x, y, s, prop, angle):

ctx.restore()

def flipy(self):
return True
#return False # tried - all draw objects ok except text (and images?)
# which comes out mirrored!

def get_canvas_width_height(self):
return self.width, self.height

Expand DownExpand Up@@ -503,7 +495,6 @@ def _save(self, fo, fmt, **kwargs):

# surface.set_dpi() can be used
renderer = RendererCairo(self.figure.dpi)
renderer.set_width_height(width_in_points, height_in_points)
renderer.set_ctx_from_surface(surface)
ctx = renderer.gc.ctx

Expand Down
8 changes: 4 additions & 4 deletionslib/matplotlib/backends/backend_qt5agg.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -78,15 +78,15 @@ def paintEvent(self, e):
reg = self.copy_from_bbox(bbox)
buf = reg.to_string_argb()
qimage = QtGui.QImage(buf, w, h, QtGui.QImage.Format_ARGB32)
# Adjust the buf reference count to work around a memory leak bug
# in QImage under PySide on Python 3.
if QT_API == 'PySide' and six.PY3:
ctypes.c_long.from_address(id(buf)).value = 1
if hasattr(qimage, 'setDevicePixelRatio'):
# Not available on Qt4 or some older Qt5.
qimage.setDevicePixelRatio(self._dpi_ratio)
origin = QtCore.QPoint(l, self.renderer.height - t)
painter.drawImage(origin / self._dpi_ratio, qimage)
# Adjust the buf reference count to work around a memory
# leak bug in QImage under PySide on Python 3.
if QT_API == 'PySide' and six.PY3:
ctypes.c_long.from_address(id(buf)).value = 1

self._draw_rect_callback(painter)

Expand Down
10 changes: 7 additions & 3 deletionslib/matplotlib/backends/backend_qt5cairo.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
from . import backend_cairo # Keep the RendererCairo class swappable.
from .backend_qt5 import QtCore, QtGui, _BackendQT5, FigureCanvasQT
from .qt_compat import QT_API


class FigureCanvasQTCairo(FigureCanvasQT):
Expand All@@ -13,11 +14,14 @@ def paintEvent(self, event):
surface = backend_cairo.cairo.ImageSurface(
backend_cairo.cairo.FORMAT_ARGB32, width, height)
self._renderer.set_ctx_from_surface(surface)
# This should be really done by set_ctx_from_surface...
self._renderer.set_width_height(width, height)
self.figure.draw(self._renderer)
qimage = QtGui.QImage(surface.get_data(), width, height,
buf = surface.get_data()
qimage = QtGui.QImage(buf, width, height,
QtGui.QImage.Format_ARGB32_Premultiplied)
# Adjust the buf reference count to work around a memory leak bug in
# QImage under PySide on Python 3.
if QT_API == 'PySide' and six.PY3:
ctypes.c_long.from_address(id(buf)).value = 1
painter = QtGui.QPainter(self)
painter.drawImage(0, 0, qimage)
self._draw_rect_callback(painter)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp