1

I need some help with Jython, I am supposed to place an image into another image so it will looked like this

However, with my current code, my result is this

Could someone please help me?

Thanks.

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)
iDeal
  • 201
  • 2
  • 4
  • 7

0 Answers0