This is a discussion on Image Croping in C# .net within the C# Programming forums, part of the Software Development category; Image Croping in C# .net Hi Guys, how to do the Image Croping in C#. Thanks in advance....
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi its very simple, Steps: 1. Create a windows class library project 2. Add the below method to the project using System; using System.Text; using System.Drawing; using System.Drawing.Imaging; public static Image ImageCrop(Image image, int left, int top, int width, int height) { Bitmap newImage = new Bitmap(width, height); Graphics g = Graphics.FromImage(newImage); newImage.SetResolution(image.HorizontalResolution, image.VerticalResolution); g.DrawImage(image, new Rectangle(0, 0, cropWidth, cropHeight), new Rectangle(left, top, width, height), GraphicsUnit.Pixel); return (Image)newImage; } 3. You can call this method like this Image myImage = System.Drawing.Image.FromFile(imageFileName); myImage = ImageCrop(myImage,0,0,1024,768); myImage.Save(newImageFileName, ImageFormat.Jpeg); Hope informative, |
| |||
| include the system.IO use the file objecet
__________________ flyers printing |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| DPI of an Image | Anandavinayagam | C# Programming | 6 | 12-12-2008 05:53 AM |
| Convert image to other image format using CODEC in .NET 3.0 | Mramesh | C# Programming | 0 | 02-07-2008 03:33 AM |
| How to create an image from panel background Image | S.Vinothkumar | C# Programming | 1 | 10-22-2007 03:52 AM |
| How to upload an image to DB in ASP.Net? | mobilegeek | ASP and ASP.NET Programming | 6 | 09-18-2007 11:18 PM |
| Rotating an Image | muthukumar | HTML, CSS and Javascript Coding Techniques | 1 | 07-30-2007 03:18 AM |