【发布时间】:2015-02-26 18:47:58
【问题描述】:
我正在尝试编写获取图像(PNG、JPG、BMP、ETC')裁剪和旋转图像的代码。 我想在不丢失信息的情况下裁剪图像(插值没有变化) 所以我正在使用
Bitmap target = new Bitmap(cropRect.Width, cropRect.Height);
using (Graphics g = Graphics.FromImage(target))
{
g.DrawImage(img, new Rectangle(0, 0, target.Width, target.Height),
cropRect,
GraphicsUnit.Pixel);
}
其中 target 是裁剪后的图像。 img 是原始图像,cropRect 是我要裁剪的裁剪矩形。 因为我保持图像大小(无缩放),所以不应该丢失任何信息。
之后我使用
旋转图像 target.RotateFlip(RotateFlipType.Rotate90FlipNone);
因为它是 90 度旋转 - 它应该保持无损。 那是对的吗? 我找不到有关该主题的任何文档,如果有人有链接,我将不胜感激!
【问题讨论】:
标签: c# image rotation crop lossless