Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User ashraf fawzy's Avatar
    Join Date
    May 2010
    Location
    Egypt
    Posts
    418
    Hi all ,

    I want to load an image and preivew it on a canvas in the middle , How can I do that ??

    Code:
    pic=graphics.Image.open("c:\\data\\logo.jpg")
    left = (canvas.size[0]/2)/2
    top = (canvas.size[1]/2)/2
    img2 = pic.resize((canvas.size[0]/2,canvas.size[1]/2),(left,top)) # this gives error ?!
    canvas.blit(img2)

  2. #2
    Registered User mvuori's Avatar
    Join Date
    Jul 2008
    Posts
    90
    As allways... WHAT error?...

    But if you check the documentation, you will see that .resize has the following arguments: resize( newsize[, callback=None, keepaspect=0])

    You have the newsize right, but the rest are totally wrong.
    This should work: img2 = pic.resize(canvas.size[0]/2,canvas.size[1]/2)

  3. #3
    Registered User ashraf fawzy's Avatar
    Join Date
    May 2010
    Location
    Egypt
    Posts
    418
    So how can I set the image in the middle of the canvas ??

  4. #4
    Registered User AJ____92's Avatar
    Join Date
    Apr 2009
    Posts
    166
    well you can do the resize on the fly ( faster, but worser quality )
    canvas.blit( image, source = ((x1,y1),(x2,y2)) , target = ((x1,y1),(x2,y2)) )

    how to find out the x and y coordinates ?
    math + brain

  5. #5
    Registered User ashraf fawzy's Avatar
    Join Date
    May 2010
    Location
    Egypt
    Posts
    418
    Although the end of your answer seems to be sarcastic, but thanks for your help.

    By the way , Do you know how can we load contact thumbnail ?? I want to fetch it and preview it on canvas .

    thanks in advance.

  6. #6
    Registered User AJ____92's Avatar
    Join Date
    Apr 2009
    Posts
    166
    Sorry i never used such modules
    But i can give you a very good advice:
    Get the python reference book and look up all the functions of the modules you wanna use. There you can find usefull stuff, if not then you have one last chance to get to your target:
    custom C++ extension

Similar Threads

  1. SVG: How to position word in the middle of canvas
    By Digitale in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2009-07-05, 20:41
  2. Canvas: How to show only a image not a canvas background
    By ricardopcunha in forum Mobile Java General
    Replies: 13
    Last Post: 2009-02-16, 08:59
  3. problem in display an image button on canvas(Background image)
    By mramin05 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2008-11-12, 04:51
  4. Replies: 1
    Last Post: 2004-06-28, 09:57
  5. Canvas and image
    By j2me_raj in forum Mobile Java General
    Replies: 1
    Last Post: 2003-08-18, 13:21

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved