为什么 aggdraw 图像是空白的?

Why is aggdraw image blank?

我正在尝试使用 Pillow 和 aggdraw 绘制一堆线段。只用枕头,我的代码就可以工作了——但我需要更流畅的线条。我似乎无法使用 aggdraw 绘制任何线条。

import aggdraw
from PIL import Image

image = Image.new("RGB", (ROW_SIZE, COL_SIZE), (255,255,255))
#draw = ImageDraw.Draw(image)
draw = aggdraw.Draw(image)
pen = aggdraw.Pen("black", 2)

# Each segment contains two points with x and y coordinates
for segment in segments:
   draw.line((segment.point1.x, segment.point1.y, segment.point2.x, segment.point2.y), pen)

image.show()

我也尝试将导入更改为 from aggdraw import Draw, Pen 并相应地更改用法 - 无济于事。

尝试使用:

...
for segment in segments:
    draw.line((segment.point1.x, segment.point1.y, segment.point2.x, segment.point2.y), pen)

# Add the following line
draw.flush()
image.show()