×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    9

    painting on images

    i want to draw on image...
    as if painting on image...
    i used .blit() method for image on canvas.. but m unsuccessful in completing this...
    pls someone guide me for PAINT ON IMAGE plsss....

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: painting on images

    How are you unsuccessful? What is going wrong? What exactly do you want to draw? Can you show us the code you tried?

    We can't help if you don't give as many details as possible.

  3. #3
    Registered User
    Join Date
    Nov 2010
    Posts
    9

    Re: painting on images

    sir i want to draw rectangles, or circle or simply use touchy paint http://wiki.forum.nokia.com/index.ph...User_Interface
    for image as background...
    so i just used
    img=Image.open(path)
    canvas.blit(img)
    and tried to paint.... but its giving me error .. INDENTATION PROBLEM
    Last edited by swt_planet; 2011-04-03 at 13:47.

  4. #4
    Registered User
    Join Date
    Nov 2010
    Posts
    9

    Re: painting on images

    M using Pys60 on symbian s60 i.e nokia 5233
    Last edited by swt_planet; 2011-04-03 at 13:55.

  5. #5
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: painting on images

    Then your code is not properly indented. Post the code you're using.

  6. #6
    Registered User
    Join Date
    Nov 2010
    Posts
    9

    Re: painting on images

    import appuifw
    import graphics
    import e32
    import key_codes


    appuifw.app.directional_pad=False;

    # define colour constants
    RGB_RED = (255, 0, 0)
    RGB_WHITE =(255, 255, 255)

    canvas=None
    global prev_pos
    prev_pos=[0,0]


    appuifw.app.screen = 'large'

    def handle_redraw(event):
    '''Define redraw function'''
    pass

    def handle_event(event):
    '''Define event callback function'''
    if event['type'] not in (key_codes.EButton1Up, key_codes.EButton1Down,key_codes.EDrag):
    return
    if event['type'] in (key_codes.EButton1Down, key_codes.EButton1Up):
    canvas.point((event['pos'][0], event['pos'][1]),outline=RGB_RED,width=10)
    canvas.point((event['pos'][0], event['pos'][1]),outline=RGB_RED,width=10)
    prev_pos[0]=event['pos'][0]
    prev_pos[1]=event['pos'][1]
    if event['type'] ==key_codes.EDrag:
    rect=(prev_pos[0], prev_pos[1],event['pos'][0], event['pos'][1])
    canvas.line(rect, outline=RGB_RED, width=10,fill=RGB_RED)
    prev_pos[0]=event['pos'][0]
    prev_pos[1]=event['pos'][1]

    canvas = appuifw.Canvas(event_callback=handle_event, redraw_callback=handle_redraw)
    appuifw.app.body = canvas
    img=Image.new((canvas.size[0],canvas.size[1]))
    bgimg=Image.open("E:\\data\\python\\imgname.jpg")
    canvas.blit(bgimg)

    appuifw.app.exit_key_handler = quit

    app_lock = e32.Ao_lock()
    app_lock.wait()

    #this is the code where m testing this function of drawing on images....

  7. #7
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: painting on images

    Please use code tags. Press the "Go Advanced" button under the quick reply field, and in the editor, press the button with the # symbol on it. Copy your code between the tags the editor inserts. That will preserve code indentation. Otherwise, the way you posted it, nothing is indented, which makes it impossible to spot the problem.

  8. #8
    Registered User
    Join Date
    Nov 2010
    Posts
    9

    Re: painting on images

    Code:
    import appuifw
    import graphics
    import e32
    import key_codes #import key_codes - required for touch event detection
     
    
    appuifw.app.directional_pad=False;
     
    # define colour constants
    RGB_RED = (255, 0, 0)
    RGB_WHITE =(255, 255, 255)
     
    canvas=None
    global prev_pos
    prev_pos=[0,0]
     
    # change application screen size to 'full'
    appuifw.app.screen = 'large' 
     
    def handle_redraw(event):
    	'''Define redraw function'''
    	pass
     
    def handle_event(event):
    	'''Define event callback function'''
    	if event['type'] not in (key_codes.EButton1Up, key_codes.EButton1Down,key_codes.EDrag):
    		return
    	if event['type'] in (key_codes.EButton1Down, key_codes.EButton1Up):
    		canvas.point((event['pos'][0], event['pos'][1]),outline=RGB_RED,width=10)
    		canvas.point((event['pos'][0], event['pos'][1]),outline=RGB_RED,width=10)
    		prev_pos[0]=event['pos'][0]
    		prev_pos[1]=event['pos'][1]
    	if event['type'] ==key_codes.EDrag:
    		rect=(prev_pos[0], prev_pos[1],event['pos'][0], event['pos'][1])
    		canvas.line(rect, outline=RGB_RED, width=10,fill=RGB_RED)
    		prev_pos[0]=event['pos'][0]
    		prev_pos[1]=event['pos'][1]
     
    canvas = appuifw.Canvas(event_callback=handle_event, redraw_callback=handle_redraw)    
    appuifw.app.body = canvas
    img=Image.new((canvas.size[0],canvas.size[1]))
    bgimg=Image.open('e:\\data\\python\\imgname.jpg')
    canvas.blit(bgimg)
    
    appuifw.app.exit_key_handler = quit
     
    # Clear the canvas
    canvas.clear(RGB_WHITE)
     
    app_lock = e32.Ao_lock()
    app_lock.wait()

  9. #9
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: painting on images

    I don't see any indentation problems... At what line does the error say the problem occurs? Please post the exact error message.

  10. #10
    Registered User
    Join Date
    Nov 2010
    Posts
    9

    Re: painting on images

    bgimg=Image.open('e\\data\\python\\imgname.jpg")
    Indentation error: unindented does not match any outer indentation level

Similar Threads

  1. efficiente way for painting images
    By TacB0sS in forum Mobile Java Games
    Replies: 4
    Last Post: 2009-06-24, 16:55
  2. painting on top of camera video input
    By rel1986 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 10
    Last Post: 2007-01-06, 09:57
  3. Problem on Delay painting
    By funfrock in forum Mobile Java General
    Replies: 2
    Last Post: 2004-07-13, 14:47
  4. Painting a string on a canvas
    By gerrykilleen in forum Mobile Java General
    Replies: 1
    Last Post: 2004-02-11, 16:50
  5. painting on whole screen on a 6610
    By thid in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2003-04-04, 06:46

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×