本文整理汇总了C#中System.Drawing.Bitmap.LinearFilter方法的典型用法代码示例。如果您正苦于以下问题:C# Bitmap.LinearFilter方法的具体用法?C# Bitmap.LinearFilter怎么用?C# Bitmap.LinearFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Bitmap
的用法示例。
在下文中一共展示了Bitmap.LinearFilter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DarkerImage
public static Bitmap DarkerImage(Bitmap source, int val) =>
source.LinearFilter(input => {
var red = Max(0, input.R - val);
var green = Max(0, input.G - val);
var blue = Max(0, input.B - val);
return Color.FromArgb(red, green, blue);
});
示例2: BrighterImage
public static Bitmap BrighterImage(Bitmap source, int val) =>
source.LinearFilter(input => {
var red = Min(255, input.R + val);
var green = Min(255, input.G + val);
var blue = Min(255, input.B + val);
return Color.FromArgb(red, green, blue);
});
示例3: Invert
public static Bitmap Invert(Bitmap source) =>
source.LinearFilter(input => {
var red = 255 - input.R;
var green = 255 - input.G;
var blue = 255 - input.B;
return Color.FromArgb(red, green, blue);
});
示例4: SepiaTone
public static Bitmap SepiaTone(Bitmap source) =>
source.LinearFilter(input => {
var red = (int)(input.R * 0.462);
var green = (int)(input.G * 0.193);
var blue = (int)(input.B * 0.1083);
return Color.FromArgb(red, green, blue);
});
示例5: GrayScale
// the linear filters are just functions f: Color -> Color to process every pixel in parallel
public static Bitmap GrayScale(Bitmap source) =>
source.LinearFilter(input => {
var avg = (input.R + input.G + input.B)/3;
return Color.FromArgb(avg, avg, avg);
});