1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Rep Power

    Cropping a part of one picture and then scaling it up larger onto another part of img

    # Date: December 14, 2012

    # FinalExam_FLast.py

    ##### Template for CIS 150 Final Exam Lab ######

    # ********** Final Exam **********

    # Do your work for the Final Exam Lab below this comment by placing
    # your function finalExam below these comments
    # Function finalExam goes below this comment

    def finalExam():
    imageA = makePicture('imageA.jpg')
    imageB = makePicture('imageB.jpg')
    imageC = makePicture('imageC.jpg')
    # All Program code is to be placed immediately below this comment

    canvasY = 0
    for sourceY in range(0, getHeight(imageB)):
    canvasX = 0
    for sourceX in range(0, getWidth(imageB)):
    sourcePx = getPixel(imageB, sourceX, sourceY)
    canvasPx1 = getPixel(imageC, canvasX, canvasY)
    canvasPx2 = getPixel(imageC, canvasX+1, canvasY)
    canvasPx3 = getPixel(imageC, canvasX, canvasY+1)
    canvasPx4 = getPixel(imageC, canvasX+1, canvasY+1)
    color = getColor(sourcePx)
    setColor(canvasPx1, color)
    setColor(canvasPx2, color)
    setColor(canvasPx3, color)
    setColor(canvasPx4, color)
    canvasX = canvasX +2
    canvasY = canvasY +2
    return imageC


    # If your finalExam function is using any other function(s)
    # you should copy those function below this comment.

    This is the error i'm getting :

    >>> finalExam()
    getPixel(picture,x,y): x (= 300) is less than 0 or bigger than the width (= 299)
    The error was:
    Inappropriate argument value (of correct type).
    An error occurred attempting to pass an argument to a function.
    Please check line 26 of /Users/xorachelannx3/Desktop/CIS150-Programming/CIS 150 FINAL EXAM LAB/FinalExam_RGrass.py

    Not sure why this doesn't work, i've set my media path to the location of those images. anyone have any ideas on what is going wrong?
  2. #2
  3. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Rep Power
    Without knowing anything about makePicture let's guess

    canvasX = canvasX +2

    is a problem, you should go to half width and half height?

    You could kludge with

    good luck!
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo