| | |
Doubling the size of an image
![]() |
I worked on this for a while and put the code into the Python snippet section:
http://www.daniweb.com/code/snippet396.html
Hope you find it constructive for your needs.
http://www.daniweb.com/code/snippet396.html
Hope you find it constructive for your needs.
May 'the Google' be with you!
Here is what I have done... some steps i did may not have been necessary, for example the extra color variables.... though now i need help with my zoom factor.... because this works for zooming in two times... but when higher numbers come about it skips pixels... i messed around with an extra for loop but its still the same... any other ideals?
Python Syntax (Toggle Plain Text)
def enlarge(oImage,w,h,x,y,zoom): nImage= EmptyImage(w*zoom,h*zoom) for q in range(w): x = x +zoom y = 0 for z in range(h): color = oImage.getPixel(q,z) red= color[0] green= color[1] blue= color[2] nImage.setPixel(x ,y ,(red,green,blue)) nImage.setPixel(x+1,y +1,(red,green,blue)) nImage.setPixel(x+1, y,(red,green,blue)) nImage.setPixel(x, y+1,(red,green,blue)) for lea in range(1,zoom): nImage.setPixel(x+lea,y+lea,(red,green,blue)) nImage.setPixel(x, y+lea,(red,green,blue)) nImage.setPixel(x+lea,y, (red, green,blue)) y = y +zoom r = nImage winner = ImageWin("Big Picture", w*zoom, h*zoom) r.draw(winner) winner.getMouse() winner.close() def main(): picname= raw_input("Enter Picture name with .jpg, .bmp, or ending: ") oImage= FileImage(picname) h= oImage.getHeight() w= oImage.getWidth() win = ImageWin("Original", w,h) oImage.draw(win) y = 0 zoom = input("Number of times to zoom: ") x = -(zoom) enlarge(oImage,w,h,x,y,zoom) win.getMouse() win.close() main()
![]() |
Similar Threads
- How get Image byte size & transfer Image over Socket? (Java)
- How to reduce the size of an image to a standard size say 40 kb (C#)
- nero burning (Windows Software)
- calculate image property in javascript (JavaScript / DHTML / AJAX)
Other Threads in the Python Forum
- Previous Thread: File with date + time
- Next Thread: Play a Musical Note (Python)
| Thread Tools | Search this Thread |
abrupt ansi anti apache approximation array assignment avogadro backend beginner binary bluetooth book builtin calculator character code converter countpasswordentry curved customdialog dan08 dictionaries dictionary dynamic examples exe file float format function gnu graphics gui heads homework ideas import inches input java launcher library line lines linux list lists loop mouse mysqlquery number numbers numeric output parsing path phonebook plugin pointer port prime programming progressbar projects py2exe pygame python random recursion redirect scrolledtext software statictext statistics string strings sum table terminal text textarea thread threading time tlapse trick tricks tuple tutorial twoup ubuntu unicode urllib urllib2 variable wordgame write wxpython xlib






