2
두 개의 코드가 있는데 둘 다 검정색 사각형이 포함 된 test.png를 만들어야합니다. 첫 번째 작업에서는 수행하지만 두 번째 작업은 투명한 사각형을 반환합니다. 그들 사이의 차이점은 첫 번째 것은 왼쪽에 명확한 스트라이프가 있고 두 번째는 그렇지 않다는 것입니다.PhotoImage의 투명도 버그
첫 번째 예 :
root = Tk()
image = PhotoImage(width = 50, height = 50)
for x in range(1, 50):
for y in range(50):
pixel(image, (x,y), (0,0,0))
image.write('test.png', format='png')
번째 예 :
I의이 코드 갖는 함수 화소()는 Tkinter을 가져와 사용root = Tk()
image = PhotoImage(width = 50, height = 50)
for x in range(50):
for y in range(50):
pixel(image, (x,y), (0,0,0))
image.write('test.png', format='png')
:
def pixel(image, pos, color):
"""Place pixel at pos=(x,y) on image, with color=(r,g,b)."""
r,g,b = color
x,y = pos
image.put("#%02x%02x%02x" % (r,g,b), (x, y))