public unsafe void HueSaturation(int hueDelta, int satDelta, int lightness) { ImageSurface dest = Surface.Clone(); ColorBgra * dstPtr = (ColorBgra *)dest.DataPtr; int len = Surface.Data.Length / 4; // map the range [0,100] -> [0,100] and the range [101,200] -> [103,400] if (satDelta > 100) { satDelta = ((satDelta - 100) * 3) + 100; } UnaryPixelOp op; if (hueDelta == 0 && satDelta == 100 && lightness == 0) { op = new UnaryPixelOps.Identity(); } else { op = new UnaryPixelOps.HueSaturationLightness(hueDelta, satDelta, lightness); } op.Apply(dstPtr, len); using (Context g = new Context(Surface)) { g.AppendPath(PintaCore.Workspace.ActiveDocument.Selection.SelectionPath); g.FillRule = Cairo.FillRule.EvenOdd; g.Clip(); g.SetSource(dest); g.Paint(); } (dest as IDisposable).Dispose(); }
public unsafe void HueSaturation(int hueDelta, int satDelta, int lightness) { ImageSurface dest = Surface.Clone (); ColorBgra* dstPtr = (ColorBgra*)dest.DataPtr; int len = Surface.Data.Length / 4; // map the range [0,100] -> [0,100] and the range [101,200] -> [103,400] if (satDelta > 100) satDelta = ((satDelta - 100) * 3) + 100; UnaryPixelOp op; if (hueDelta == 0 && satDelta == 100 && lightness == 0) op = new UnaryPixelOps.Identity (); else op = new UnaryPixelOps.HueSaturationLightness (hueDelta, satDelta, lightness); op.Apply (dstPtr, len); using (Context g = new Context (Surface)) { g.AppendPath (PintaCore.Layers.SelectionPath); g.FillRule = FillRule.EvenOdd; g.Clip (); g.SetSource (dest); g.Paint (); } (dest as IDisposable).Dispose (); }