From: Alex Grönholm <alex.gronholm@ne...>  20100331 23:05:13

1.4.2010 1:52, hughesj6 kirjoitti: > Hello, > > If anyone can help me ASAP, I would greatly appreciate it. This project is > due tonight at Midnight EST, and I'm stuck! > > I am working on a project for an Elementary Programming class, and the > assignment is the following: > > "For this assignment you will take an image and create a new image that > contains 4 copies of that > picture. Our new image will be twice the height and width of the original > image (this is so we can > have four copies of the original in this new image. > > For one copy, set the Red level of all the pixels in that copy to “0”. > For one copy, set the Blue level of all the pixels in that copy to “0”. > For one copy, set the Green level of all the pixels in that copy to “0”. > For one copy, use one of the formulas in your text book for turning a color > picture into a > grayscale picture. (Only apply this formula to one of the four copies. Not > the entire picture.)" > > I have gotten pretty far in the code, but ultimately I cannot figure out why > it gives me random colors for "pic2" rather than the colors I enter in. I > have attempted numerous ways of coding it  but I am completely stuck!!! > *PLEASE HELP!!!!* > > I'm sorry, but what does this have to do with Jython? > ______________________ > > I have attached the .py file, as well as pasted one version of my code > below. Any suggestions would be appreciated! > > CODE: > > def main(): > > pic = makePicture( pickAFile() ) > show(pic) > showInformation("This is your original picture, Click OK to alter the > picture!") > > w0 = getWidth(pic) > h0 = getHeight(pic) > > for x0 in range(0, w0): > for y0 in range(0, h0): > pixels = getPixel(pic, x0, y0) > r = getRed(pixels) > g = getBlue(pixels) > b = getGreen(pixels) > > w = w0*2 > h = h0*2 > pic2 = makeEmptyPicture(w, h) > > for x in range(0, w/2): > for y in range(0, h/2): > px = getPixel(pic2, x, y) > setRed(px, 0) > setGreen(px, g) > setBlue(px, b) > > for x2 in range(0, w/2): > for y2 in range(h/2, h): > px2 = getPixel(pic2, x2, y2) > setRed(px2, r*0.299) > setGreen(px2, g*0.587) > setBlue(px2, b*0.114) > > for x3 in range(w/2, w): > for y3 in range(0, h/2): > px3 = getPixel(pic2, x3, y3) > setRed(px3, r) > setGreen(px3, g) > setBlue(px3, 0) > > for x4 in range(w/2, w): > for y4 in range(h/2, h): > px4 = getPixel(pic2, x4, y4) > setRed(px4, r) > setGreen(px4, 0) > setBlue(px4, b) > > repaint(pic2) > > __________________________________________________________________________ > *NOTE* > > I have also tried replacing the altering forloops with the following, but > got the same results: > > i.e.: > > for x3 in range(w/2, w): > for y3 in range(0, h/2): > r = getRed(getPixel(pic, x0, y0)) > setRed(getPixel(pic2, x3, y3), r) > g = getGreen(getPixel(pic, x0, y0)) > setGreen(getPixel(pic2, x3, y3), g) > b = getBlue(getPixel(pic, x0, y0)) > setBlue(getPixel(pic2, x3, y3), 0) > http://old.nabble.com/file/p28100673/Program6_Hughes_STUCK.py > Program6_Hughes_STUCK.py > 