【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();
}
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();
}
相关文章推荐
- 【C#】取得并改变图像解析度
- c# MyXls 导出excel文件
- 细说C#多线程那些事-线程基础
- 拿什么拯救你,我的代码--c#编码规范实战篇
- C# 矩形面积 0002
- C# helloworld 0001
- C# 去除字符串前0,保留有效数字的解决方案
- [C#][Log4Net] 配置
- C#把白色背景变成透明
- c#使用WPD读取便携式设备信息一(枚举设备、连接设备及读取设备信息)
- c#winfrom PropertyGrid 运行时变更属性项
- C#线程同步的几种方法
- C#中的委托和事件
- (C#)WinForm窗体间传值
- 函数式编程——C#理解
- C#详解值类型和引用类型区别
- C#的Infinity和NaN
- C#命名参数的使用
- C#抽象类
- C#枚举简述