From: <md...@us...> - 2008-05-06 18:56:59
|
Revision: 5123 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5123&view=rev Author: mdboom Date: 2008-05-06 11:56:47 -0700 (Tue, 06 May 2008) Log Message: ----------- Fixing bugs in recent changes to Qt blitting. Modified Paths: -------------- branches/v0_91_maint/lib/matplotlib/backends/backend_qt4agg.py branches/v0_91_maint/lib/matplotlib/backends/backend_qtagg.py branches/v0_91_maint/src/_backend_agg.cpp Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_qt4agg.py =================================================================== --- branches/v0_91_maint/lib/matplotlib/backends/backend_qt4agg.py 2008-05-06 15:42:16 UTC (rev 5122) +++ branches/v0_91_maint/lib/matplotlib/backends/backend_qt4agg.py 2008-05-06 18:56:47 UTC (rev 5123) @@ -109,8 +109,10 @@ # we are blitting here else: bbox = self.replot - w, h = int(bbox.width()), int(bbox.height()) - l, t = bbox.ll().x().get(), bbox.ur().y().get() + l, t = int(bbox.ll().x().get()), int(bbox.ur().y().get()) + r, b = int(bbox.ur().x().get()), int(bbox.ll().y().get()) + w = r - l + h = t - b reg = self.copy_from_bbox(bbox) stringBuffer = reg.to_string_argb() qImage = QtGui.QImage(stringBuffer, w, h, QtGui.QImage.Format_ARGB32) Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_qtagg.py =================================================================== --- branches/v0_91_maint/lib/matplotlib/backends/backend_qtagg.py 2008-05-06 15:42:16 UTC (rev 5122) +++ branches/v0_91_maint/lib/matplotlib/backends/backend_qtagg.py 2008-05-06 18:56:47 UTC (rev 5123) @@ -115,8 +115,10 @@ # we are blitting here else: bbox = self.replot - w, h = int(bbox.width()), int(bbox.height()) - l, t = bbox.ll().x().get(), bbox.ur().y().get() + l, t = int(bbox.ll().x().get()), int(bbox.ur().y().get()) + r, b = int(bbox.ur().x().get()), int(bbox.ll().y().get()) + w = r - l + h = t - b reg = self.copy_from_bbox(bbox) stringBuffer = reg.to_string_argb() qImage = qt.QImage(stringBuffer, w, h, 32, None, 0, qt.QImage.IgnoreEndian) Modified: branches/v0_91_maint/src/_backend_agg.cpp =================================================================== --- branches/v0_91_maint/src/_backend_agg.cpp 2008-05-06 15:42:16 UTC (rev 5122) +++ branches/v0_91_maint/src/_backend_agg.cpp 2008-05-06 18:56:47 UTC (rev 5123) @@ -227,26 +227,28 @@ 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; + unsigned char* pix; + unsigned char* begin; + unsigned char* end; + unsigned char tmp; + size_t i, j; PyObject* str = PyString_FromStringAndSize((const char*)aggbuf.data, aggbuf.height*aggbuf.stride); - if (PyString_AsStringAndSize(str, &begin, &length)) { + if (PyString_AsStringAndSize(str, (char**)&begin, &length)) { throw Py::TypeError("Could not create memory for blit"); } pix = begin; end = begin + (aggbuf.height * aggbuf.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; + for (i = 0; i < aggbuf.height; ++i) { + pix = begin + i * aggbuf.stride; + for (j = 0; j < aggbuf.width; ++j) { + // Convert rgba to argb + tmp = pix[2]; + pix[2] = pix[0]; + pix[0] = tmp; + pix += 4; + } } return Py::String(str, true); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |