Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何清除python3枕头中的区域_Python 3.x_Python Imaging Library - Fatal编程技术网

Python 3.x 如何清除python3枕头中的区域

Python 3.x 如何清除python3枕头中的区域,python-3.x,python-imaging-library,Python 3.x,Python Imaging Library,如何在python3枕头中使用ImageDraw清除区域 im = Image.new('RGBA', (1200, 400), (0, 0, 0, 0)) draw = ImageDraw.Draw(im) ... draw.rectangle((100, 100, 300, 150), fill=(0, 0, 0, 0)) draw.text((100, 100), 'Hello World!', font=font, fill=(0, 0, 255, 255)) canvas.writ

如何在python3枕头中使用
ImageDraw
清除区域

im = Image.new('RGBA', (1200, 400), (0, 0, 0, 0))
draw = ImageDraw.Draw(im)

...

draw.rectangle((100, 100, 300, 150), fill=(0, 0, 0, 0))
draw.text((100, 100), 'Hello World!', font=font, fill=(0, 0, 255, 255))
canvas.write(im.tobytes())
我的想法是用
fill=(0,0,0,0)
绘制一个矩形,但由于
alpha
分量为
0
,因此该矩形与图像混合后不会改变像素


我每秒更新一个图像60次,我无法重新绘制整个图像。

错误在我的代码中的其他地方

要清除某个区域,只需拨打电话

draw.rectangle((100, 100, 300, 150), fill=(0, 0, 0, 0))

区域
(100100300150)
将用
fill
参数中给出的颜色填充。在本例中,矩形完全没有混合。

错误在我的代码中的其他地方

要清除某个区域,只需拨打电话

draw.rectangle((100, 100, 300, 150), fill=(0, 0, 0, 0))
区域
(100100300150)
将用
fill
参数中给出的颜色填充。在这种情况下,矩形完全不混合