如果你能够处理您的SWIG缓冲机的签名性问题,你可以直接创建PIL成像仪。 http://www.un.org/Depts/DGACM/index_french.htm 您将发现:
struct ImagingMemoryInstance {
/* Format */
char mode[4+1]; /* Band names ("1", "L", "P", "RGB", "RGBA", "CMYK") */
int type; /* Data type (IMAGING_TYPE_*) */
int depth; /* Depth (ignored in this version) */
int bands; /* Number of bands (1, 2, 3, or 4) */
int xsize; /* Image dimension. */
int ysize;
/* Colour palette (for "P" images only) */
ImagingPalette palette;
/* Data pointers */
UINT8 **image8; /* Set for 8-bit images (pixelsize=1). */
INT32 **image32; /* Set for 32-bit images (pixelsize=4). */
/* Internals */
char **image; /* Actual raster data. */
char *block; /* Set if data is allocated in a single block. */
int pixelsize; /* Size of a pixel, in bytes (1, 2 or 4) */
int linesize; /* Size of a line, in bytes (xsize * pixelsize) */
/* Virtual methods */
void (*destroy)(Imaging im);
};
...... 图像计量* 是Imaging
的型号,是你在整个消费物价指数C推广源中普遍发现的碎片的基础。 Don一字,看——从APIC的消息来源看,PIL的编码基础明显是可行的,相当一致。
As @maxy points out, you can also create a NumPy array struct just as easy (if not easier) -- but while the NumPy C API is as stable as out of Guido s personal playbook, I personally find that one library-source dependency is enough, in these scenarios.