注册 登录
编程论坛 Python论坛

很傻很天真的编程问题 by Using Jyphon

qingmui 发布于 2010-10-17 08:25, 1289 次点击
使用Jython Environment for Student编程
问题:
Write a program that reduces the green and increases the blue in the top third of a picture and negates the bottom third. Your color reduction function(s) should be as general as possible, that is, they can reduce or increase by any given amount.

我的解答:

def redneg(a,b):
# this a,b are customize!
   file = r"D:\Picture\gzjietu.jpg"
   pic = makePicture(file)
   for x in range(0,getWidth(pic)):
     for y in range(0,getHeight(pic)/3):
        px = getPixel(pic,x,y)      
        setGreen(px,getGreen(px)*a)
        setBlue(px, getBlue(px)*b)
        
   for x in range(0,getWidth(pic)):
     for y in range(getHeight(pic)-getHeight(pic)*(2/3),getHeight(pic)):   
       px = getPixel(pic, x, y)
       red = getRed(px)
       blue = getBlue(px)
       green = getGreen(px)
       newColor = makeColor(255-red, 255-green, 255-blue)
       setColor=(px,newColor)      
         
   repaint(pic)     
===============

然后我后面的negative picture code好像没用啊
解释器也没说我哪里出问题
1 回复
#2
KLML884222010-11-19 09:07
。。。。。。。。。。。。。。。。。
1