Image Jython,如何将图像放置在另一个图像的中心

Image Jython,如何将图像放置在另一个图像的中心,image,jython,pixel,jes,Image,Jython,Pixel,Jes,我需要一些帮助与Jython,我应该把一个图像到另一个图像,使它看起来 但是,使用我当前的代码,我的结果是 谁能帮帮我吗 谢谢 def copyPicture(pict): tpict = makeEmptyPicture(getWidth(pict)*2, getHeight(pict)*2) for x in range(0,getWidth(pict)): for y in range(0,getHeight(pict)): srcPix=getPixel(pi

我需要一些帮助与Jython,我应该把一个图像到另一个图像,使它看起来

但是,使用我当前的代码,我的结果是

谁能帮帮我吗

谢谢

def copyPicture(pict):
  tpict = makeEmptyPicture(getWidth(pict)*2, getHeight(pict)*2)
  for x in range(0,getWidth(pict)):
    for y in range(0,getHeight(pict)):
      srcPix=getPixel(pict, x,y)
      tgtPix=getPixel(tpict,x,y)
      setColor(tgtPix, getColor(srcPix))
  for x in range(0,getWidth(pict)):
    for y in range(0,getHeight(pict)):
      srcPix=getPixel(pict,getWidth(pict)-x-1,y)
      tgtPix=getPixel(tpict,x+getWidth(pict),y)
      setColor(tgtPix, getColor(srcPix))
  for x in range(0,getWidth(tpict)):
    for y in range(0,getHeight(tpict)/2):
      srcPix=getPixel(tpict,x,y)
      tgtPix=getPixel(tpict,x,getHeight(pict)+getHeight(pict)-y-1)
      setColor(tgtPix,getColor(srcPix))
  x1=getWidth(tpict)/2    
  for x in range(0,getWidth(pict),2):
    y1=getHeight(tpict)/2
    for y in range(0,getHeight(pict),2):
      srcPix=getPixel(pict,x,y)
      tgtPix=getPixelAt(tpict,x1,y1)
      setColor(tgtPix, getColor(srcPix))
      y1=y1+1
    x1=x1+1
  repaint(tpict)

您需要设置
x1=getWidth(tpict)/2-getWidth(pict),2)/2
,对于
y1
,我想也是这样!谢谢你的回复,但是结果不同了:/你需要设置
x1=getWidth(tpict)/2-getWidth(pict),2)/2
,同样的
y1
-我想!感谢您的回复,但结果不同:/