Python 在Jython中翻转图片
这是我的代码,它翻转了图片。我需要将它翻转180度,我现在的代码将它翻转180度。我想不出如何改变这一点。它不会让我发布我正在谈论的图片,所以希望你们都能理解我所说的Python 在Jython中翻转图片,python,jython,Python,Jython,这是我的代码,它翻转了图片。我需要将它翻转180度,我现在的代码将它翻转180度。我想不出如何改变这一点。它不会让我发布我正在谈论的图片,所以希望你们都能理解我所说的 def flip(picture): width = getWidth(picture) height = getHeight(picture) for y in range(0, height/2): for x in range(0, width): p1 = getPixe
def flip(picture):
width = getWidth(picture)
height = getHeight(picture)
for y in range(0, height/2):
for x in range(0, width):
p1 = getPixel(picture, x, y)
p2 = getPixel(picture, x, height - y - 1,)
color = getColor(p1)
setColor(p1, getColor(p2))
setColor(p2, color)
试试这个。我也有同样的问题,我们处理的是高度,而不是宽度
def flip(picture):
width = getWidth(picture)
height = getHeight(picture)
for y in range(0, height/2):
for x in range(0, width):
**p1 = getPixel(picture, width - 1 - x, y)**
p2 = getPixel(picture, x, height - 1 - y,)
color = getColor(p1)
setColor(p1, getColor(p2))
setColor(p2, color)