TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Bhavesh Vankar
761
1.1k
88k
C# Crop Image Code
Sep 7 2020 4:43 AM
i have one crop button image to crop image using jquery while selecting area for the crop image area selecting but when press crop button the image is not croping and displaying in image canvas below is my code kindly please suggest me.
string
filename =
"~/CapturedImage/"
+ DateTime.Now.ToString(
"dd-MM-yy hh-mm"
) +
".jpg"
;
//string filename = "~/CapturedImage/V_Image.jpg";
string
FilePath = Path.Combine(Server.MapPath(
"~/CapturedImage"
));
int
x = Convert.ToInt32(X.Value);
int
y = Convert.ToInt32(Y.Value);
int
w = Convert.ToInt32(W.Value);
int
h = Convert.ToInt32(H.Value);
//Loan The Image from location
if
(File.Exists(filename))
{
System.Drawing.Image image = Bitmap.FromFile(HttpContext.Current.Request.PhysicalApplicationPath + @
"\CapturedImage\" + DateTime.Now.ToString("
dd-MM-yy hh-mm
") + "
.jpg");
Bitmap bmpimage =
new
Bitmap(w, h, image.PixelFormat);
Graphics grpx = Graphics.FromImage(bmpimage);
grpx.DrawImage(image,
new
Rectangle(0, 0, w, h),
new
Rectangle(x, y, w, h), GraphicsUnit.Pixel);
bmpimage.Save(HttpContext.Current.Request.PhysicalApplicationPath + @
"\CroppedImage\" + DateTime.Now.ToString("
dd-MM-yy hh-mm
") + "
.jpg", image.RawFormat);
imgCapture.Dispose();
bmpimage =
null
;
imgCapture.ImageUrl = @
"\CroppedImage\" + DateTime.Now.ToString("
dd-MM-yy hh-mm
") + "
.jpg";
// imgCapture.ImageUrl = @"\CroppedImage\V_Image.jpg";
Reply
Answers (
3
)
Image not saving in folder.
Recapture Image error