|
From: <md...@us...> - 2008-05-06 15:42:29
|
Revision: 5122
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5122&view=rev
Author: mdboom
Date: 2008-05-06 08:42:16 -0700 (Tue, 06 May 2008)
Log Message:
-----------
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
........
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py
trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py
trunk/matplotlib/src/_backend_agg.cpp
trunk/matplotlib/src/_backend_agg.h
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Name: svnmerge-integrated
- /branches/v0_91_maint:1-5108
+ /branches/v0_91_maint:1-5121
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-05-06 15:30:09 UTC (rev 5121)
+++ trunk/matplotlib/CHANGELOG 2008-05-06 15:42:16 UTC (rev 5122)
@@ -1,3 +1,5 @@
+2008-05-06 Fix strange colors when blitting in QtAgg and Qt4Agg - MGD
+
2008-05-05 pass notify_axes_change to the figure's add_axobserver
in the qt backends, like we do for the other backends.
Thanks Glenn Jones for the report - DSD
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py 2008-05-06 15:30:09 UTC (rev 5121)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py 2008-05-06 15:42:16 UTC (rev 5122)
@@ -114,7 +114,7 @@
h = int(t) - int(b)
t = int(b) + h
reg = self.copy_from_bbox(bbox)
- stringBuffer = reg.to_string()
+ stringBuffer = reg.to_string_argb()
qImage = QtGui.QImage(stringBuffer, w, h, QtGui.QImage.Format_ARGB32)
pixmap = QtGui.QPixmap.fromImage(qImage)
p = QtGui.QPainter( self )
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py 2008-05-06 15:30:09 UTC (rev 5121)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py 2008-05-06 15:42:16 UTC (rev 5122)
@@ -119,7 +119,7 @@
w = int(r) - int(l)
h = int(t) - int(b)
reg = self.copy_from_bbox(bbox)
- stringBuffer = reg.to_string()
+ stringBuffer = reg.to_string_argb()
qImage = qt.QImage(stringBuffer, w, h, 32, None, 0, qt.QImage.IgnoreEndian)
self.pixmap.convertFromImage(qImage, qt.QPixmap.Color)
p.drawPixmap(qt.QPoint(l, self.renderer.height-t), self.pixmap)
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp 2008-05-06 15:30:09 UTC (rev 5121)
+++ trunk/matplotlib/src/_backend_agg.cpp 2008-05-06 15:42:16 UTC (rev 5122)
@@ -90,6 +90,34 @@
return Py::String(PyString_FromStringAndSize((const char*)data, height*stride), true);
}
+Py::Object BufferRegion::to_string_argb(const Py::Tuple &args) {
+ // owned=true to prevent memory leak
+ Py_ssize_t length;
+ char* pix;
+ char* begin;
+ char* end;
+ char tmp;
+
+ PyObject* str = PyString_FromStringAndSize((const char*)data, height*stride);
+ if (PyString_AsStringAndSize(str, &begin, &length)) {
+ throw Py::TypeError("Could not create memory for blit");
+ }
+
+ pix = begin;
+ end = begin + (height * stride);
+ while (pix != end) {
+ // Convert rgba to argb
+ tmp = pix[3];
+ pix[3] = pix[2];
+ pix[2] = pix[1];
+ pix[1] = pix[0];
+ pix[0] = pix[3];
+ pix += 4;
+ }
+
+ return Py::String(str, true);
+}
+
GCAgg::GCAgg(const Py::Object &gc, double dpi) :
dpi(dpi), isaa(true), linewidth(1.0), alpha(1.0),
dashOffset(0.0)
@@ -210,7 +238,6 @@
}
}
-
const size_t
RendererAgg::PIXELS_PER_INCH(96);
@@ -1707,6 +1734,8 @@
add_varargs_method("to_string", &BufferRegion::to_string,
"to_string()");
+ add_varargs_method("to_string_argb", &BufferRegion::to_string_argb,
+ "to_string_argb()");
}
Modified: trunk/matplotlib/src/_backend_agg.h
===================================================================
--- trunk/matplotlib/src/_backend_agg.h 2008-05-06 15:30:09 UTC (rev 5121)
+++ trunk/matplotlib/src/_backend_agg.h 2008-05-06 15:42:16 UTC (rev 5122)
@@ -103,6 +103,7 @@
bool freemem;
Py::Object to_string(const Py::Tuple &args);
+ Py::Object to_string_argb(const Py::Tuple &args);
static void init_type(void);
virtual ~BufferRegion() {
@@ -138,7 +139,7 @@
double dashOffset;
dash_t dashes;
- protected:
+protected:
agg::rgba get_color(const Py::Object& gc);
double points_to_pixels( const Py::Object& points);
void _set_linecap(const Py::Object& gc) ;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|