protected override void InitDialogFromToken(EffectConfigToken effectToken) { CurvesEffectConfigToken token = (CurvesEffectConfigToken)effectToken; bool oldValue = finishTokenOnDropDownChanged; finishTokenOnDropDownChanged = false; switch (token.ColorTransferMode) { case ColorTransferMode.Luminosity: modeComboBox.SelectedItem = colorTransferNames.EnumValueToLocalizedName(ColorTransferMode.Luminosity); break; case ColorTransferMode.Rgb: modeComboBox.SelectedItem = colorTransferNames.EnumValueToLocalizedName(ColorTransferMode.Rgb); break; } finishTokenOnDropDownChanged = oldValue; curveControl.ControlPoints = (SortedList <int, int>[])token.ControlPoints.Clone(); curveControl.Invalidate(); curveControl.Update(); }
public override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, System.Drawing.Rectangle[] rois, int startIndex, int length) { CloudsEffectConfigToken token = (CloudsEffectConfigToken)parameters; UserBlendOp blendOp = token.BlendOp; if (blendOp is UserBlendOps.NormalBlendOp && EnvironmentParameters.PrimaryColor.A == 255 && EnvironmentParameters.SecondaryColor.A == 255) { // this is just an optimization blendOp = null; } this.scale = token.Amount1; this.power = token.Amount2 / 100.0f; this.seed = (byte)(token.Seed ^ instanceSeed); for (int i = startIndex; i < startIndex + length; ++i) { RenderClouds(dstArgs.Surface, rois[i]); if (blendOp != null) { blendOp.Apply(dstArgs.Surface, rois[i].Location, srcArgs.Surface, rois[i].Location, dstArgs.Surface, rois[i].Location, rois[i].Size); } } }
protected override void OnSetRenderInfo(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs) { CodeLabConfigToken sect = (CodeLabConfigToken)parameters; userEffect = sect.UserScriptObject; if (userEffect != null) { userEffect.EnvironmentParameters = this.EnvironmentParameters; try { userEffect.SetRenderInfo(sect.Preview ? sect.PreviewToken : null, dstArgs, srcArgs); fetchDebugMsg = true; } catch (Exception exc) { sect.LastExceptions.Add(exc); dstArgs.Surface.CopySurface(srcArgs.Surface); sect.UserScriptObject = null; userEffect.Dispose(); userEffect = null; } } base.OnSetRenderInfo(parameters, dstArgs, srcArgs); }
public override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { ThreeAmountsConfigToken token = (ThreeAmountsConfigToken)parameters; int hueDelta = token.Amount1; int satDelta = token.Amount2; int lightness = token.Amount3; // map the range [0,100] -> [0,100] and the range [101,200] -> [103,400] if (satDelta > 100) { satDelta = ((satDelta - 100) * 3) + 100; } UnaryPixelOp op; Surface dst = dstArgs.Surface; Surface src = srcArgs.Surface; if (hueDelta == 0 && satDelta == 100 && lightness == 0) { op = new UnaryPixelOps.Identity(); } else { op = new UnaryPixelOps.HueSaturationLightness(hueDelta, satDelta, lightness); } op.Apply(dst, src, rois, startIndex, length); }
public BackgroundEffectRenderer(Effect effect, EffectConfigToken effectToken, RenderArgs dstArgs, RenderArgs srcArgs, PdnRegion renderRegion, int tileCount, int workerThreads) { this.effect = effect; this.effectToken = effectToken; this.dstArgs = dstArgs; this.srcArgs = srcArgs; this.renderRegion = renderRegion; this.renderRegion.Intersect(dstArgs.Bounds); this.tileRegions = SliceUpRegion(renderRegion, tileCount, dstArgs.Bounds); this.tilePdnRegions = new PdnRegion[this.tileRegions.Length]; for (int i = 0; i < this.tileRegions.Length; ++i) { PdnRegion pdnRegion = Utility.RectanglesToRegion(this.tileRegions[i]); this.tilePdnRegions[i] = pdnRegion; } this.tileCount = tileCount; this.workerThreads = workerThreads; if ((effect.EffectDirectives & EffectDirectives.SingleThreaded) != 0) { this.workerThreads = 1; } this.threadPool = new Threading.ThreadPool(this.workerThreads, false); }
public RendererContext(BackgroundEffectRenderer ber, EffectConfigToken token, int threadNumber, int startOffset) { this.ber = ber; this.token = token; this.threadNumber = threadNumber; this.startOffset = startOffset; }
protected override void InitDialogFromToken(EffectConfigToken effectToken) { CloudEffectConfigToken token = (CloudEffectConfigToken)effectToken; numericUpDownFrequency.Value = (decimal)token.Frequency; numericUpDownPersistance.Value = (decimal)token.Persistance; numericUpDownOctaves.Value = (decimal)token.Octaves; numericUpDownAmplitude.Value = (decimal)token.Amplitude; trackBarCloudCoverage.Value = (int)(token.CloudCoverage * 10.0); trackBarCloudDensity.Value = (int)(token.CloudDensity * 10.0); switch (token.DisplayOption) { case CloudEffect.REPLACE_SOURCE: radioButtonSource.Checked = true; break; case CloudEffect.OVERLAY_PRIMARY: radioButtonPrimary.Checked = true; break; case CloudEffect.OVERLAY_SECONDARY: radioButtonSecondary.Checked = true; break; case CloudEffect.REPLACE_TRANSPARENT: radioButtonTransparent.Checked = true; break; default: break; } random1.Text = Convert.ToString(token.R1); random2.Text = Convert.ToString(token.R2); random3.Text = Convert.ToString(token.R3); }
public BackgroundEffectRenderer(Effect effect, EffectConfigToken effectToken, RenderArgs dstArgs, RenderArgs srcArgs, PdnRegion renderRegion, IRenderer <ColorAlpha8> clipMaskRenderer, int tileCount, int workerThreads) { this.effect = effect; this.effectToken = effectToken; this.dstArgs = dstArgs; this.srcArgs = srcArgs; this.renderRegion = renderRegion; this.renderRegion.Intersect(dstArgs.Bounds); this.tileCount = tileCount; if (effect.CheckForEffectFlags(EffectFlags.None | EffectFlags.SingleRenderCall)) { this.tileCount = 1; } this.tileRegions = this.SliceUpRegion(renderRegion, this.tileCount, dstArgs.Bounds); this.tilePdnRegions = new PdnRegion[this.tileRegions.Length]; for (int i = 0; i < this.tileRegions.Length; i++) { this.tilePdnRegions[i] = PdnRegion.FromRectangles(this.tileRegions[i]); } this.workerThreads = workerThreads; if (effect.CheckForEffectFlags(EffectFlags.None | EffectFlags.SingleThreaded)) { this.workerThreads = 1; } this.clipMaskRenderer = clipMaskRenderer; this.threadPool = new EffectRendererWorkItemQueue(WorkItemDispatcher.Default, WorkItemQueuePriority.Normal, workerThreads); }
public override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, System.Drawing.Rectangle[] rois, int startIndex, int length) { TwoAmountsConfigToken tact = (TwoAmountsConfigToken)parameters; PixelOp redEyeRemove = new UnaryPixelOps.RedEyeRemove(tact.Amount1, tact.Amount2); redEyeRemove.Apply(dstArgs.Surface, srcArgs.Surface, rois, startIndex, length); }
public void Start() { this.Abort(); this.aborted = false; if (this.effectToken != null) { try { this.effectTokenCopy = (EffectConfigToken)this.effectToken.Clone(); } catch (Exception exception) { this.exceptions.Add(exception); this.effectTokenCopy = null; } } this.threadShouldStop = false; this.OnStartingRendering(); this.thread = new Thread(new ThreadStart(this.ThreadFunction)); this.thread.Name = "BackgroundEffectRenderer"; this.threadInitialized = new ManualResetEvent(false); this.thread.Start(); this.threadInitialized.WaitOne(); this.threadInitialized.Close(); this.threadInitialized = null; }
private static unsafe void RenderWithClipMask(Effect effect, EffectConfigToken token, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, IRenderer <ColorAlpha8> clipMaskRenderer) { effect.Render(token, dstArgs, srcArgs, rois); if (!effect.IsCancelRequested && (clipMaskRenderer != null)) { RectInt32 bounds = RectangleUtil.Bounds(rois).ToRectInt32(); if (bounds.HasPositiveArea) { using (ISurface <ColorAlpha8> surface = clipMaskRenderer.UseTileOrToSurface(bounds)) { int width = bounds.Width; int height = bounds.Height; int left = bounds.Left; int top = bounds.Top; int bottom = bounds.Bottom; int stride = dstArgs.Surface.Stride; int num8 = srcArgs.Surface.Stride; int num9 = surface.Stride; ColorBgra *pointAddress = dstArgs.Surface.GetPointAddress(left, top); ColorBgra *bgraPtr2 = srcArgs.Surface.GetPointAddress(left, top); byte * numPtr = (byte *)surface.Scan0; for (int i = height; i > 0; i--) { ColorBgra.Underwrite(bgraPtr2, pointAddress, numPtr, width); pointAddress += stride; bgraPtr2 += num8; numPtr += num9; } } } } }
public override unsafe void Render( EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, System.Drawing.Rectangle[] rois, int startIndex, int length) { // First we blur the source, and write the result to the destination surface // Then we apply Brightness/Contrast with the input as the dst, and the output as the dst // Third, we apply the Screen blend operation so that dst = dst OVER src ThreeAmountsConfigToken token = (ThreeAmountsConfigToken)parameters; AmountEffectConfigToken blurToken = new AmountEffectConfigToken(token.Amount1); this.blurEffect.Render(blurToken, dstArgs, srcArgs, rois, startIndex, length); BrightnessAndContrastAdjustmentConfigToken bcToken = new BrightnessAndContrastAdjustmentConfigToken(token.Amount2, token.Amount3); this.bcAdjustment.Render(bcToken, dstArgs, dstArgs, rois, startIndex, length); for (int i = startIndex; i < startIndex + length; ++i) { Rectangle roi = rois[i]; for (int y = roi.Top; y < roi.Bottom; ++y) { ColorBgra *dstPtr = dstArgs.Surface.GetPointAddressUnchecked(roi.Left, y); ColorBgra *srcPtr = srcArgs.Surface.GetPointAddressUnchecked(roi.Left, y); screenBlendOp.Apply(dstPtr, srcPtr, dstPtr, roi.Width); } } }
public unsafe override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { Point[] points = ((MotionBlurEffectConfigToken)parameters).LinePoints; Surface dst = dstArgs.Surface; Surface src = srcArgs.Surface; for (int i = startIndex; i < startIndex + length; ++i) { Rectangle rect = rois[i]; for (int y = rect.Top; y < rect.Bottom; ++y) { ColorBgra *dstPtr = dst.GetPointAddress(rect.Left, y); for (int x = rect.Left; x < rect.Right; ++x) { Point a = new Point(x + points[0].X, y + points[0].Y); Point b = new Point(x + points[points.Length - 1].X, y + points[points.Length - 1].Y); // If both ends of this line are in bounds, we don't need to do silly clipping if (src.Bounds.Contains(a) && src.Bounds.Contains(b)) { *dstPtr = DoLineAverageUnclipped(points, x, y, dst, src); } else { *dstPtr = DoLineAverage(points, x, y, dst, src); } ++dstPtr; } } } }
public override unsafe void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { Point[] points = ((MotionBlurEffectConfigToken)parameters).LinePoints; Surface dst = dstArgs.Surface; Surface src = srcArgs.Surface; for (int i = startIndex; i < startIndex + length; ++i) { Rectangle rect = rois[i]; for (int y = rect.Top; y < rect.Bottom; ++y) { ColorBgra *dstPtr = dst.GetPointAddress(rect.Left, y); for (int x = rect.Left; x < rect.Right; ++x) { Point a = new Point(x + points[0].X, y + points[0].Y); Point b = new Point(x + points[points.Length - 1].X, y + points[points.Length - 1].Y); // If both ends of this line are in bounds, we don't need to do silly clipping if (src.Bounds.Contains(a) && src.Bounds.Contains(b)) { *dstPtr = DoLineAverageUnclipped(points, x, y, dst, src); } else { *dstPtr = DoLineAverage(points, x, y, dst, src); } ++dstPtr; } } } }
protected override void InitDialogFromToken(EffectConfigToken effectToken) { UnaryPixelOps.Level levels = ((LevelsEffectConfigToken)effectToken).Levels; float gamma = MaskGamma(levels); int lo = MaskAvg(levels.ColorOutLow); int hi = MaskAvg(levels.ColorOutHigh); int md = (int)(lo + (hi - lo) * Math.Pow(0.5, gamma)); outputHiUpDown.Value = hi; outputGammaUpDown.Value = (decimal)gamma; outputLowUpDown.Value = lo; inputHiUpDown.Value = MaskAvg(levels.ColorInHigh); inputLoUpDown.Value = MaskAvg(levels.ColorInLow); gradientOutput.SetValue(0, lo); gradientOutput.SetValue(1, md); gradientOutput.SetValue(2, hi); swatchInHigh.BackColor = levels.ColorInHigh.ToColor(); swatchInLow.BackColor = levels.ColorInLow.ToColor(); swatchOutMid.BackColor = levels.Apply(((HistogramRgb)histogramInput.Histogram).GetMeanColor()).ToColor(); swatchOutMid.Invalidate(); swatchOutHigh.BackColor = levels.ColorOutHigh.ToColor(); swatchOutLow.BackColor = levels.ColorOutLow.ToColor(); }
public EffectBenchmark(string name, int iterations, Effect effect, EffectConfigToken token, Surface image) : base(name + " (" + iterations + "x)") { this.effect = effect; this.token = token; this.image = image; this.iterations = iterations; }
protected override void OnSetRenderInfo(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs) { EffectPluginConfigToken token = (EffectPluginConfigToken)parameters; PGP = token.GP; Draw = token.Draw; if (PGP != null) MyRender(dstArgs.Surface, srcArgs.Surface); base.OnSetRenderInfo(parameters, dstArgs, srcArgs); }
public unsafe override void Render(EffectConfigToken configToken, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { EmbossEffectConfigToken eect = (EmbossEffectConfigToken)configToken; double[,] weights = eect.Weights; Surface dst = dstArgs.Surface; Surface src = srcArgs.Surface; for (int i = startIndex; i < startIndex + length; ++i) { Rectangle rect = rois[i]; // loop through each line of target rectangle for (int y = rect.Top; y < rect.Bottom; ++y) { int fyStart = 0; int fyEnd = 3; if (y == src.Bounds.Top) fyStart = 1; if (y == src.Bounds.Bottom - 1) fyEnd = 2; // loop through each point in the line ColorBgra *dstPtr = dst.GetPointAddress(rect.Left, y); for (int x = rect.Left; x < rect.Right; ++x) { int fxStart = 0; int fxEnd = 3; if (x == src.Bounds.Left) fxStart = 1; if (x == src.Bounds.Right - 1) fxEnd = 2; // loop through each weight double sum = 0.0; for (int fy = fyStart; fy < fyEnd; ++fy) { for (int fx = fxStart; fx < fxEnd; ++fx) { double weight = weights[fy, fx]; ColorBgra c = src.GetPointUnchecked(x - 1 + fx, y - 1 + fy); double intensity = (double)c.GetIntensityByte(); sum += weight * intensity; } } int iSum = (int)sum; iSum += 128; if (iSum > 255) iSum = 255; if (iSum < 0) iSum = 0; *dstPtr = ColorBgra.FromBgra((byte)iSum, (byte)iSum, (byte)iSum, 255); ++dstPtr; } } } }
public unsafe override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { AmountEffectConfigToken token = (AmountEffectConfigToken)parameters; foreach (Rectangle rect in rois) { RenderRect(token.Amount, srcArgs.Surface, dstArgs.Surface, rect); } }
public override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { lock (this) { SetRenderInfo(parameters, dstArgs, srcArgs); } this.gbEffect.Render(this.gbToken, dstArgs, srcArgs, rois, startIndex, length); }
public unsafe override void Render( EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, System.Drawing.Rectangle[] rois, int startIndex, int length) { AmountEffectConfigToken token = (AmountEffectConfigToken)parameters; float bulge = token.Amount; Surface dst = dstArgs.Surface; Surface src = srcArgs.Surface; float hw = dst.Width / 2.0f; float hh = dst.Height / 2.0f; float maxrad = Math.Min(hw, hh); float maxrad2 = maxrad * maxrad; float amt = token.Amount / 100.0f; for (int n = startIndex; n < startIndex + length; ++n) { Rectangle rect = rois[n]; for (int y = rect.Top; y < rect.Bottom; y++) { ColorBgra* dstPtr = dst.GetPointAddressUnchecked(rect.Left, y); ColorBgra* srcPtr = src.GetPointAddressUnchecked(rect.Left, y); float v = y - hh; for (int x = rect.Left; x < rect.Right; x++) { float u = x - hw; float r = (float)Math.Sqrt(u * u + v * v); float rscale; rscale = (1.0f - (r / maxrad)); if (rscale > 0) { rscale = 1 - amt * rscale * rscale; float xp = u * rscale; float yp = v * rscale; *dstPtr = src.GetBilinearSampleWrapped(xp + hw, yp + hh); } else { *dstPtr = *srcPtr; } ++dstPtr; ++srcPtr; } } } }
public unsafe override void Render( EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, System.Drawing.Rectangle[] rois, int startIndex, int length) { AmountEffectConfigToken token = (AmountEffectConfigToken)parameters; float bulge = token.Amount; Surface dst = dstArgs.Surface; Surface src = srcArgs.Surface; float hw = dst.Width / 2.0f; float hh = dst.Height / 2.0f; float maxrad = Math.Min(hw, hh); float maxrad2 = maxrad * maxrad; float amt = token.Amount / 100.0f; for (int n = startIndex; n < startIndex + length; ++n) { Rectangle rect = rois[n]; for (int y = rect.Top; y < rect.Bottom; y++) { ColorBgra *dstPtr = dst.GetPointAddressUnchecked(rect.Left, y); ColorBgra *srcPtr = src.GetPointAddressUnchecked(rect.Left, y); float v = y - hh; for (int x = rect.Left; x < rect.Right; x++) { float u = x - hw; float r = (float)Math.Sqrt(u * u + v * v); float rscale; rscale = (1.0f - (r / maxrad)); if (rscale > 0) { rscale = 1 - amt * rscale * rscale; float xp = u * rscale; float yp = v * rscale; *dstPtr = src.GetBilinearSampleWrapped(xp + hw, yp + hh); } else { *dstPtr = *srcPtr; } ++dstPtr; ++srcPtr; } } } }
protected override void InitDialogFromToken(EffectConfigToken effectToken) { CodeLabConfigToken sect = (CodeLabConfigToken)effectToken; txtScriptName.Text = sect.ScriptName; if (sect != null) { txtCode.Text = sect.UserCode; } }
protected override sealed void OnSetRenderInfo(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs) { this.token = (TToken)parameters; this.dstArgs = dstArgs; this.srcArgs = srcArgs; this.OnSetRenderInfo((TToken)parameters, dstArgs, srcArgs); base.OnSetRenderInfo(parameters, dstArgs, srcArgs); }
public unsafe override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { BrightnessAndContrastAdjustmentConfigToken token = (BrightnessAndContrastAdjustmentConfigToken)parameters; int contrast = token.Contrast; int brightness = token.Brightness; int multiply = token.Multiply; int divide = token.Divide; byte[] rgbTable = token.RgbTable; for (int r = startIndex; r < startIndex + length; ++r) { Rectangle rect = rois[r]; for (int y = rect.Top; y < rect.Bottom; ++y) { ColorBgra *srcRowPtr = srcArgs.Surface.GetPointAddress(rect.Left, y); ColorBgra *dstRowPtr = dstArgs.Surface.GetPointAddress(rect.Left, y); ColorBgra *dstRowEndPtr = dstRowPtr + rect.Width; if (divide == 0) { while (dstRowPtr < dstRowEndPtr) { ColorBgra col = *srcRowPtr; int i = col.GetIntensityByte(); uint c = rgbTable[i]; dstRowPtr->Bgra = (col.Bgra & 0xff000000) | c | (c << 8) | (c << 16); ++dstRowPtr; ++srcRowPtr; } } else { while (dstRowPtr < dstRowEndPtr) { ColorBgra col = *srcRowPtr; int i = col.GetIntensityByte(); int shiftIndex = i * 256; col.R = rgbTable[shiftIndex + col.R]; col.G = rgbTable[shiftIndex + col.G]; col.B = rgbTable[shiftIndex + col.B]; *dstRowPtr = col; ++dstRowPtr; ++srcRowPtr; } } } } return; }
protected override void OnSetRenderInfo(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs) { lock (this) { this.gbToken = new PropertyBasedEffectConfigToken(this.gbProps); this.gbToken.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, ((AmountEffectConfigToken)parameters).Amount); this.gbEffect.SetRenderInfo(this.gbToken, dstArgs, srcArgs); } base.OnSetRenderInfo(parameters, dstArgs, srcArgs); }
private void RenderTile(EffectConfigToken token, int tileIndex) { Rectangle[] rois = this.ber.tileRegions[tileIndex]; BackgroundEffectRenderer.RenderWithClipMask(this.ber.effect, token, this.ber.dstArgs, this.ber.srcArgs, rois, this.ber.clipMaskRenderer); PdnRegion renderedRegion = this.ber.tilePdnRegions[tileIndex]; if (!this.ber.threadShouldStop) { this.ber.OnRenderedTile(new RenderedTileEventArgs(renderedRegion, this.ber.tileCount, tileIndex)); } }
public override unsafe void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { TwoAmountsConfigToken tact = (TwoAmountsConfigToken)parameters; int dev = tact.Amount1 * tact.Amount1 / 64; //dev = target stddev / 16 int sat = tact.Amount2 * 4096 / 100; if (threadRand == null) { threadRand = new Random(unchecked (System.Threading.Thread.CurrentThread.GetHashCode() ^ unchecked ((int)DateTime.Now.Ticks))); } Random localRand = threadRand; int[] localLookup = lookup; for (int ri = startIndex; ri < startIndex + length; ++ri) { Rectangle rect = rois[ri]; for (int y = rect.Top; y < rect.Bottom; ++y) { ColorBgra *srcPtr = srcArgs.Surface.GetPointAddressUnchecked(rect.Left, y); ColorBgra *dstPtr = dstArgs.Surface.GetPointAddressUnchecked(rect.Left, y); for (int x = 0; x < rect.Width; ++x) { int r; int g; int b; int i; r = localLookup[localRand.Next(tableSize)]; g = localLookup[localRand.Next(tableSize)]; b = localLookup[localRand.Next(tableSize)]; i = (1867 * r + 9618 * g + 4899 * b) >> 14; r = i + (((r - i) * sat) >> 12); g = i + (((g - i) * sat) >> 12); b = i + (((b - i) * sat) >> 12); dstPtr->R = Utility.ClampToByte(srcPtr->R + ((r * dev * 16 + 32768) >> 16)); dstPtr->G = Utility.ClampToByte(srcPtr->G + ((g * dev * 16 + 32768) >> 16)); dstPtr->B = Utility.ClampToByte(srcPtr->B + ((b * dev * 16 + 32768) >> 16)); dstPtr->A = srcPtr->A; ++srcPtr; ++dstPtr; } } } }
public unsafe override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { TwoAmountsConfigToken token = (TwoAmountsConfigToken)parameters; this.radius = token.Amount1; this.spread = token.Amount2; foreach (Rectangle rect in rois) { RenderRect(this.radius, srcArgs.Surface, dstArgs.Surface, rect); } }
public override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { if (parameters is CurvesEffectConfigToken token) { UnaryPixelOp uop = token.Uop; for (int i = startIndex; i < startIndex + length; ++i) { uop.Apply(dstArgs.Surface, srcArgs.Surface, rois[i]); } } }
internal CodeLabConfigToken() { UserScriptObject = null; UserCode = ""; LastExceptions = new List <Exception>(); Output = new List <string>(); ScriptName = "Untitled"; ScriptPath = ""; Dirty = false; PreviewToken = null; Bookmarks = Array.Empty <int>(); ProjectType = ProjectType.Effect; }
private void RendererLoop(EffectConfigToken token) { try { while (this.RenderNextTile(token)) { } } catch (Exception exception) { this.ber.exceptions.Add(exception); } }
protected override void OnSetRenderInfo(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs) { CodeLabConfigToken sect = (CodeLabConfigToken)parameters; userEffect = sect.UserScriptObject; projectType = sect.ProjectType; if (projectType == ProjectType.Shape) { Size srcSize = EnvironmentParameters.SourceSurface.Size; Rectangle selection = EnvironmentParameters.SelectionBounds; ColorBgra strokeColor = EnvironmentParameters.PrimaryColor; ColorBgra fillColor = EnvironmentParameters.SecondaryColor; double strokeThickness = EnvironmentParameters.BrushWidth; Thread t = new Thread(() => { ShapeBuilder.SetEnviromentParams(srcSize.Width, srcSize.Height, selection.X, selection.Y, selection.Width, selection.Height, strokeColor, fillColor, strokeThickness); ShapeBuilder.RenderShape(sect.UserCode); }); t.SetApartmentState(ApartmentState.STA); t.Start(); t.Join(); shapeSurface?.Dispose(); shapeSurface = (ShapeBuilder.Shape != null) ? Surface.CopyFromBitmap(ShapeBuilder.Shape) : null; } else if (projectType == ProjectType.Effect && userEffect != null) { userEffect.EnvironmentParameters = this.EnvironmentParameters; try { userEffect.SetRenderInfo(sect.PreviewToken, dstArgs, srcArgs); fetchDebugMsg = true; } catch (Exception exc) { sect.LastExceptions.Add(exc); dstArgs.Surface.CopySurface(srcArgs.Surface); sect.UserScriptObject = null; userEffect?.Dispose(); userEffect = null; } } base.OnSetRenderInfo(parameters, dstArgs, srcArgs); }
public override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { CurvesEffectConfigToken token = parameters as CurvesEffectConfigToken; if (token != null) { UnaryPixelOp uop = token.Uop; for (int i = startIndex; i < startIndex + length; ++i) { uop.Apply(dstArgs.Surface, srcArgs.Surface, rois[i]); } } }
public override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { CloudEffectConfigToken token = (CloudEffectConfigToken)parameters; PdnRegion selectionRegion = EnvironmentParameters.GetSelection(srcArgs.Bounds); this.r1 = token.R1; this.r2 = token.R2; this.r3 = token.R3; for (int i = startIndex; i < startIndex + length; ++i) { Rectangle rect = rois[i]; for (int y = rect.Top; y < rect.Bottom; ++y) { for (int x = rect.Left; x < rect.Right; ++x) { if (selectionRegion.IsVisible(x, y)) { ColorBgra srcBgra = srcArgs.Surface[x, y]; byte c = (byte)(PerlinNoise2d(x, y, token) * 255); switch (token.DisplayOption) { case CloudEffect.REPLACE_SOURCE: dstArgs.Surface[x, y] = ColorBgra.FromBgra(srcBgra.B, srcBgra.G, srcBgra.R, c); break; case CloudEffect.OVERLAY_PRIMARY: ColorBgra primary = (ColorBgra)EnvironmentParameters.ForeColor; dstArgs.Surface[x, y] = ColorBgra.FromBgra(primary.B, primary.G, primary.R, c); break; case CloudEffect.OVERLAY_SECONDARY: ColorBgra secondary = (ColorBgra)EnvironmentParameters.BackColor; dstArgs.Surface[x, y] = ColorBgra.FromBgra(secondary.B, secondary.G, secondary.R, c); break; case CloudEffect.REPLACE_TRANSPARENT: dstArgs.Surface[x, y] = (0 == srcBgra.A) ? ColorBgra.FromBgra(srcBgra.B, srcBgra.G, srcBgra.R, c) : srcArgs.Surface[x, y]; break; default: break; } } } } } }
public override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { if (levels == null) { HistogramRgb histogram = new HistogramRgb(); histogram.UpdateHistogram(srcArgs.Surface, this.EnvironmentParameters.GetSelection(dstArgs.Bounds)); levels = histogram.MakeLevelsAuto(); } if (levels.isValid) { levels.Apply(dstArgs.Surface, srcArgs.Surface, rois, startIndex, length); } }
public unsafe override void Render( EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { AmountEffectConfigToken token = (AmountEffectConfigToken)parameters; foreach (Rectangle rect in rois) { RenderRect(token.Amount, srcArgs.Surface, dstArgs.Surface, rect); } }
public void Start() { Abort(); this.aborted = false; if (this.effectToken != null) { this.effectTokenCopy = (EffectConfigToken)this.effectToken.Clone(); } threadShouldStop = false; OnStartingRendering(); thread = new Thread(new ThreadStart(ThreadFunction)); thread.Start(); }
public unsafe override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { int width = srcArgs.Surface.Width; double[][] diffusion = new double[][] { new double[width], new double[width] }; int currentBuffer = 0; for (int y = 0; y < srcArgs.Surface.Height; y++) { byte* srcRow = (byte*)srcArgs.Surface.Scan0.Pointer + y * srcArgs.Surface.Stride; byte* dstRow = (byte*)dstArgs.Surface.Scan0.Pointer + y * dstArgs.Surface.Stride; Array.Clear(diffusion[currentBuffer], 0, width); currentBuffer = 1 - currentBuffer; bool forward = y % 2 == 0; int start = forward ? 0 : width - 1; int end = forward ? width : -1; int increment = forward ? 1 : -1; for (int x = start; x != end; x += increment) { double intensity = (0.0721 * srcRow[x * 4] + 0.7154 * srcRow[x * 4 + 1] + 0.2125 * srcRow[x * 4 + 2]) / 255.0; intensity += diffusion[currentBuffer][x]; double error = 0.0; if (intensity > 0.5) { error = intensity > 1.0 ? 0.0 : intensity - 1.0; *((uint*)(dstRow + x * 4)) = 0xFFFFFFFF; } else { error = intensity; *((uint*)(dstRow + x * 4)) = 0xFF000000; } diffusion[1 - currentBuffer][x] += (error * 5 / 16); if ((forward && x > start) || (!forward && x < start)) diffusion[1 - currentBuffer][x - increment] += (error * 3 / 16); if ((forward && x < width - 1) || (!forward && x > start + 1)) { diffusion[currentBuffer][x + increment] += (error * 7 / 16); diffusion[1 - currentBuffer][x + increment] += (error / 16); } } } }
protected override void InitDialogFromToken(EffectConfigToken effectToken) { MotionBlurEffectConfigToken token = (MotionBlurEffectConfigToken)effectToken; angleChooserControl.ValueDouble = token.Angle; distanceTrackBar.Value = token.Distance; centeredCheckBox.Checked = token.Centered; this.Text = PdnResources.GetString("MotionBlurEffectConfigDialog.Text"); this.degreeLabel.Text = PdnResources.GetString("MotionBlurEffectConfigDialog.DegreeLabel.Text"); this.pixelsLabel.Text = PdnResources.GetString("MotionBlurEffectConfigDialog.PixelsLabel.Text"); this.cancelButton.Text = PdnResources.GetString("Form.CancelButton.Text"); this.okButton.Text = PdnResources.GetString("Form.OkButton.Text"); this.centeredCheckBox.Text = PdnResources.GetString("MotionBlurEffectConfigDialog.CenteredCheckBox.Text"); this.angleHeader.Text = PdnResources.GetString("MotionBlurEffectConfigDialog.AngleHeader.Text"); this.distanceHeader.Text = PdnResources.GetString("MotionBlurEffectConfigDialog.DistanceHeader.Text"); }
public override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { PdnRegion selectionRegion = EnvironmentParameters.GetSelection(srcArgs.Bounds); for (int i = startIndex; i < startIndex + length; ++i) { Rectangle rect = rois[i]; for (int y = rect.Top; y < rect.Bottom; ++y) { for (int x = rect.Left; x < rect.Right; ++x) { // Render Code Here } } } }
protected override void InitDialogFromToken(EffectConfigToken effectToken) { base.InitDialogFromToken(effectToken); UserBlendOp setOp = ((CloudsEffectConfigToken)effectToken).BlendOp; if (setOp == null) { setOp = new UserBlendOps.NormalBlendOp(); } foreach (object op in this.comboBlendModes.Items) { if (0 == string.Compare(op.ToString(), setOp.ToString(), StringComparison.CurrentCultureIgnoreCase)) { this.comboBlendModes.SelectedItem = op; break; } } }
public override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { CodeLabConfigToken sect = (CodeLabConfigToken)parameters; Effect userEffect = sect.UserScriptObject; if (userEffect != null) { userEffect.EnvironmentParameters = this.EnvironmentParameters; try { userEffect.Render(null, dstArgs, srcArgs, rois, startIndex, length); } catch (Exception exc) { sect.LastExceptions.Add(exc); dstArgs.Surface.CopySurface(srcArgs.Surface); sect.UserScriptObject = null; } } }
public unsafe override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { AmountEffectConfigToken aecd = (AmountEffectConfigToken)parameters; for (int i = startIndex; i < startIndex + length; ++i) { Rectangle rect = rois[i]; for (int y = rect.Top; y < rect.Bottom; ++y) { int yEnd = y + 1; for (int x = rect.Left; x < rect.Right; ++x) { Rectangle cellRect = GetCellBox(x, y, aecd.Amount); cellRect.Intersect(dstArgs.Bounds); ColorBgra color = ComputeCellColor(x, y, srcArgs, aecd.Amount); int xEnd = Math.Min(rect.Right, cellRect.Right); yEnd = Math.Min(rect.Bottom, cellRect.Bottom); for (int y2 = y; y2 < yEnd; ++y2) { ColorBgra *ptr = dstArgs.Surface.GetPointAddressUnchecked(x, y2); for (int x2 = x; x2 < xEnd; ++x2) { ptr->Bgra = color.Bgra; ++ptr; } } x = xEnd - 1; } y = yEnd - 1; } } }
protected override void InitDialogFromToken(EffectConfigToken effectToken) { CurvesEffectConfigToken token = (CurvesEffectConfigToken)effectToken; bool oldValue = finishTokenOnDropDownChanged; finishTokenOnDropDownChanged = false; switch (token.ColorTransferMode) { case ColorTransferMode.Luminosity: modeComboBox.SelectedItem = colorTransferNames.EnumValueToLocalizedName(ColorTransferMode.Luminosity); break; case ColorTransferMode.Rgb: modeComboBox.SelectedItem = colorTransferNames.EnumValueToLocalizedName(ColorTransferMode.Rgb); break; } finishTokenOnDropDownChanged = oldValue; curveControl.ControlPoints = (SortedList<int, int>[])token.ControlPoints.Clone(); curveControl.Invalidate(); curveControl.Update(); }
public unsafe override void Render( EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, System.Drawing.Rectangle[] rois, int startIndex, int length) { ThreeAmountsConfigToken token = (ThreeAmountsConfigToken)parameters; Surface dst = dstArgs.Surface; Surface src = srcArgs.Surface; int width = dst.Width; int height = dst.Height; float hw = width / 2.0f; float hh = height / 2.0f; float sin = (float)Math.Sin(token.Amount1 * Math.PI / 180.0); float cos = (float)Math.Cos(token.Amount1 * Math.PI / 180.0); float scale = (float)Math.PI / token.Amount2; float intensity = token.Amount3; intensity = intensity * intensity / 10 * Math.Sign(intensity); int aaLevel = 4; int aaSamples = aaLevel * aaLevel + 1; PointF* aaPoints = stackalloc PointF[aaSamples]; for (int i = 0; i < aaSamples; ++i) { double x = (i * aaLevel) / (double)aaSamples; double y = i / (double)aaSamples; x -= (int)x; // RGSS + rotation to maximize AA quality aaPoints[i] = new PointF((float)(cos * x + sin * y), (float)(cos * y - sin * x)); } for (int n = startIndex; n < startIndex + length; ++n) { Rectangle rect = rois[n]; for (int y = rect.Top; y < rect.Bottom; y++) { float j = y - hh; ColorBgra* dstPtr = dst.GetPointAddressUnchecked(rect.Left, y); for (int x = rect.Left; x < rect.Right; x++) { int b = 0; int g = 0; int r = 0; int a = 0; float i = x - hw; for (int p = 0; p < aaSamples; ++p) { PointF pt = aaPoints[p]; float u = i + pt.X; float v = j - pt.Y; float s = cos * u + sin * v; float t = -sin * u + cos * v; s += intensity * (float)Math.Tan(s * scale); t += intensity * (float)Math.Tan(t * scale); u = cos * s - sin * t; v = sin * s + cos * t; int xSample = (int)(hw + u); int ySample = (int)(hh + v); xSample = (xSample + width) % width; if (xSample < 0) // This makes it a little faster { xSample = (xSample + width) % width; } ySample = (ySample + height) % height; if (ySample < 0) // This makes it a little faster { ySample = (ySample + height) % height; } ColorBgra sample = *src.GetPointAddressUnchecked(xSample, ySample); b += sample.B; g += sample.G; r += sample.R; a += sample.A; } *(dstPtr++) = ColorBgra.FromBgra( (byte)(b / aaSamples), (byte)(g / aaSamples), (byte)(r / aaSamples), (byte)(a / aaSamples)); } } } }
public override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { UnaryPixelOps.Level levels = (parameters as LevelsEffectConfigToken).Levels; levels.Apply(dstArgs.Surface, srcArgs.Surface, rois, startIndex, length); }
public unsafe override void Render(EffectConfigToken properties, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { TwoAmountsConfigToken token = (TwoAmountsConfigToken)properties; int brushSize = token.Amount1; byte smoothness = (byte)token.Amount2; Surface src = srcArgs.Surface; Surface dst = dstArgs.Surface; int width = src.Width; int height = src.Height; int arrayLens = 1 + smoothness; int* intensityCount = stackalloc int[arrayLens]; uint* avgRed = stackalloc uint[arrayLens]; uint* avgGreen = stackalloc uint[arrayLens]; uint* avgBlue = stackalloc uint[arrayLens]; uint* avgAlpha = stackalloc uint[arrayLens]; byte maxIntensity = smoothness; for (int r = startIndex; r < startIndex + length; ++r) { Rectangle rect = rois[r]; int rectTop = rect.Top; int rectBottom = rect.Bottom; int rectLeft = rect.Left; int rectRight = rect.Right; for (int y = rectTop; y < rectBottom; ++y) { ColorBgra *dstPtr = dst.GetPointAddress(rect.Left, y); int top = y - brushSize; int bottom = y + brushSize + 1; if (top < 0) { top = 0; } if (bottom > height) { bottom = height; } for (int x = rectLeft; x < rectRight; ++x) { int left = x - brushSize; int right = x + brushSize + 1; if (left < 0) { left = 0; } if (right > width) { right = width; } for (int i = 0; i < arrayLens; ++i) { intensityCount[i] = 0; avgRed[i] = 0; avgGreen[i] = 0; avgBlue[i] = 0; avgAlpha[i] = 0; } int numInt = 0; for (int j = top; j < bottom; ++j) { ColorBgra *srcPtr = src.GetPointAddress(left, j); for (int i = left; i < right; ++i) { byte intensity = (byte)((srcPtr->GetIntensityByte() * maxIntensity) / 255); ++intensityCount[intensity]; ++numInt; avgRed[intensity] += srcPtr->R; avgGreen[intensity] += srcPtr->G; avgBlue[intensity] += srcPtr->B; avgAlpha[intensity] += srcPtr->A; ++srcPtr; } } byte chosenIntensity = 0; int maxInstance = 0; for (int i = 0; i <= maxIntensity; ++i) { if (intensityCount[i] > maxInstance) { chosenIntensity = (byte)i; maxInstance = intensityCount[i]; } } byte R = (byte)(avgRed[chosenIntensity] / maxInstance); byte G = (byte)(avgGreen[chosenIntensity] / maxInstance); byte B = (byte)(avgBlue[chosenIntensity] / maxInstance); byte A = (byte)(avgAlpha[chosenIntensity] / maxInstance); *dstPtr = ColorBgra.FromBgra(B, G, R, A); ++dstPtr; } } } }
public unsafe override void Render(EffectConfigToken token, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { AmountEffectConfigToken realToken = (AmountEffectConfigToken)token; Surface src = srcArgs.Surface; Surface dst = dstArgs.Surface; int width = src.Width; int height = src.Height; int r = realToken.Amount; Random localRandom = this.random; int* intensityCount = stackalloc int[256]; uint* avgRed = stackalloc uint[256]; uint* avgGreen = stackalloc uint[256]; uint* avgBlue = stackalloc uint[256]; uint* avgAlpha = stackalloc uint[256]; byte* intensityChoices = stackalloc byte[(1 + (r * 2)) * (1 + (r * 2))]; for (int ri = startIndex; ri < startIndex + length; ++ri) { Rectangle rect = rois[ri]; int rectTop = rect.Top; int rectBottom = rect.Bottom; int rectLeft = rect.Left; int rectRight = rect.Right; for (int y = rectTop; y < rectBottom; ++y) { ColorBgra *dstPtr = dst.GetPointAddress(rect.Left, y); int top = y - r; int bottom = y + r + 1; if (top < 0) { top = 0; } if (bottom > height) { bottom = height; } for (int x = rectLeft; x < rectRight; ++x) { int intensityChoicesIndex = 0; for (int i = 0; i < 256; ++i) { intensityCount[i] = 0; avgRed[i] = 0; avgGreen[i] = 0; avgBlue[i] = 0; avgAlpha[i] = 0; } int left = x - r; int right = x + r + 1; if (left < 0) { left = 0; } if (right > width) { right = width; } for (int j = top; j < bottom; ++j) { if (j < 0 || j >= height) { continue; } ColorBgra *srcPtr = src.GetPointAddressUnchecked(left, j); for (int i = left; i < right; ++i) { byte intensity = srcPtr->GetIntensityByte(); intensityChoices[intensityChoicesIndex] = intensity; ++intensityChoicesIndex; ++intensityCount[intensity]; avgRed[intensity] += srcPtr->R; avgGreen[intensity] += srcPtr->G; avgBlue[intensity] += srcPtr->B; avgAlpha[intensity] += srcPtr->A; ++srcPtr; } } int randNum; lock (localRandom) { randNum = localRandom.Next(intensityChoicesIndex); } byte chosenIntensity = intensityChoices[randNum]; byte R = (byte)(avgRed[chosenIntensity] / intensityCount[chosenIntensity]); byte G = (byte)(avgGreen[chosenIntensity] / intensityCount[chosenIntensity]); byte B = (byte)(avgBlue[chosenIntensity] / intensityCount[chosenIntensity]); byte A = (byte)(avgAlpha[chosenIntensity] / intensityCount[chosenIntensity]); *dstPtr = ColorBgra.FromBgra(B, G, R, A); ++dstPtr; // prepare the array for the next loop iteration for (int i = 0; i < intensityChoicesIndex; ++i) { intensityChoices[i] = 0; } } } } }
public unsafe override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { RotateZoomEffectConfigToken token = (RotateZoomEffectConfigToken)parameters; RotateZoomEffectConfigToken.RzInfo rzInfo = token.ComputedOnce; Rectangle bounds = this.EnvironmentParameters.GetSelection(dstArgs.Bounds).GetBoundsInt(); bounds.Intersect(dstArgs.Bounds); Surface src = srcArgs.Surface; Surface dst = dstArgs.Surface; PdnRegion selection = this.EnvironmentParameters.GetSelection(src.Bounds); Rectangle srcBounds = src.Bounds; int srcMaxX = srcBounds.Width - 1; int srcMaxY = srcBounds.Height - 1; float dsxdx = rzInfo.dsxdx; float dsydx = rzInfo.dsydx; float dszdx = rzInfo.dszdx; float dsxdy = rzInfo.dsxdy; float dsydy = rzInfo.dsydy; float dszdy = rzInfo.dszdy; float zoom = token.Zoom; uint srcMask = token.SourceAsBackground ? 0xffffffff : 0; bool tile = token.Tile; float divZ = 0.5f * (float)Math.Sqrt(dst.Width * dst.Width + dst.Height * dst.Height); float centerX = (float)dst.Width / 2.0f; float centerY = (float)dst.Height / 2.0f; float tx = (token.Offset.X) * dst.Width / 2.0f; float ty = (token.Offset.Y) * dst.Height / 2.0f; uint tilingMask = tile ? 0xffffffff : 0; for (int i = startIndex; i < startIndex + length; ++i) { Rectangle rect = rois[i]; float cx = rzInfo.startX; float cy = rzInfo.startY; float cz = rzInfo.startZ; float mcl = ((rect.Left - tx) - dst.Width / 2.0f); cx += dsxdx * mcl; cy += dsydx * mcl; cz += dszdx * mcl; float mct = ((rect.Top - ty) - dst.Height / 2.0f); cx += dsxdy * mct; cy += dsydy * mct; cz += dszdy * mct; for (int y = rect.Top; y < rect.Bottom; ++y) { ColorBgra *dstPtr = dst.GetPointAddressUnchecked(rect.Left, y); ColorBgra *srcPtr = src.GetPointAddressUnchecked(rect.Left, y); float rx = cx; float ry = cy; float rz = cz; for (int x = rect.Left; x < rect.Right; ++x) { if (rz > -divZ) { float div = divZ / (zoom * (divZ + rz)); float u = (rx * div) + centerX; float v = (ry * div) + centerY; if (tile || (u >= -1 && v >= -1 && u <= srcBounds.Width && v <= srcBounds.Height)) { unchecked { int iu = (int)Math.Floor(u); uint sxfrac = (uint)(256 * (u - (float)iu)); uint sxfracinv = 256 - sxfrac; int iv = (int)Math.Floor(v); uint syfrac = (uint)(256 * (v - (float)iv)); uint syfracinv = 256 - syfrac; uint wul = (uint)(sxfracinv * syfracinv); uint wur = (uint)(sxfrac * syfracinv); uint wll = (uint)(sxfracinv * syfrac); uint wlr = (uint)(sxfrac * syfrac); uint inBoundsMaskLeft = tilingMask; uint inBoundsMaskTop = tilingMask; uint inBoundsMaskRight = tilingMask; uint inBoundsMaskBottom = tilingMask; int sx = iu; if (sx < 0) { sx = srcMaxX + ((sx + 1) % srcBounds.Width); } else if (sx > srcMaxX) { sx = sx % srcBounds.Width; } else { inBoundsMaskLeft = 0xffffffff; } int sy = iv; if (sy < 0) { sy = srcMaxY + ((sy + 1) % srcBounds.Height); } else if (sy > srcMaxY) { sy = sy % srcBounds.Height; } else { inBoundsMaskTop = 0xffffffff; } int sleft = sx; int sright; if (sleft == srcMaxX) { sright = 0; inBoundsMaskRight = (iu == -1) ? 0xffffffff : tilingMask; } else { sright = sleft + 1; inBoundsMaskRight = inBoundsMaskLeft & 0xffffffff; } int stop = sy; int sbottom; if (stop == srcMaxY) { sbottom = 0; inBoundsMaskBottom = (iv == -1) ? 0xffffffff : tilingMask; } else { sbottom = stop + 1; inBoundsMaskBottom = inBoundsMaskTop & 0xffffffff; } uint maskUL = inBoundsMaskLeft & inBoundsMaskTop; ColorBgra cul = ColorBgra.FromUInt32(src.GetPointUnchecked(sleft, stop).Bgra & maskUL); uint maskUR = inBoundsMaskRight & inBoundsMaskTop; ColorBgra cur = ColorBgra.FromUInt32(src.GetPointUnchecked(sright, stop).Bgra & maskUR); uint maskLL = inBoundsMaskLeft & inBoundsMaskBottom; ColorBgra cll = ColorBgra.FromUInt32(src.GetPointUnchecked(sleft, sbottom).Bgra & maskLL); uint maskLR = inBoundsMaskRight & inBoundsMaskBottom; ColorBgra clr = ColorBgra.FromUInt32(src.GetPointUnchecked(sright, sbottom).Bgra & maskLR); ColorBgra c = ColorBgra.BlendColors4W16IP(cul, wul, cur, wur, cll, wll, clr, wlr); if (c.A == 255 || !token.SourceAsBackground) { dstPtr->Bgra = c.Bgra; } else { *dstPtr = PaintDotNet.UserBlendOps.NormalBlendOp.ApplyStatic(*srcPtr, c); } } } else { if (srcMask != 0) { dstPtr->Bgra = srcPtr->Bgra; } else { dstPtr->Bgra = 0; } } } else { if (srcMask != 0) { dstPtr->Bgra = srcPtr->Bgra; } else { dstPtr->Bgra = 0; } } rx += dsxdx; ry += dsydx; rz += dszdx; ++dstPtr; ++srcPtr; } cx += dsxdy; cy += dsydy; cz += dszdy; } } }
protected override void InitDialogFromToken(EffectConfigToken effectToken) { base.InitDialogFromToken (effectToken); amount3Slider.Value = ((ThreeAmountsConfigToken)effectToken).Amount3; }
public override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length) { this.invertOp.Apply(dstArgs.Surface, srcArgs.Surface, rois, startIndex, length); }
protected override void InitDialogFromToken(EffectConfigToken effectToken) { EffectPluginConfigToken token = (EffectPluginConfigToken)effectToken; _apertureSize = token.ApertureSize; }