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
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Crop Image
Prashant Nimbare
Nov 27, 2012
5.7
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
This article is about crop the image to desire size in windows application
cropeImage.rar
CROP IMAGE
First design your form in like Following form
drag 1 picture box and button from ToolBox
on click event button write following Code
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;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public static Image GetThumbnailImage(string path, int width, int height)
{
using (Image image = Image.FromFile(path))
{
Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(ThumbnailCall);
return image.GetThumbnailImage(width, height, myCallback, IntPtr.Zero);
}
}
private static bool ThumbnailCall()
{
return false;
}
private void button1_Click(object sender, EventArgs e)
{
pictureBox1.Image = GetThumbnailImage(@"C:\Users\Administrator\Desktop\roger.jpg", 200, 200);
}
}
}
run your application ., click on load button
you will get following output..
Crop Image
Next Recommended Reading
Scan File From Scanner Using Flatbed And ADF With Windows Image Acquisition (WIA)