Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """This is a small program to turn a picture 90 degrees clockwise.
- 这是一个将一副图片按顺时针方向转90度的程序,请帮忙修改一下。错误是如下的内容。
- Please help me to find out where I was wrong. Thank you!
- """
- import media
- room = media.load_picture("room.jpg") #room.jpg is a 470*400 pixels pic(any else the same)
- width = media.get_width(room)
- height = media.get_height(room)
- new = media.create_picture(height, width, media.white) #to create a new picture, width=>former height,height=>width
- for y in range(0,height): #load height of room
- for x in range(0,width): #load width of room
- from_p = media.get_pixel(room,x,y) #get pixel of room,but not in (room, x, y)
- to_p = media.get_pixel(new,(height-y), x ) #get pixel of new, in (new, x, y) row
- media.set_color(to_p, media.get_color(from_p)) #set color of the new one
- media.show(new)
- """
- Error Info:
- Python 2.7.3 (default, Aug 1 2012, 05:14:39)
- [GCC 4.6.3]
- Type "help", "copyright", "credits" or "license" for more information.
- [evaluate turn90.py]
- Traceback (most recent call last):
- File "/usr/lib/wingide-101-4.1/src/debug/tserver/_sandbox.py", line 9, in <module>
- File "/usr/local/lib/python2.7/dist-packages/pygraphics/media.py", line 49, in get_pixel
- return pic.get_pixel(x, y)
- File "/usr/local/lib/python2.7/dist-packages/pygraphics/picture.py", line 203, in get_pixel
- return pixel.Pixel(self.pixels, x, y)
- File "/usr/local/lib/python2.7/dist-packages/pygraphics/pixel.py", line 20, in __init__
- self.pixels[x, y]
- IndexError: image index out of range
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement