Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 9th, 2012, 06:05 PM
xorachelannx3 xorachelannx3 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 1 xorachelannx3 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 m 14 sec
Reputation Power: 0
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
repaint(imageC)
show(imageC)
return imageC





show(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?

Reply With Quote
  #2  
Old December 10th, 2012, 08:11 AM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,361 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 10 h 11 sec
Reputation Power: 383
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
try:
except:
statement.

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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Cropping a part of one picture and then scaling it up larger onto another part of img

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap