Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9bd1746

Browse files
committed
Merged revisions 5122-5123 via svnmerge from
https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_91_maint ........ r5123 | mdboom | 2008-05-06 14:56:47 -0400 (Tue, 06 May 2008) | 2 lines Fixing bugs in recent changes to Qt blitting. ........ svn path=/trunk/matplotlib/; revision=5124
1 parent 68c108c commit 9bd1746

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

src/_backend_agg.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,26 +93,28 @@ Py::Object BufferRegion::to_string(const Py::Tuple &args) {
9393
Py::Object BufferRegion::to_string_argb(const Py::Tuple &args) {
9494
// owned=true to prevent memory leak
9595
Py_ssize_t length;
96-
char* pix;
97-
char* begin;
98-
char* end;
99-
char tmp;
96+
unsigned char* pix;
97+
unsigned char* begin;
98+
unsigned char* end;
99+
unsigned char tmp;
100+
size_t i, j;
100101

101102
PyObject* str = PyString_FromStringAndSize((const char*)data, height*stride);
102-
if (PyString_AsStringAndSize(str, &begin, &length)) {
103+
if (PyString_AsStringAndSize(str, (char**)&begin, &length)) {
103104
throw Py::TypeError("Could not create memory for blit");
104105
}
105106

106107
pix = begin;
107108
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;
109+
for (i = 0; i < (size_t)height; ++i) {
110+
pix = begin + i * stride;
111+
for (j = 0; j < (size_t)width; ++j) {
112+
// Convert rgba to argb
113+
tmp = pix[2];
114+
pix[2] = pix[0];
115+
pix[0] = tmp;
116+
pix += 4;
117+
}
116118
}
117119

118120
return Py::String(str, true);

0 commit comments

Comments
 (0)