简单的jes功能将图片颜色从红色切换为绿色或蓝色?

时间:2016-06-20 02:19:04

标签: python jython jes

标题说明了一切,我只想找到一种简单的方法将所有照片红色像素更改为绿色或蓝色。

1 个答案:

答案 0 :(得分:0)

假设您的意思是为每个像素交换红色和蓝色值,那么这就是您可以做到的。如果没有,那么这里应该足够让你离得很近。

def swapRedwithBlue(sourceImage):

width = getWidth(sourceImage)
height = getHeight(sourceImage)

for x in range(width):
  for y in range(height):

    sourcePixel = getPixel(sourceImage, x, y) 
    R = getRed(sourcePixel)
    G = getGreen(sourcePixel)
    B = getBlue(sourcePixel)
    color = makeColor(B, G, R)
    destinationPixel = getPixel(sourceImage, x, y)
    setColor(destinationPixel, color)

repaint(sourceImage)
相关问题