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 68c108c

Browse filesBrowse files
committed
Merged revisions 5109-5121 via svnmerge from
https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_91_maint ........ r5119 | jdh2358 | 2008-05-06 10:34:32 -0400 (Tue, 06 May 2008) | 1 line use pngs for wx icons ........ r5120 | mdboom | 2008-05-06 11:25:04 -0400 (Tue, 06 May 2008) | 2 lines Fix blitting in Qt backends (which need ARGB, not RGBA) ........ r5121 | mdboom | 2008-05-06 11:30:09 -0400 (Tue, 06 May 2008) | 2 lines Forgot CHANGELOG ........ svn path=/trunk/matplotlib/; revision=5122
1 parent 60388a7 commit 68c108c
Copy full SHA for 68c108c

File tree

Expand file treeCollapse file tree

5 files changed

+36
-4
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+36
-4
lines changed

‎CHANGELOG

Copy file name to clipboardExpand all lines: CHANGELOG
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2008-05-06 Fix strange colors when blitting in QtAgg and Qt4Agg - MGD
2+
13
2008-05-05 pass notify_axes_change to the figure's add_axobserver
24
in the qt backends, like we do for the other backends.
35
Thanks Glenn Jones for the report - DSD

‎lib/matplotlib/backends/backend_qt4agg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qt4agg.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def paintEvent( self, e ):
114114
h = int(t) - int(b)
115115
t = int(b) + h
116116
reg = self.copy_from_bbox(bbox)
117-
stringBuffer = reg.to_string()
117+
stringBuffer = reg.to_string_argb()
118118
qImage = QtGui.QImage(stringBuffer, w, h, QtGui.QImage.Format_ARGB32)
119119
pixmap = QtGui.QPixmap.fromImage(qImage)
120120
p = QtGui.QPainter( self )

‎lib/matplotlib/backends/backend_qtagg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qtagg.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def paintEvent( self, e ):
119119
w = int(r) - int(l)
120120
h = int(t) - int(b)
121121
reg = self.copy_from_bbox(bbox)
122-
stringBuffer = reg.to_string()
122+
stringBuffer = reg.to_string_argb()
123123
qImage = qt.QImage(stringBuffer, w, h, 32, None, 0, qt.QImage.IgnoreEndian)
124124
self.pixmap.convertFromImage(qImage, qt.QPixmap.Color)
125125
p.drawPixmap(qt.QPoint(l, self.renderer.height-t), self.pixmap)

‎src/_backend_agg.cpp

Copy file name to clipboardExpand all lines: src/_backend_agg.cpp
+30-1Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,34 @@ Py::Object BufferRegion::to_string(const Py::Tuple &args) {
9090
return Py::String(PyString_FromStringAndSize((const char*)data, height*stride), true);
9191
}
9292

93+
Py::Object BufferRegion::to_string_argb(const Py::Tuple &args) {
94+
// owned=true to prevent memory leak
95+
Py_ssize_t length;
96+
char* pix;
97+
char* begin;
98+
char* end;
99+
char tmp;
100+
101+
PyObject* str = PyString_FromStringAndSize((const char*)data, height*stride);
102+
if (PyString_AsStringAndSize(str, &begin, &length)) {
103+
throw Py::TypeError("Could not create memory for blit");
104+
}
105+
106+
pix = begin;
107+
end = begin + (height * stride);
108+
while (pix != end) {
109+
// Convert rgba to argb
110+
tmp = pix[3];
111+
pix[3] = pix[2];
112+
pix[2] = pix[1];
113+
pix[1] = pix[0];
114+
pix[0] = pix[3];
115+
pix += 4;
116+
}
117+
118+
return Py::String(str, true);
119+
}
120+
93121
GCAgg::GCAgg(const Py::Object &gc, double dpi) :
94122
dpi(dpi), isaa(true), linewidth(1.0), alpha(1.0),
95123
dashOffset(0.0)
@@ -210,7 +238,6 @@ GCAgg::_set_clip_path( const Py::Object& gc) {
210238
}
211239
}
212240

213-
214241
const size_t
215242
RendererAgg::PIXELS_PER_INCH(96);
216243

@@ -1707,6 +1734,8 @@ void BufferRegion::init_type() {
17071734

17081735
add_varargs_method("to_string", &BufferRegion::to_string,
17091736
"to_string()");
1737+
add_varargs_method("to_string_argb", &BufferRegion::to_string_argb,
1738+
"to_string_argb()");
17101739
}
17111740

17121741

‎src/_backend_agg.h

Copy file name to clipboardExpand all lines: src/_backend_agg.h
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class BufferRegion : public Py::PythonExtension<BufferRegion> {
103103
bool freemem;
104104

105105
Py::Object to_string(const Py::Tuple &args);
106+
Py::Object to_string_argb(const Py::Tuple &args);
106107
static void init_type(void);
107108

108109
virtual ~BufferRegion() {
@@ -138,7 +139,7 @@ class GCAgg {
138139
double dashOffset;
139140
dash_t dashes;
140141

141-
protected:
142+
protected:
142143
agg::rgba get_color(const Py::Object& gc);
143144
double points_to_pixels( const Py::Object& points);
144145
void _set_linecap(const Py::Object& gc) ;

0 commit comments

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