Click here to Skip to main content
15,947,785 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to dynamically zoom image. and draw shapes on image
Posted

Please see my recent answer about zooming: Zoom image in C# .net mouse wheel[^].

Drawing shapes on the image is very similar to that. You can have a source image loaded from file, with something which would be a background for your shapes, the take the image which is already zoomed as described in my answer referenced above. At this moment, you already have the instance of System.Graphics you can use for drawing on the image. If you don't use zoom, the previous steps explains how to obtain such instance. This way, you can have original or zoomed image with some drawing on top of it.

For ASP.NET, you will need one more step. You either save your image on the server side and reference it in the <img> element generated on your ASP.NET page. But more likely, you would need to generate images on the fly, without saving a file. In this case, the URI used in the img src attribute should point to ASPX generating the image by using the class System.Net.HttpResponse and appropriate content type which will tell the browser it's an image of certain type:
http://msdn.microsoft.com/en-us/library/system.web.httpresponse.aspx[^].

The code sample shown in the MSDN article referenced above happens to be exactly what you need, generating a JPEG file, but you can generate PNG or anything else.

—SA
 
Share this answer
 
Comments
ridoy 22-Aug-13 16:42pm    
5ed!
Sergey Alexandrovich Kryukov 22-Aug-13 17:51pm    
Thank you very much.
—SA
Dholakiya Ankit 23-Aug-13 0:35am    
nice one 5+ how do u manage all this?
Sergey Alexandrovich Kryukov 23-Aug-13 0:56am    
Thank you. Manage what? Answering? Well, but solving some problems from time to time and reading MSDN and other things as required...
—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900