[函数名称]
图像木刻效果函数WoodCutProcess(WriteableBitmap
src)
[函数代码]
///<summary>
///
Wood cut process.
///</summary>
///<param
name="src">Source image.</param>
///<returns></returns>
publicstaticWriteableBitmap
WoodCutProcess(WriteableBitmap src)////17木刻处理
{
if(src!=null
)
{
int
w = src.PixelWidth;
h = src.PixelHeight;
WriteableBitmap
woodcutImage =newWriteableBitmap(w,h);
byte[]
temp = src.PixelBuffer.ToArray();
tempRGB = 0;
for
(int i = 0; i < temp.Length; i += 4)
tempRGB = (int)((temp[i]
+ temp[i + 1] + temp[i + 2]) / 3);
temp[i] = (byte)(tempRGB
> 122.5 ? 0 : 255);
temp[i + 1] = (byte)(tempRGB
temp[i + 2] = (byte)(tempRGB
tempRGB = 0;
}
Stream
sTemp = woodcutImage.PixelBuffer.AsStream();
sTemp.Seek(0,
SeekOrigin.Begin);
sTemp.Write(temp, 0, w * 4 * h);
return
woodcutImage;
else
returnnull;
}
}
[图像效果]