views:

1412

answers:

3

Hi,

I made small program to divide large pictures and take part of them. When i import image that made by "Microsoft Paint" this image is "96 dpi" so my program doing well.

But I've pictures that made by Photoshop its resolution is 71.6 dpi when i crop these pictures the new cropped picture take 96 dpi resolution so the size is deference between them.

I want to crop the picture with keeping its resolution as it.

.

thank you very much

+2  A: 

DPI (dots per inch) is just a relationship between pixel size and the size on a medium. If you have an image which is 1024 x 768 pixels, it is 1024 x 768. There is no inherent DPI attached to a bitmap/binary file.

If you want to print that image on a printer which prints at 300 dpi, then you can calculate the size on the paper, for example.

splattne
Tell me what: what is big (in pixels) and what is small (in pixels). If you don't know the pixels, tell me the inches AND dpi you'll need. From inches AND dpi you can calculate the pixels.
splattne
It might be helpful to put that info in the question as well.
Lucas Jones
+1  A: 

The SetResolution() method of the Bitmap class allows you to specify the resolution of an image.

See http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.setresolution.aspx

Tarsier
+4  A: 

Bitmap.clone lets you create a cropped copy of an image, which you can then save. It shouldn't change resolution or anything (the image will look bigger if you open it in a program that zooms in more when images are smaller). It cannot be used to expand the canvas (you'll get out of memory errors). So, just grab an Image from file, cast to Bitmap, (system.drawing namespace) and clone it to be smaller, then save it.

Example:

using System.Drawing;
//...
Bitmap x = (Bitmap) Image.FromFile(@"c:\tmp\food.png");
Image x2 = x.Clone(new Rectangle(25, 25, 50, 50), x.PixelFormat);
x2.Save(@"c:\tmp\food2.png");
Brian
That's It Thank u very much.
Wahid Bitar