private void AdjustHue(Image <Rgba32> source, Image <Rgba32> output, Rgba32 averageColor) { output.Mutate(c => { Parallel.For(0, source.Height, h => { var rowSpan = source.GetPixelRowSpan(h); for (int w = 0; w < source.Width; w++) { Rgba32 pixel = new Rgba32(); rowSpan[w].ToRgba32(ref pixel); int R = Math.Min(255, Math.Max(0, (pixel.R + averageColor.R) / 2)); int G = Math.Min(255, Math.Max(0, (pixel.G + averageColor.G) / 2)); int B = Math.Min(255, Math.Max(0, (pixel.B + averageColor.B) / 2)); Color clAvg = new Rgba32(Convert.ToByte(R), Convert.ToByte(G), Convert.ToByte(B)); Rgba32 pixelColor = clAvg.ToPixel <Rgba32>(); output[w, h] = pixelColor; } }); }); }
public override Image <TPixel> GetImage() { Image <TPixel> image = base.GetImage(); Color color = new Rgba32(this.r, this.g, this.b, this.a); image.GetRootFramePixelBuffer().FastMemoryGroup.Fill(color.ToPixel <TPixel>()); return(image); }
public override Image <TPixel> GetImage() { Image <TPixel> image = base.GetImage(); Color color = new Rgba32(this.r, this.g, this.b, this.a); image.GetPixelSpan().Fill(color.ToPixel <TPixel>()); return(image); }