您的位置:首页 > 编程语言 > C#

【C#】剪切出图片的一部分

2016-04-21 08:58 381 查看
using System.Drawing;
using System.Drawing.Imaging;

class Program
{
static void Main(string[] args)
{
// 画像を読み込む
string baseFilePath = @"C:\bitmapBase.gif";
Bitmap bmpBase = new Bitmap(baseFilePath);

// 画像を切り抜く
Rectangle rect = new Rectangle(20, 90, 450, 100);
Bitmap bmpNew = bmpBase.Clone(rect, bmpBase.PixelFormat);

// 画像をGIF形式で保存
string newFilePath = @"C:\ bitmapNew.gif";
bmpNew.Save(newFilePath, ImageFormat.Gif);

// 画像リソースを解放
bmpBase.Dispose();
bmpNew.Dispose();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: