File tree Expand file tree Collapse file tree 1 file changed +15
-13
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +15
-13
lines changed
Original file line number Diff line number Diff line change @@ -93,26 +93,28 @@ Py::Object BufferRegion::to_string(const Py::Tuple &args) {
93
93
Py::Object BufferRegion::to_string_argb (const Py::Tuple &args) {
94
94
// owned=true to prevent memory leak
95
95
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;
100
101
101
102
PyObject* str = PyString_FromStringAndSize ((const char *)data, height*stride);
102
- if (PyString_AsStringAndSize (str, &begin, &length)) {
103
+ if (PyString_AsStringAndSize (str, ( char **) &begin, &length)) {
103
104
throw Py::TypeError (" Could not create memory for blit" );
104
105
}
105
106
106
107
pix = begin;
107
108
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
+ }
116
118
}
117
119
118
120
return Py::String (str, true );
You can’t perform that action at this time.
0 commit comments