【问题标题】:Problem copying one image completely to another in JES在 JES 中将一个图像完全复制到另一个图像时出现问题
【发布时间】:2018-11-02 22:29:17
【问题描述】:

对于我的任务,我们必须将我们校园的照片复制到一张空白的白色图像上,然后通过交换羚羊和长耳兔的鹿角和耳朵来制作 2 种不同的鹿角羚。我选择解决的第一步是将 GCU 校园复制到白色图像。我的程序加载并运行,但是当它显示带有复制像素的新画布时,它只显示 GCU 校园的右下角复制到(仍然大部分是空白的)画布的左上角。我试过切换目标和源。我尝试手动输入校园的像素高度和宽度,而不是使用 getHeight\Width。我基本上只是复制了示例代码并插入了我的变量,但它仍然不起作用。任何帮助将不胜感激。这是我的代码:

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()

【问题讨论】:

  • 另外,如果您对尺寸感到好奇,GCU 图片为 264x620,空白画布为 1440 x 2560

标签: python jython jes


【解决方案1】:

所以问题出在我试图复制到的图像上。我不确定它为什么会导致问题,但我正在尝试解决方案,发现使用不同的空白图像允许程序复制整个 GCU 照片。我选择了一个尺寸更接近我正在复制的图像的画布,这是我最好的选择。谢谢。

【讨论】:

    猜你喜欢
    • 2020-11-05
    • 2018-08-31
    • 2015-08-10
    • 2018-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-05
    • 1970-01-01
    相关资源
    最近更新 更多