using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;
namespace WindowsFormsApplication1
{
public partial class imagecrop : Form
{
public
imagecrop()
{
InitializeComponent();
}
private
void btncrop_Click(object
sender, EventArgs e)
{
Bitmap
mybitmap;
Bitmap
mybitmapcropped;
Graphics
mygraphics;
Rectangle
rec = new Rectangle(0,
0, 250, 300);
mybitmap=new
Bitmap(@"E:\1.jpg");
mybitmapcropped = new Bitmap(200,
200);
mygraphics = Graphics.FromImage(mybitmapcropped);
mygraphics.DrawImage(mybitmap, new Rectangle(0,
0, mybitmapcropped.Width,
mybitmapcropped.Height),rec.Left,rec.Top,rec.Width,rec.Height,GraphicsUnit.Pixel);
mybitmap.Dispose();
mybitmapcropped.Save(@"E:\2.jpg",ImageFormat.Jpeg);
}
}
}
No comments:
Post a Comment