首页 > 解决方案 > 如何选择图像的一部分,然后使用 JES 将图像的选定部分以棋盘图案粘贴到另一个图像中?

问题描述

我正在使用Jython、 或JES,并且我想以棋盘格图案重复将一个图像的一部分复制到另一个图像中。我想知道如何做到这一点?

到目前为止,我有这个:

def checkerboard(pic):
  p = makeEmptyPicture(500,500)
  targetX = 100
  for sourceX in range(81,123):
    targetY = 100
    for sourceY in range(99,126):
      color = getColor(getPixel(pic,sourceX,sourceY))
      setColor(getPixel(p,targetX,targetY),color)
      targetY = targetY + 1
    targetX = targetX + 1
  show(p)

Pic是用户选择的图像, 和picXpicY图片的范围。问题是这只是将图像的一部分粘贴到空图片(p)中。我希望将图像的一部分重复粘贴到空图片的某个区域中的空图片中。

标签: pythonjythonjes

解决方案


推荐阅读