
Instead of iterating over the original pixels, and figuring out the 16 new pixels that each one maps to, why not iterate over the new pixels, and figure out the 1 old pixels that each one (non-uniquely) maps to? for r in range(height*yscale): However, if you turn your algorithm around, there's a possibly simpler way to look at this.
#PIXEL 3 COMPANY OF HEROES 2 IMAGES CODE#
Now just repeat the same trick with the rows (and give n a better name so you can keep the row and column offsets straight) and you have the code above. Now you can replace the 4 with xscale, and you're done. So, to abstract that into a loop, you want that 4*c+n to be a loop where n goes from 0 to 3, like this: for n in range(4): Well, first, for each row, you've got 4 lines of code, like this: tPixel(4*r, 4*c, pixel) tPixel(yscale*r + yoffset, xscale*c + xoffset, pixel) But to do it this way, you actually need two for loops, nested.* for yoffset in range(yscale): I feel that I should probably be able to implement a for loop _tkinter.TclError: pyimage1 get: coordinates out of range Return self.tk.call(self.name, 'get', x, y) P = įile "/Library/Frameworks/amework/Versions/3.2/lib/python3.2/tkinter/ init.py", line 3260, in get I've gone and tested both my quadruple.py and resize.py, and with square images they work, but when I put a none square image in, I get the following:įile "/Users/jakebenedict/CPS/Lab6/cImage.py", line 313, in getTkPixel

When I try with a not square image, I got the error that my coordinates were out of range. 3 x 3) and it works fine with a square image, but when I try to change one of them, I get an error: I've tested it with scalars that are equal (i.e. tPixel((heightScalar*r)+i, (widthScalar*c)+j, pixel) I've also tried using the more complicated method: for r in range(oldHeight):

Pixel = oldImage.getPixel(r // heightScalar, c // widthScalar) NewImage = EmptyImage(newWidth, newHeight) MyNewWin = ImageWin("Scaled Image", newWidth, newHeight) MyWin = ImageWin("Old Image", oldWidth, oldHeight) I am working with the following modified code: from cImage import *

I feel that I should probably be able to implement a for loop, but I'm having a hard time getting things to work.
#PIXEL 3 COMPANY OF HEROES 2 IMAGES HOW TO#
MyNewWin = ImageWin("Quadrupled Image", width*4, height*4)īut I am having trouble trying to figure out how to edit my code so it scales it as requested. MyWin = ImageWin("Old Image", width, height) I've written a code for quadrupling an image: import sys I'm working on a python code that takes an image name from the command line, and prints it in a window, rescaled to the user's likings, i.e., the input python3.2 resize.py image.gif 2 3 would take image.gif and double the width and triple the height.
