[英]PIL selection of coordinates to make an image
我想從我選擇的坐標中創建一個圖像。 所以我希望每個坐標都設置一個特定的大小,顏色說黑色和2X2,然后將它放在它代表的特定像素上。 我將如何解決這個問題? 函數putpixel
,是否適用於我想做的事情?
提前致謝
使用putpixel
執行此putpixel
將不方便,但並非不可能。 既然你說你想要制作多個像素的點,那么最好使用ImageDraw.rectangle()
或ellipse()
。
例如:
import Image
import ImageDraw
img = Image.new("RGB", (400,400), "white")
draw = ImageDraw.Draw(img)
coords = [(100,70), (220, 310), (200,200)]
dotSize = 2
for (x,y) in coords:
draw.rectangle([x,y,x+dotSize-1,y+dotSize-1], fill="black")
img.show()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.