private BitmapRGB24 ApplyEffectRGB24(BitmapRGB24 input) { ColorRGB24[] pix = new ColorRGB24[input.Size.Elements]; var c = this.Contrast; for (int i = 0; i < pix.Length; i++) { pix[i].Red = (byte)((pix[i].Red - 127) * c); pix[i].Green = (byte)((pix[i].Green - 127) * c); pix[i].Blue = (byte)((pix[i].Blue - 127) * c); } return(new BitmapRGB24(input.Size, pix)); }
private BitmapRGB24 ApplyEffectRGB24(BitmapRGB24 input) { ColorRGB24[] pix = new ColorRGB24[input.Size.Elements]; var c = this.Contrast; for (int i = 0; i < pix.Length; i++) { pix[i].Red = (byte)((pix[i].Red - 127) * c); pix[i].Green = (byte)((pix[i].Green - 127) * c); pix[i].Blue = (byte)((pix[i].Blue - 127) * c); } return new BitmapRGB24(input.Size, pix); }
private void BoxBlurRGB24(BitmapRGB24 input, BitmapRGB24 output, BitmapRGB32 mask = null) { Contract.Requires(input != null); Contract.Requires(output != null); Contract.Requires(input.Width == output.Width); Contract.Requires(input.Height == output.Height); int radius = this.Radius; int w = input.Width; int h = input.Height; var bmp = output; var pix = bmp.Pixels; float div = (float)Math.Pow((radius * 2 + 1), 2); for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { var tr = 0.0; var tg = 0.0; var tb = 0.0; for (int ky = -radius; ky <= radius; ky++) { for (int kx = -radius; kx <= radius; kx++) { var px = Math.Max(Math.Min(x + kx, w - 1), 0); var py = Math.Max(Math.Min(y + ky, h - 1), 0); var p = input[px, py]; tr += p.Red; tg += p.Green; tb += p.Blue; //div += 1; } } //total.Alpha = 1.0f; bmp[x, y] = new ColorRGB24((byte)(tr / 255.0 * (255.0 / div)), (byte)(tg / 255.0 * (255.0 / div)), (byte)(tb / 255.0 * (255.0 / div))); } } }