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....
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....
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.
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.
M using Pys60 on symbian s60 i.e nokia 5233
Last edited by swt_planet; 2011-04-03 at 13:55.
Then your code is not properly indented. Post the code you're using.
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....
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.
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()
I don't see any indentation problems... At what line does the error say the problem occurs? Please post the exact error message.
bgimg=Image.open('e\\data\\python\\imgname.jpg")
Indentation error: unindented does not match any outer indentation level