Assignment into Python 3.x Buffers with itemsize > 1
问题 I am trying to expose a buffer of image pixel information (32 bit RGBA) through the Python 3.x buffer interface. After quite a bit of playing around, I was able to get this working like so: int Image_get_buffer(PyObject* self, Py_buffer* view, int flags) { int img_len; void* img_bytes; // Do my image fetch magic get_image_pixel_data(self, &img_bytes, &img_len); // Let python fill my buffer PyBuffer_FillInfo(view, self, img_bytes, img_len, 0, flags); } And in python I can play with it like so: