当前位置: 移动技术网 > IT编程>开发语言>c# > C#图像重新着色的方法

C#图像重新着色的方法

2019年07月18日  | 移动技术网IT编程  | 我要评论

本文实例讲述了c#图像重新着色的方法。分享给大家供大家参考。具体实现方法如下:

using system;
using system.collections.generic;
using system.componentmodel;
using system.data;
using system.drawing;
using system.text;
using system.windows.forms;
using system.drawing.drawing2d;
using system.drawing.imaging;
namespace windowsapplication2
{
  public partial class form18 : form
  {
    public form18()
    {
      initializecomponent();
    }
    private void panel1_paint(object sender, painteventargs e)
    {
      graphics g = e.graphics;
      using (bitmap bmp = new bitmap(@"d:/我的文档/桌面/ico/administrator.bmp"))
      {
        colormap[] colormap = new colormap[1];
        colormap[0] = new colormap();
        colormap[0].oldcolor = color.blue;
        colormap[0].newcolor = color.white;
        imageattributes attr = new imageattributes();
        attr.setremaptable(colormap);
        rectangle rect = new rectangle(0, 0, bmp.width, bmp.height);
        rect.offset(0, 0);
        g.drawimage(bmp, rect, 0, 0, rect.width, rect.height, g.pageunit, attr);
      }
    }
  }
}

希望本文所述对大家的c#程序设计有所帮助。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网