本文实例讲述了c#图像处理之木刻效果实现方法。分享给大家供大家参考。具体如下:
//木刻效果 public bitmap pfiltermuke(bitmap src) { try { bitmap a = new bitmap(src); rectangle rect = new rectangle(0, 0, a.width, a.height); system.drawing.imaging.bitmapdata bmpdata = a.lockbits(rect, system.drawing.imaging.imagelockmode.readwrite, system.drawing.imaging.pixelformat.format24bpprgb); int stride = bmpdata.stride; unsafe { byte* pin = (byte*)bmpdata.scan0.topointer(); byte* p; int r, g, b; int temp = 0; for (int y = 0; y < a.height; y++) { for (int x = 0; x < a.width; x++) { p = pin; b = p[0]; g = p[1]; r = p[2]; temp = (byte)((b + g + r) / 3); if (temp >= 122.5) { p[2] = 0; p[1] = 0; p[0] = 0; } else { p[2] = (byte)255; p[1] = (byte)255; p[0] = (byte)255; } pin += 3; } pin += stride - a.width * 3; } } a.unlockbits(bmpdata); return a; } catch (exception e) { messagebox.show(e.message.tostring()); return null; } }
原图:
效果图:
希望本文所述对大家的c#程序设计有所帮助。
如对本文有疑问, 点击进行留言回复!!
使用Visual Studio2019创建C#项目(窗体应用程序、控制台应用程序、Web应用程序)
C#实现获取本地内网(局域网)和外网(公网)IP地址的方法分析
网友评论