This is a post I am related to C # (C sharp). In this post, I will explain the steps of making the application of C #. Image Cropping application creation Tutorial is part of the C # application usage as it relates to the process image. Images are processed will be deducted according to the wishes. Now it's time to direct the implementation of the program.
Maybe
many of you already know very well about the programming language one,
namely how to slice images of any type by using the C # programming
language. In my implementation using stiap Microsoft Visual Studio 2012.
Please read :
1.
the first step, open the C # program and create a new file by choosing
File > > New Project (Ctrl + Shift + N) > > select Windows
Application, and name the file as per your liking (for example
CroppingImage) and press OK. Next would come an empty form.
2. a Component used for this simple program is:
• OpenFileDialog
• PictureBox
• Button
Click and put option component of the program which will be used as the image below :
3. Then double click on the button "Load" and add the following code:
OpenFileDialog file = new OpenFileDialog();
string lokasi = file.InitialDirectory;
lokasi = @"C:\Users\ardha\Desktop";
file.Title
= "Open Image File";
file.Filter = "Image
Files(*.jpg,*.png,*.tiff,*.bmp,*.gif)|*.jpg;*.png;*.tiff;*.bmp;*.gif";
file.FilterIndex = 2;
file.RestoreDirectory = true;
if (file.ShowDialog() == DialogResult.OK)
{
pictureBox1.Image = new Bitmap(file.FileName);
}
The purpose of the button loads the image file is to choose what you'd like displayed in the picture box. The desired file types can be specified via the syntax Filter (in the above example file.Filter),
whereas if you want to directly refer to a particular directory can be
used syntax InitialDirectory (in the above example file.InitialDirectory)
4. whereas, to change the image file onto keabuan, double click on the button "Cropping" and add the following code:
cropping();
Here we need a declaration for "Cropping" Cropping code, as follows:
private void cropping()
{
int cropX = 66;
int cropY = 120;
int cropWidth = 82;
int cropHeight = 80;
try
{
Rectangle rect = new Rectangle(cropX, cropY, cropWidth, cropHeight);
Bitmap OriginalImage = new Bitmap(pictureBox1.Image, pictureBox1.Width,
pictureBox1.Height);
Bitmap _img = new Bitmap(cropWidth, cropHeight);
Graphics g = Graphics.FromImage(_img);
g.InterpolationMode =
System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.PixelOffsetMode =
System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
g.CompositingQuality =
System.Drawing.Drawing2D.CompositingQuality.HighQuality;
g.DrawImage(OriginalImage, 0,
0, rect, GraphicsUnit.Pixel);
crop = new Bitmap(_img);
pictureBox1.Image = crop;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
} 5. in the writing of the code is needed. dll from AForge. dll can be downloaded here.
Add the following code:
using AForge.Imaging.Filters;
6. the application is complete, after adding the source code above, lives in the run course. And the results were as follows :
For more details on this please download program understanding program files and full-length project
download program files binary here
download full project here
for more information contact on ardhamail@gmail.com
Guide
to download: click on the download link above, after it would
appear adf.ly page, wait a few seconds until appears on the top right
corner of the ad skip writing. Click the button, the page will appear after that ziddu, please click on the download button that appears on the page ziddu
NB: in this tutorial program using the Visual studio IDE. with the target framework > 4.0. So
at a minimum your computer must be installed or windows vista or
windows xp with the .NET framework 4.0 to be able to run programs *.
exe, while for open projectnya inevitably must install microsoft visual
studio 2012
0 comments:
Post a Comment