I’m beginner to HTML5 .
What I want to do is :
Upload an image in a canvas then allow the user to draw on this image ,so i can save this image in my database.
I learn how to draw through this lesson
But i don’t know how to open the image in the Canvas ,then let the user draw on this image .
If my understanding is correct :
You want to retrive an Image from the database, display it to the user to draw on it, then upload it back to the server to be stored in the database again !
1 – Create a IHttpHandler (.ashx) to return the image from the database
save this as getImage.ashx
2 – Add these lines in the InitThis() function on the Tutorial you quoted after ctx = document.getElementById(‘myCanvas’).getContext(“2d”); to display the picture on the canvas
Also you can add width and height to strech the image or fill the canvas :
3 – Upload the final drawing to the server again using the canvas’s toDataURL function and save the image to the database.
sending the canvas imagedata to the server :
reading and saving the image serverside :