1

我有一个函数,它返回一个指向对应于 8 位灰度像素的字节序列开头的指针。我正在尝试使用 PIL 的 frombuffer() 函数来创建图像。看这里我做了以下事情:

image_data = (1280*960*ctypes.c_ubyte)()
image_data = Frameptr
im = Image.frombuffer("L", (1280, 960), image_data, "raw", "L", 0, 1)

但是,我仍然收到此错误消息

Traceback (most recent call last):
File "_ctypes/callbacks.c", line 314, in 'calling callback function'
File "C:\Desktop\Program_2013\camera\framegrab.py", line 44, in FrameDataCallBack
im = Image.frombuffer("L", (1280, 960), image_data, "raw", "L", 0, 1)
File "C:\Python27\lib\site-packages\PIL\Image.py", line 1853, in frombuffer
core.map_buffer(data, size, decoder_name, None, 0, args)
ValueError: buffer is not large enough

任何帮助,将不胜感激!

4

0 回答 0