Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #scale down a picture by half in each dimension. Error is at bottom of page
- def scaleDown(src, dest) :
- skipRow = "false"
- skipCol = "false"
- destX = 1
- for srcX in range(1, getWidth(src)) :
- if skipRow == "true" :
- skipRow = "false"
- else :
- skipRow = "true"
- destY = 1 #checking coordinate (1, 1) at the start, then scanning all y in x, then checking next column
- for srcY in range(1, getHeight(src)) :
- if skipCol == "true" :
- skipCol = "false"
- else :
- skipCol = "true"
- srcPixel = getPixel(src, srcX, srcY)
- destPixel = getPixel(dest, destX, destY)
- setColor(destPixel, getColor(srcPixel))
- destY = destY + 1
- destX = destX + 1
- def scaleDownExercise() :
- srcPic = makePicture(pickAFile())
- destWidth = getWidth(srcPic)/2
- destHeight = getHeight(srcPic) /2 #this is where the error is
- destPic = makeEmptyPicture(destWidth, destHeight)
- show(srcPic)
- show(destPic)
- scaleDown(srcPic, destPic)
- repaint(destPic)
- #error:
- #getPixel(picture,x,y): y (= 450) is less than 0 or bigger than the height (= 449)
- #The error was:
- #Inappropriate argument value (of correct type).
- #An error occurred attempting to pass an argument to a function.
- #Please check line 19 of C:\Users\Matt\Desktop\Test Python\test3.py
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement