本文整理匯總了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);
});