【C#】剪切出图片的一部分
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();
}
本作品采用 知识共享署名-非商业性使用 2.5 中国大陆许可协议进行许可。 |