如何能在不改变在C#.NET决议中我裁剪图像? [英] How can I crop image without changing its resolution in C#.Net?

查看:135
本文介绍了如何能在不改变在C#.NET决议中我裁剪图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了个小程序来划分大型画册,并把他们的一部分。 当我导入所作形象Microsoft画图这个形象是96 DPI所以我的节目做得很好。

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.

不过,我已经是由Photoshop的决议是,当我裁剪这些图片新的裁切后的照片需要96 dpi的分辨率使大小为它们之间的尊重71.6 dpi的照片。

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.

非常感谢你。

推荐答案

Bitmap.clone ,您可以创建一个图像,然后你就可以保存的裁剪副本。它不应该更改分辨率,或任何东西(图像会显得更大,如果你在程序中放大更多的时候图像较小打开它)。它不能被用来扩展画布(你会得到内存不足的错误)。因此,只要抓住一个图片从文件,转换为位图,( System.Drawing中命名空间),并克隆它要小一些,然后将其保存。

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.

例如:

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");

这篇关于如何能在不改变在C#.NET决议中我裁剪图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆