public void TestRGBPixelOperatorMin() { RGBPixel a = new RGBPixel(1, 2, 3); RGBPixel b = new RGBPixel(5, 10, 100); RGBPixel act = RGBPixel.Min(a, b); Assert.Equal(new RGBPixel(1, 2, 3), act); RGBPixel c = new RGBPixel(0.3f, 3, 0.2f); act = RGBPixel.Min(a, c); Assert.Equal(new RGBPixel(0.3f, 2, 0.2f), act); }
public Task <RGBPixel[, ]> Mix(IList <RGBPixel[, ]> sources, ulong frame) { // Schneller Ausgang if (sources.Count == 1) { return(Task.FromResult(sources[0])); } Func <RGBPixel, RGBPixel, RGBPixel> fn; switch (this.Operator) { case Operatoren.Max: fn = (a, b) => a = RGBPixel.Max(a, b); break; case Operatoren.Min: fn = (a, b) => a = RGBPixel.Min(a, b); break; case Operatoren.Add: fn = (a, b) => a = a + b; break; case Operatoren.Sub: fn = (a, b) => a = a - b; break; case Operatoren.Mul: fn = (a, b) => a = a * b; break; case Operatoren.Div: fn = (a, b) => a = a / b; break; default: fn = (a, b) => a; break; } // erstes Ding klonen. RGBPixel[,] res = sources[0].Clone2(o => o); for (int i = 1; i < sources.Count; i++) { res.MapInplace(sources[i], fn); } return(Task.FromResult(res)); }