如何清除 python3 Pillow 中的区域
How to clear a region in python3 Pillow
如何清除 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))
区域 (100, 100, 300, 150)
将用 fill
参数中给定的颜色填充。在这种情况下,矩形根本没有混合。
如何清除 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))
区域 (100, 100, 300, 150)
将用 fill
参数中给定的颜色填充。在这种情况下,矩形根本没有混合。