Problem copying one image completely to another in JES

384 Views Asked by At

For my assignment we have to copy a picture of our campus onto a blank white image, then make 2 different jackalopes by swapping the antlers and the ears on an antelope and the jackrabbit. The first step I chose to tackle was copying the GCU campus to the white image. My program loads and runs but when it shows the new canvas with the copied pixels, it only displays the bottom right corner of the GCU campus copied to the upper left hand corner of the (still mostly blank) canvas. I have tried switching target and source. I have tried manually entering the pixel height and width for the campus instead of using getHeight\Width. I basically just copied the sample code and plugged in my variables but it still doesn't work. Any help would be greatly appreciated. Here is my code:

setMediaPath()

lopefile= getMediaPath("antelope.jpg")
lope= makePicture(lopefile)
jackfile= getMediaPath("jackrabbit.jpg")
jack= makePicture(jackfile)
GCUfile= getMediaPath("campus.jpg")
GCU= makePicture(GCUfile)
canvasfile= getMediaPath("canvas.jpg")
canvas= makePicture(canvasfile)

#this will copy the GCU picture to the blank canvas for the background
def makeBackground():
  targetX = 0
  for sourceX in range(0,getWidth(GCU)): 
    targetY = 0 
    for sourceY in range(0,getHeight(GCU)):
      color = getColor(getPixel(GCU,sourceX,sourceY))
      setColor(getPixel(canvas,targetX,targetY), color)
      targetY = targetY + 1
    targetX = targetX + 1 
  show(canvas)
  return (canvas)

makeBackground()
1

There are 1 best solutions below

0
On

So the problem was with the image I was trying to copy onto. I am not sure why it was causing problems but I was experimenting with solutions and found that using a different blank white image allowed the program to copy the entire GCU photo. I chose a canvas closer in size to the image I was copying over and that is my best bet for what was different. Thanks.