Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在Jython中翻转图片_Python_Jython - Fatal编程技术网

Python 在Jython中翻转图片

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

这是我的代码,它翻转了图片。我需要将它翻转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 = 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)