Click here to Skip to main content
15,887,856 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Assalam-o-Alaikum,
I am making a web application like facebook, But i am stuck at control mode of image, like fill mode, stretch mode etc

How can I upload an image to a particular mode either fill mode or stretch mode, just like to resize cover photo in facebook?
Posted

Alaikum Assalam,

If you want to crop and perform other image transformation in ASP.NET, on server side, you can use System.Drawing. Suppose you have some image. You can create an instance of other image, System.Drawing.Bitmap and get the instance of System.Drawing.Bitmap out of it. It allows you to draw on this bitmap. Here is how:
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.fromimage.aspx[^].

Then you can do any drawing on this bitmap, in particular, draw some other image, either with stretch, of cropped. Please see all different System.Drawing.Graphics.DrawImage methods:
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.aspx[^].

You can save the image in the file, but usually you deliver image immediately in HTTP response, without any file, using appropriate media type. Please see this MDSN page on System.Web.HttpResponse for the example of working with an image:
http://msdn.microsoft.com/en-us/library/system.web.httpresponse.aspx[^].

Good luck,
—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