C#图像重新着色的方法
程序员文章站
2023-11-21 15:57:22
本文实例讲述了c#图像重新着色的方法。分享给大家供大家参考。具体实现方法如下:
using system;
using system.collections.g...
本文实例讲述了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#程序设计有所帮助。