void ColorDodgeLayer(Layer layer) { var layers = ActiveImage.Layers; int index = layers.GetIndex(layer); var previous = layers[index + 1]; Console.WriteLine("layer: " + layer.Name); Console.WriteLine("previous: " + previous.Name); var srcPR = new PixelRgn(previous, false, false); var destPR = new PixelRgn(layer, false, false); #if false var iterator = new RegionIterator(srcPR, destPR); iterator.ForEach((src, dest) => { dest.Red = ColorDodge(src.Red, dest.Red); dest.Green = ColorDodge(src.Green, dest.Green); dest.Blue = ColorDodge(src.Blue, dest.Blue); }); #else var iterator = new RegionIterator(destPR); iterator.ForEach((dest) => {}); #endif }
void DoDifference(Drawable sourceDrawable, Drawable toDiffDrawable) { _indexedColorsMap = new IndexedColorsMap(); var rectangle = sourceDrawable.MaskBounds; var srcPR = new PixelRgn(sourceDrawable, rectangle, true, true); var destPR = new PixelRgn(toDiffDrawable, rectangle, false, false); var iterator = new RegionIterator(srcPR, destPR); iterator.ForEach((src, dest) => src.Set(MakeAbsDiff(dest, src))); sourceDrawable.Flush(); sourceDrawable.MergeShadow(false); sourceDrawable.Update(rectangle); }
public void Render(Image image, Drawable drawable) { var parser = new MathExpressionParser(); parser.Init(GetValue<string>("formula"), image.Dimensions); var newImage = new Image(image.Dimensions, image.BaseType); var srcPR = new PixelRgn(drawable, image.Bounds, false, false); PixelRgn destPR1 = null; var layer1 = AddLayer(newImage, 1, _("layer_one"), "translate_1_x", "translate_1_y", out destPR1); PixelRgn destPR2 = null; var layer2 = AddLayer(newImage, 2, _("layer_two"), "translate_2_x", "translate_2_y", out destPR2); var transparent = new Pixel(4); if (destPR1 != null && destPR2 != null) { var iterator = new RegionIterator(srcPR, destPR1, destPR2); iterator.ForEach((src, dest1, dest2) => { var tmp = Copy(src); if (parser.Eval(src) < 0) { dest1.Set(tmp); dest2.Set(transparent); } else { dest2.Set(tmp); dest1.Set(transparent); } }); } else if (destPR1 != null) { var iterator = new RegionIterator(srcPR, destPR1); iterator.ForEach((src, dest) => dest.Set((parser.Eval(src) < 0) ? Copy(src) : transparent)); } else // destPR2 != null { var iterator = new RegionIterator(srcPR, destPR2); iterator.ForEach((src, dest) => dest.Set((parser.Eval(src) >= 0) ? Copy(src) : transparent)); } Rotate(layer1, GetValue<int>("rotate_1")); Rotate(layer2, GetValue<int>("rotate_2")); if (GetValue<bool>("merge")) { var merged = newImage.MergeVisibleLayers(MergeType.ExpandAsNecessary); merged.Offsets = new Offset(0, 0); newImage.Resize(merged.Dimensions, merged.Offsets); } new Display(newImage); Display.DisplaysFlush(); }
public void Render(Image image, Drawable drawable) { var parser = new MathExpressionParser(); parser.Init(GetValue <string>("formula"), image.Dimensions); var newImage = new Image(image.Dimensions, image.BaseType); var srcPR = new PixelRgn(drawable, image.Bounds, false, false); PixelRgn destPR1 = null; var layer1 = AddLayer(newImage, 1, _("layer_one"), "translate_1_x", "translate_1_y", out destPR1); PixelRgn destPR2 = null; var layer2 = AddLayer(newImage, 2, _("layer_two"), "translate_2_x", "translate_2_y", out destPR2); var transparent = new Pixel(4); if (destPR1 != null && destPR2 != null) { var iterator = new RegionIterator(srcPR, destPR1, destPR2); iterator.ForEach((src, dest1, dest2) => { var tmp = Copy(src); if (parser.Eval(src) < 0) { dest1.Set(tmp); dest2.Set(transparent); } else { dest2.Set(tmp); dest1.Set(transparent); } }); } else if (destPR1 != null) { var iterator = new RegionIterator(srcPR, destPR1); iterator.ForEach((src, dest) => dest.Set((parser.Eval(src) < 0) ? Copy(src) : transparent)); } else // destPR2 != null { var iterator = new RegionIterator(srcPR, destPR2); iterator.ForEach((src, dest) => dest.Set((parser.Eval(src) >= 0) ? Copy(src) : transparent)); } Rotate(layer1, GetValue <int>("rotate_1")); Rotate(layer2, GetValue <int>("rotate_2")); if (GetValue <bool>("merge")) { var merged = newImage.MergeVisibleLayers(MergeType.ExpandAsNecessary); merged.Offsets = new Offset(0, 0); newImage.Resize(merged.Dimensions, merged.Offsets); } new Display(newImage); Display.DisplaysFlush(); }