Last post Aug 23, 2012 05:00 AM by lasantha
Feb 14, 2011 11:26 AM|mscachette|LINK
I have been pulling out my hair trying to get this figured out and I need to tap the wisdom of the dotNet elite.
I am running dotNet 3.5 (VB.NET) , IIS7, Windows 7.
Basically, I have constructed a UI using a combination of two JQuery tools. JCrop and Resizable. Both are working on the client side and I need to save the optionally resized and optionally cropped photo after the user has completed their image manipulation.
At the moment, I have a class file that resizes images on the fly and crops them. But they scripts to handle the resized image and the cropped image are separate.
Here is the specifics:
Dim image As New Bitmap(ThumbWidth, ThumbHeight)
Dim g As Graphics = Graphics.FromImage(image)
' Load the file data.
Dim thumbnail As System.Drawing.Image
If ImageProcessType = ProcessType.Filename Then
thumbnail = System.Drawing.Image.FromFile(FileName)
thumbnail = System.Drawing.Image.FromStream(PostedFile)
Here is where I get stuck.
g.DrawImage(thumbnail, X1, Y1, ThumbWidth, ThumbHeight) 'This only handles resizing of the images and not the cropping
g.DrawImage(thumbnail, New Rectangle(0, 0, ThumbWidth, ThumbHeight), New Rectangle(X1, Y1, ThumbWidth, ThumbHeight), GraphicsUnit.Pixel) 'This handles the cropping already but not the resizing
My question is, which one of the roughly 30 overloaded graphics.drawimage (http://msdn.microsoft.com/en-us/library/system.drawing.graphics.drawimage.aspx)
should I use to where I can pass in 0s for X and Y coords for no crop, resize the image if the user has chosen to do so, and crop from within that resized image if the user has chosen to do so?
I have the following data available: (I could add more if I need to)
X and Y coords
Thumbnail Height and Width
Mar 27, 2011 03:51 PM|smirnov|LINK
Please look at my last post here. You have to provide coordinates of cropped area at the line with
graphic_crop.DrawImage(i, new Rectangle(0, 0, 75, 75), 0, 0, 75, 75, GraphicsUnit.Pixel);
where 0,0,75,75 is for 75x75 box.
Aug 23, 2012 05:00 AM|lasantha|LINK
Here good article.