Using Python 2.5.2, Cairo 1.4.2, PyCairo 1.4.12, PyGame 1.8 The following code (shown in the url mentioned above): surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, w, h) ... render to surface ... buf = surface.get_data() ... imsurf = pygame.image.frombuffer(buf, (w,h), "RGBA") ... results in a TypeError "char buffer type not available" changing the imsurf... line to : imsurf = pygame.image.frombuffer(str(buf), (w,h), "RGBA") avoid the exception but results in a black image being shown
The code used to work, and pycairo has not been changed to stop it working. It looks like pygame.image.frombuffer() used to accept readable buffers, and has been changed so it now only accepts character buffers. However, if you look at the Python/C API reference manual, section 10.7 "Buffer Object Structures" where it describes the bf_getcharbuffer slot: "... This notion of exporting the internal buffers as ``text'' is used to distinguish between objects that are binary in nature, and those which have character-based content. ..." The pycairo image data is binary, not text or character-based data, so in my opinion, the character buffer slot should not be used to read binary image data. I suggest opening a pygame bug report to request that pygame.image.frombuffer() stop reading binary image data as text-based characters.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.