繁体   English   中英

JES影像复制

[英]JES image duplicating

我正在做一个项目,在该项目中我也需要打印用户选择的任何图像多次。

我的代码大部分都能正常工作,但是我需要创建一个嵌套循环,该循环将基本上改变原始图像的Xpos和Ypos的值,并对其进行更改以生成新的图片。

def repeat(pic):
    val = requestIntegerInRange("Enter 1-10", 1, 10)
    print "The user entered :" + str(val)
    w = getWidth(pic)
    h = getHeight(pic)
    print "Height and Width of this image are:", h, w
    result = makeEmptyPicture(w, h * val)
    xpos = 0
    while(xpos < w):
        ypos = 0
        while(ypos < h):
            pixel = getPixel(pic, xpos, ypos)
            color = getColor(pixel)
            loop = 0
            while(loop <= val):
                newX = xpos
                newY = ypos + h * val
                pixel2 = getPixel(result, newX, newY)
                setColor(pixel2, color)
                loop = loop + 1
            ypos = ypos + 1
        xpos = xpos + 1 

val是用户选择的用于多次打印图像的值。

当我使用上面的代码运行程序时,它显示

The error value is: 
Inappropriate argument value (of correct type).Height and Width of the Picture are : 208 146
getPixel(picture,x,y): y (= 1456) is less than 0 or bigger than the height (= 1455)
An error occurred attempting to pass an argument to a function.

您正在执行newY = ypos + h * val ,应该在其中newY = ypos + h * loop

此外,您在val上的loop < val应在loop < val而不是loop <= val上停止。 最后一个副本是不需要的(第(val + 1)个),这是使您编程失败的部分。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM