protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { this.angle = newToken.GetProperty<DoubleProperty>(PropertyNames.Angle).Value; // adjust and convert angle to radians double r = (double)this.angle * 2.0 * Math.PI / 360.0; // angle delta for each weight double dr = Math.PI / 4.0; // for r = 0 this builds an emboss filter pointing straight left this.weights = new double[3][]; for (int i = 0; i < 3; ++i) { this.weights[i] = new double[3]; } this.weights[0][0] = Math.Cos(r + dr); this.weights[0][1] = Math.Cos(r + 2.0 * dr); this.weights[0][2] = Math.Cos(r + 3.0 * dr); this.weights[1][0] = Math.Cos(r); this.weights[1][1] = 0; this.weights[1][2] = Math.Cos(r + 4.0 * dr); this.weights[2][0] = Math.Cos(r - dr); this.weights[2][1] = Math.Cos(r - 2.0 * dr); this.weights[2][2] = Math.Cos(r - 3.0 * dr); base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { Size = newToken.GetProperty <Int32Property>(PropertyNames.Size).Value; K = newToken.GetProperty <DoubleProperty>(PropertyNames.K).Value; InitializeIntegralImage(srcArgs.Surface); base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { this.radius = newToken.GetProperty<Int32Property>(PropertyNames.Radius).Value; this.strength = -0.2 * newToken.GetProperty<DoubleProperty>(PropertyNames.Strength).Value; base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { scale = newToken.GetProperty <Int32Property>(PropertyNames.Scale).Value; roughness = newToken.GetProperty <DoubleProperty>(PropertyNames.Roughness).Value; minOpacity = newToken.GetProperty <Int32Property>(PropertyNames.MinimumOpacity).Value; reseed = (byte)newToken.GetProperty <Int32Property>(PropertyNames.Reseed).Value; customColor = newToken.GetProperty <BooleanProperty>(PropertyNames.UseCustomColor).Value; color = ColorBgra.FromOpaqueInt32(newToken.GetProperty <Int32Property>(PropertyNames.Color).Value); if (emptySurface == null) { emptySurface = new Surface(srcArgs.Size); } if (cloudSurface == null) { cloudSurface = new Surface(srcArgs.Size); } // Call the Render Clouds function cloudsProps = cloudsEffect.CreatePropertyCollection(); PropertyBasedEffectConfigToken CloudsParameters = new PropertyBasedEffectConfigToken(cloudsProps); CloudsParameters.SetPropertyValue(CloudsEffect.PropertyNames.Scale, scale); CloudsParameters.SetPropertyValue(CloudsEffect.PropertyNames.Power, roughness); CloudsParameters.SetPropertyValue(CloudsEffect.PropertyNames.Seed, reseed); using (EffectEnvironmentParameters environParameters = new EffectEnvironmentParameters(ColorBgra.Black, Color.FromArgb(minOpacity, Color.Black), 0, EnvironmentParameters.GetSelectionAsPdnRegion(), emptySurface)) cloudsEffect.EnvironmentParameters = environParameters; cloudsEffect.SetRenderInfo(CloudsParameters, new RenderArgs(cloudSurface), new RenderArgs(emptySurface)); base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { int colorValue = newToken.GetProperty <Int32Property>(PropertyNames.Int32ColorWheel).Value; this.color = ColorBgra.FromOpaqueInt32(colorValue); base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { Amount1 = newToken.GetProperty <DoubleProperty>(PropertyNames.Amount1).Value; Amount2 = newToken.GetProperty <Int32Property>(PropertyNames.Amount2).Value; Amount3 = newToken.GetProperty <BooleanProperty>(PropertyNames.Amount3).Value; Amount4 = ColorBgra.FromOpaqueInt32(newToken.GetProperty <Int32Property>(PropertyNames.Amount4).Value); Amount5 = newToken.GetProperty <DoubleVectorProperty>(PropertyNames.Amount5).Value; base.OnSetRenderInfo(newToken, dstArgs, srcArgs); Bitmap puzzleBitmap = new Bitmap((int)(100 * Amount1), (int)(100 * Amount1), System.Drawing.Imaging.PixelFormat.Format32bppArgb); Graphics puzzleGraphics = Graphics.FromImage(puzzleBitmap); puzzleGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; Pen puzzlePen = new Pen(Amount4, Amount2); // Create points that define the horizontal curve. Point horPoint0 = new Point((int)(-50 * Amount1), (int)(16 * Amount1)); Point horPoint1 = new Point((int)(0 * Amount1), (int)(16 * Amount1)); Point horPoint2 = new Point((int)(13 * Amount1), (int)(28 * Amount1)); Point horPoint3 = new Point((int)(9 * Amount1), (int)(50 * Amount1)); Point horPoint4 = new Point((int)(49 * Amount1), (int)(49 * Amount1)); Point horPoint5 = new Point((int)(90 * Amount1), (int)(49 * Amount1)); Point horPoint6 = new Point((int)(86 * Amount1), (int)(71 * Amount1)); Point horPoint7 = new Point((int)(99 * Amount1), (int)(83 * Amount1)); Point horPoint8 = new Point((int)(149 * Amount1), (int)(83 * Amount1)); Point[] horCurvePoints = { horPoint0, horPoint1, horPoint2, horPoint3, horPoint4, horPoint5, horPoint6, horPoint7, horPoint8 }; // Draw the horizontal curve to graphics object. puzzleGraphics.DrawCurve(puzzlePen, horCurvePoints); // Create points that define the vertical curve. Point verPoint0 = new Point((int)(83 * Amount1), (int)(-50 * Amount1)); Point verPoint1 = new Point((int)(83 * Amount1), (int)(0 * Amount1)); Point verPoint2 = new Point((int)(73 * Amount1), (int)(13 * Amount1)); Point verPoint3 = new Point((int)(49 * Amount1), (int)(9 * Amount1)); Point verPoint4 = new Point((int)(50 * Amount1), (int)(50 * Amount1)); Point verPoint5 = new Point((int)(50 * Amount1), (int)(90 * Amount1)); Point verPoint6 = new Point((int)(28 * Amount1), (int)(86 * Amount1)); Point verPoint7 = new Point((int)(16 * Amount1), (int)(99 * Amount1)); Point verPoint8 = new Point((int)(16 * Amount1), (int)(149 * Amount1)); Point[] verCurvePoints = { verPoint0, verPoint1, verPoint2, verPoint3, verPoint4, verPoint5, verPoint6, verPoint7, verPoint8 }; // Draw the vertical curve to graphics object. puzzleGraphics.DrawCurve(puzzlePen, verCurvePoints); puzzlePen.Dispose(); puzzleSurface = Surface.CopyFromBitmap(puzzleBitmap); puzzleBitmap.Dispose(); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { this.radius = newToken.GetProperty<Int32Property>(PropertyNames.Radius).Value; this.percentile = newToken.GetProperty<Int32Property>(PropertyNames.Percentile).Value; base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { this.thickness = newToken.GetProperty<Int32Property>(PropertyNames.Thickness).Value; this.intensity = newToken.GetProperty<Int32Property>(PropertyNames.Intensity).Value; base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
private Settings GetSettings(PropertyBasedEffectConfigToken newToken) { var settings = new Settings(); settings.Text = newToken.GetProperty <StringProperty>(C.Properties.Text.ToString()).Value; settings.FontFamily = (FontFamily)newToken.GetProperty <StaticListChoiceProperty>(C.Properties.FontFamily.ToString()).Value; settings.FontSize = newToken.GetProperty <Int32Property>(C.Properties.FontSize.ToString()).Value; settings.LetterSpacing = newToken.GetProperty <DoubleProperty>(C.Properties.LetterSpacing.ToString()).Value; settings.LineSpacing = newToken.GetProperty <DoubleProperty>(C.Properties.LineSpacing.ToString()).Value; settings.AntiAliasLevel = newToken.GetProperty <Int32Property>(C.Properties.AntiAliasLevel.ToString()).Value; settings.FontStyle = settings.FontFamily.IsStyleAvailable(FontStyle.Regular) ? FontStyle.Regular : settings.FontFamily.IsStyleAvailable(FontStyle.Bold) ? FontStyle.Bold : FontStyle.Italic; settings.TextAlign = (C.TextAlignmentOptions)Enum.Parse(typeof(C.TextAlignmentOptions), newToken .GetProperty <StaticListChoiceProperty>(C.Properties.TextAlignment.ToString()) .Value.ToString()); if (newToken.GetProperty <BooleanProperty>(C.Properties.Bold.ToString()).Value&& settings.FontFamily.IsStyleAvailable(FontStyle.Bold)) { settings.FontStyle |= FontStyle.Bold; } if (newToken.GetProperty <BooleanProperty>(C.Properties.Italic.ToString()).Value&& settings.FontFamily.IsStyleAvailable(FontStyle.Italic)) { settings.FontStyle |= FontStyle.Italic; } if (newToken.GetProperty <BooleanProperty>(C.Properties.Underline.ToString()).Value&& settings.FontFamily.IsStyleAvailable(FontStyle.Underline)) { settings.FontStyle |= FontStyle.Underline; } if (newToken.GetProperty <BooleanProperty>(C.Properties.Strikeout.ToString()).Value&& settings.FontFamily.IsStyleAvailable(FontStyle.Strikeout)) { settings.FontStyle |= FontStyle.Strikeout; } return(settings); }
public ConfigToken ToToken(Dictionary <string, Type> effects, IServiceProvider services, Surface effectSourceSurface) { ConfigToken token = new ConfigToken(); for (int i = 0; i < Effects.Count; i++) { EffectConfigToken stepToken = null; Type type; if (effects.TryGetValue(Effects[i], out type)) { Effect effect = (Effect)(type.GetConstructor(Type.EmptyTypes).Invoke(new object[0])); effect.Services = services; effect.EnvironmentParameters = new EffectEnvironmentParameters(allcolors[i].First, allcolors[i].Second, 2, new PdnRegion(effectSourceSurface.Bounds), effectSourceSurface); if (effect.Options.Flags.HasFlag(EffectFlags.Configurable)) { try { EffectConfigDialog dialog = effect.CreateConfigDialog(); stepToken = dialog.EffectToken; if (effect is PropertyBasedEffect) { PropertyBasedEffectConfigToken pbect = stepToken as PropertyBasedEffectConfigToken; IEnumerator <Property> enumerator = pbect.Properties.Properties.GetEnumerator(); for (int ii = 0; ii < Properties[i].Length; ii++) { try { enumerator.MoveNext(); enumerator.Current.ReadOnly = false; if (enumerator.Current.Value is FontFamily) { enumerator.Current.Value = new FontFamily((string)Properties[i][ii]); } else { enumerator.Current.Value = Properties[i][ii]; } } catch (ReadOnlyException) { } } } else { Type t = stepToken.GetType(); SetObjectPropertiesAndFields(stepToken, Properties[i], Fields[i], effects, services, effectSourceSurface); } } catch (Exception) { } } token.effects.Add(new ScriptStep(effect.Name, effect.Image, type, stepToken, Colors[i].First, Colors[i].Second)); } else { token.effects.Add(new ScriptStep(Effects[i], null, null, null, Colors[i].First, Colors[i].Second)); } } return(token); }
/// <summary> /// Sets global effect parameters. /// </summary> /// <param name="parameters">The parameters.</param> /// <param name="dstArgs">The destination picture arguments.</param> /// <param name="srcArgs">The source picture arguments.</param> protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs) { if (_initialized == false) { _threshold = ComputeThresholding(srcArgs.Surface); _initialized = true; } }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { this.Value1 = (int)newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.Type).Value; this.Value2 = newToken.GetProperty <Int32Property>(PropertyNames.Aperture).Value; //this.Value3 = newToken.GetProperty<Int32Property>(PropertyNames.Tolerance).Value; //this.Value4 = newToken.GetProperty<BooleanProperty>(PropertyNames.Alpha).Value; base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { HistogramRgb histogram = new HistogramRgb(); histogram.UpdateHistogram(srcArgs.Surface, this.EnvironmentParameters.GetSelection(dstArgs.Bounds)); this.levels = histogram.MakeLevelsAuto(); base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken token, RenderArgs dstArgs, RenderArgs srcArgs) { m_Text = token.GetProperty <StringProperty>(PropertyNames.M_Text).Value; m_Modulus = token.GetProperty <Int32Property>(PropertyNames.M_Modulus).Value; m_Offset = token.GetProperty <Int32Property>(PropertyNames.M_Offset).Value; base.OnSetRenderInfo(token, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { DirSetting = newToken.GetProperty <StringProperty>(PropertyNames.DirSetting).Value; Filename = (byte)((int)newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.DirFiles).Value); Checkk = newToken.GetProperty <BooleanProperty>(PropertyNames.checkk).Value; base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { this.intensity = newToken.GetProperty<Int32Property>(PropertyNames.Intensity).Value; this.saturation = newToken.GetProperty<Int32Property>(PropertyNames.Saturation).Value; this.coverage = 0.01 * newToken.GetProperty<DoubleProperty>(PropertyNames.Coverage).Value; base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { if (FFTW.IsAvailable) { this.OnSetRenderInfoCore(newToken, dstArgs, srcArgs); } base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { this.tolerance = newToken.GetProperty<Int32Property>(PropertyNames.Tolerance).Value; this.saturation = newToken.GetProperty<Int32Property>(PropertyNames.Saturation).Value; this.redEyeOp = new UnaryPixelOps.RedEyeRemove(this.tolerance, this.saturation); base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
/// <summary> /// Sets global effect parameters. /// </summary> /// <param name="parameters">The parameters.</param> /// <param name="dstArgs">The destination picture arguments.</param> /// <param name="srcArgs">The source picture arguments.</param> protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs) { var wavelength = parameters.GetProperty <Int32Property>("Wavelength").Value; var orientation = parameters.GetProperty <DoubleProperty>("Orientation").Value *Math.PI / 180.0; var renderQuality = parameters.GetProperty <Int32Property>("RenderQuality").Value + 1; var binary = parameters.GetProperty <BooleanProperty>("Binary").Value; _convolutionPool = new GaborConvolutionPool(wavelength, orientation, renderQuality, binary); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { int fragments = newToken.GetProperty<Int32Property>(PropertyNames.Fragments).Value; double rotation = newToken.GetProperty<DoubleProperty>(PropertyNames.Rotation).Value; int distance = newToken.GetProperty<Int32Property>(PropertyNames.Distance).Value; RecalcPointOffsets(fragments, rotation, distance); base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { this.Amount1 = newToken.GetProperty <Int32Property>(PropertyNames.Amount1).Value; this.Amount2 = newToken.GetProperty <BooleanProperty>(PropertyNames.Amount2).Value; this.Amount3 = ColorBgra.FromOpaqueInt32(newToken.GetProperty <Int32Property>(PropertyNames.Amount3).Value); this.Amount4 = newToken.GetProperty <BooleanProperty>(PropertyNames.Amount4).Value; this.Amount5 = newToken.GetProperty <Int32Property>(PropertyNames.Amount5).Value; base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { this.zoom = newToken.GetProperty<DoubleProperty>(PropertyNames.Zoom).Value; this.quality = newToken.GetProperty<Int32Property>(PropertyNames.Quality).Value; this.angle = newToken.GetProperty<DoubleProperty>(PropertyNames.Angle).Value; this.angleTheta = (this.angle * Math.PI * 2) / 360.0; this.factor = newToken.GetProperty<DoubleProperty>(PropertyNames.Factor).Value; base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
/// <summary> /// </summary> protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken token, RenderArgs dstArgs, RenderArgs srcArgs) { // // This is an expensive operation, so pull the effect configuration once here rather than each time its needed during // effect rendering // _effectConfiguration = ShadowEffectConfiguration.FromToken(token); base.OnSetRenderInfo(token, dstArgs, srcArgs); }
protected override void OnSetRenderInfoCore(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { if (this._enumDropDown == null) { this._enumDropDown = new EnumDropDownValues <ValueSources>(); } this._isForwards = !newToken.GetProperty <BooleanProperty>(PropertyNames.FFTDirectionIsForward).Value; this._valueSource = this._enumDropDown.GetEnumMember(newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.ValueSource).Value); }
protected override void OnSetRenderInfo( PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { _colorChart = (ColorChart)newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.ColorChart).Value; _includeSecondaryColor = newToken.GetProperty <BooleanProperty>(PropertyNames.IncludeSecondaryColor).Value; _colorMap = ComputeColorMap(); base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { margin = newToken.GetProperty <Int32Property>(PropertyNames.Margin).Value; spread = newToken.GetProperty <Int32Property>(PropertyNames.Spread).Value; blur = newToken.GetProperty <Int32Property>(PropertyNames.Blur).Value; color = ColorBgra.FromUInt32(unchecked ((uint)newToken.GetProperty <Int32Property>(PropertyNames.Color).Value)); offsetX = newToken.GetProperty <Int32Property>(PropertyNames.OffsetX).Value; offsetY = newToken.GetProperty <Int32Property>(PropertyNames.OffsetY).Value; if (shadowSurface == null) { shadowSurface = new Surface(srcArgs.Surface.Size); } else { shadowSurface.Clear(Color.Transparent); } // Setup for calling the Gaussian Blur effect PropertyCollection blurProps = blurEffect.CreatePropertyCollection(); PropertyBasedEffectConfigToken BlurParameters = new PropertyBasedEffectConfigToken(blurProps); BlurParameters.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, blur); blurEffect.SetRenderInfo(BlurParameters, dstArgs, new RenderArgs(shadowSurface)); Rectangle selection = EnvironmentParameters.GetSelection(srcArgs.Surface.Bounds).GetBoundsInt(); PointF topStart = new PointF(selection.Left, selection.Top + (margin + spread + offsetY) / 2f); PointF topEnd = new PointF(selection.Right, selection.Top + (margin + spread + offsetY) / 2f); PointF rightStart = new PointF(selection.Right - (margin + spread - offsetX) / 2f, selection.Top); PointF rightEnd = new PointF(selection.Right - (margin + spread - offsetX) / 2f, selection.Bottom); PointF bottomStart = new PointF(selection.Left, selection.Bottom - (margin + spread - offsetY) / 2f); PointF bottomEnd = new PointF(selection.Right, selection.Bottom - (margin + spread - offsetY) / 2f); PointF leftStart = new PointF(selection.Left + (margin + spread + offsetX) / 2f, selection.Top); PointF leftEnd = new PointF(selection.Left + (margin + spread + offsetX) / 2f, selection.Bottom); using (Graphics shadow = new RenderArgs(shadowSurface).Graphics) using (Pen shadowPen = new Pen(color)) { shadowPen.Width = margin + spread + offsetX; shadow.DrawLine(shadowPen, leftStart, leftEnd); shadowPen.Width = margin + spread - offsetX; shadow.DrawLine(shadowPen, rightStart, rightEnd); shadowPen.Width = margin + spread + offsetY; shadow.DrawLine(shadowPen, topStart, topEnd); shadowPen.Width = margin + spread - offsetY; shadow.DrawLine(shadowPen, bottomStart, bottomEnd); } base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
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); }
/// <summary> /// Factory method for creating a ShadowEffectConfiguration object from the effect configuration token. /// </summary> /// <param name="token">The input token</param> /// <returns></returns> public static ShadowEffectConfiguration FromToken(PropertyBasedEffectConfigToken token) { return(new ShadowEffectConfiguration { Angle = (int)token.GetProperty <DoubleProperty>(ShadowEffectProperties.Angle).Value, DepthAngle = (int)token.GetProperty <DoubleProperty>(ShadowEffectProperties.DepthAngle).Value, Opacity = (double)(token.GetProperty <Int32Property>(ShadowEffectProperties.Opacity).Value), KeepOriginalImage = token.GetProperty <BooleanProperty>(ShadowEffectProperties.KeepOriginalImage).Value, DiffusionFactor = (int)token.GetProperty <Int32Property>(ShadowEffectProperties.DiffusionFactor).Value }); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken token, RenderArgs dstArgs, RenderArgs srcArgs) { m_TintStrength = token.GetProperty <DoubleProperty>(PropertyNames.M_TintStrength).Value; m_UseRgbPicker = token.GetProperty <BooleanProperty>(PropertyNames.M_UseRgbPicker).Value; m_RgbColor = ColorBgra.FromOpaqueInt32(token.GetProperty <Int32Property>(PropertyNames.M_RgbColor).Value); m_H = token.GetProperty <Int32Property>(PropertyNames.M_H).Value; m_S = token.GetProperty <Int32Property>(PropertyNames.M_S).Value; m_V = token.GetProperty <Int32Property>(PropertyNames.M_V).Value; base.OnSetRenderInfo(token, dstArgs, srcArgs); }
private void UpdatePropertiesIfNeeded(PropertyBasedEffectConfigToken newToken) { var whiteBalanceMethod = (WhiteBalanceMethod)newToken.GetProperty <StaticListChoiceProperty>(PropertyNames.WhiteBalanceMethod).Value; if (_lastSetWhiteBalanceMethod == whiteBalanceMethod) { return; } UpdateProperties(newToken, whiteBalanceMethod); _lastSetWhiteBalanceMethod = whiteBalanceMethod; }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { selection = EnvironmentParameters.GetSelection(srcArgs.Surface.Bounds).GetBoundsInt(); Thread t = new Thread(new ThreadStart(CopySelectionCoords)); t.SetApartmentState(ApartmentState.STA); t.Start(); t.Join(); base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { Rectangle selection = EnvironmentParameters.SelectionBounds; double rmax = Math.Max(selection.Height, selection.Width); innerRadius = newToken.GetProperty <DoubleProperty>(PropertyNames.InnerRadius).Value *rmax; outerRadius = newToken.GetProperty <DoubleProperty>(PropertyNames.OuterRadius).Value *rmax; center = newToken.GetProperty <DoubleVectorProperty>(PropertyNames.Center).Value; inverseAlpha = newToken.GetProperty <BooleanProperty>(PropertyNames.InverseAlpha).Value; repeatPerTurn = newToken.GetProperty <Int32Property>(PropertyNames.RepeatPerTurn).Value; angle = newToken.GetProperty <DoubleProperty>(PropertyNames.Angle).Value; base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { SelLower = newToken.GetProperty <Int32Property>(PropertyNames.SelLower).Value; SelUpper = newToken.GetProperty <Int32Property>(PropertyNames.SelUpper).Value; SizeLower = newToken.GetProperty <Int32Property>(PropertyNames.SizeLower).Value; SizeUpper = newToken.GetProperty <Int32Property>(PropertyNames.SizeUpper).Value; ReqLower = newToken.GetProperty <Int32Property>(PropertyNames.ReqLower).Value; ReqUpper = newToken.GetProperty <Int32Property>(PropertyNames.ReqUpper).Value; base.OnSetRenderInfo(newToken, dstArgs, srcArgs); PdnRegion selection = EnvironmentParameters.GetSelection(SrcArgs.Surface.Bounds); CustomOnRender(selection.GetRegionScansInt()); }
protected override void OnSetRenderInfo( PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { UpdatePropertiesIfNeeded(newToken); var redGain = newToken.GetProperty <DoubleProperty>(PropertyNames.RedGain).Value; var greenGain = newToken.GetProperty <DoubleProperty>(PropertyNames.GreenGain).Value; var blueGain = newToken.GetProperty <DoubleProperty>(PropertyNames.BlueGain).Value; _colorMap = ComputeColorMap(redGain, greenGain, blueGain); base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
/// <summary> /// Sets global effect parameters. /// </summary> /// <param name="parameters">The parameters.</param> /// <param name="dstArgs">The destination picture arguments.</param> /// <param name="srcArgs">The source picture arguments.</param> protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs) { if (_initialized == false) { picture = ToYCbCr(srcArgs.Surface); blendMap = Colorizer.ComputeBlendMap(picture, () => IsCancelRequested); if (blendMap != null) { _initialized = true; } } _blendFactor = parameters.GetProperty <Int32Property>("BlendFactor").Value; }
/// <summary> /// Called whenever the UI for the plugin is changed somehow. /// May be called more than once for the same change; uses test-lock-test to prevent doing the same thing twice. /// This code handles all of the resource allocation & initiates all of the computations needed for the plugin effect. /// </summary> /// <param name = "newToken"></param> /// <param name = "dstArgs"></param> /// <param name = "srcArgs"></param> protected override void OnSetRenderInfo( PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { this._filterName = _GetFilterName(newToken); this._copyToClipboard = _IsCopyToClipboard(newToken); // if something has changed, this is not a 'phantom' method call due to threading if (this._filterName != this._oldFilterName || this._copyToClipboard != this._oldCopyToClipboard) { lock (this._locker) { if (this._filterName != this._oldFilterName) { this._oldFilterName = this._filterName; var filterParameters = SupportedManipulators.Manipulators.FirstOrDefault(i => i.Item1 == this._filterName); Debug.Assert(filterParameters != null); var inputSurface = srcArgs.Surface; var sourceRectangle = this.EnvironmentParameters.GetSelection(inputSurface.Bounds).GetBoundsInt(); var targetRectangle = new Rectangle( sourceRectangle.X * filterParameters.Item2.ScaleFactorX, sourceRectangle.Y * filterParameters.Item2.ScaleFactorY, sourceRectangle.Width * filterParameters.Item2.ScaleFactorX, sourceRectangle.Height * filterParameters.Item2.ScaleFactorY ); var image = this._CreateImageFromSurface(inputSurface); var filtered = filterParameters.Item3(image, sourceRectangle); this._lastFilteredImage = this._CreateSurfaceFromImage(filtered, targetRectangle); this._lastTargetRectangle = targetRectangle; } if (this._copyToClipboard != this._oldCopyToClipboard) { this._oldCopyToClipboard = this._copyToClipboard; if (this._copyToClipboard) { this._DirectToClipboard(); } } } } // pass along control base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
public static ScriptLabScript FromToken(ConfigToken token) { ScriptLabScript sls = new ScriptLabScript(); foreach (ScriptStep step in token.effects) { if (step.EffectType == null) { sls.Add(step.Name, step.Name, new object[0], new object[0], Pair.Create(step.PrimaryColor, step.SecondaryColor)); } else if (step.Token == null) { sls.Add(step.EffectType.FullName + ":" + step.Name, step.Name, null, null, Pair.Create(step.PrimaryColor, step.SecondaryColor)); } else if (step.Token is PropertyBasedEffectConfigToken) { PropertyBasedEffectConfigToken pbect = step.Token as PropertyBasedEffectConfigToken; object[] properties = new object[pbect.Properties.Count]; IEnumerator <Property> enumerator = pbect.Properties.Properties.GetEnumerator(); for (int i = 0; i < pbect.Properties.Count; i++) { enumerator.MoveNext(); if (enumerator.Current.Value is FontFamily) { properties[i] = (enumerator.Current.Value as FontFamily).Name; } else if (enumerator.Current.Value.GetType().IsSerializable) { properties[i] = enumerator.Current.Value; } } sls.Add(step.EffectType.FullName + ":" + step.Name, step.Name, properties, null, Pair.Create(step.PrimaryColor, step.SecondaryColor)); } else { object[][] propertiesAndFields = MembersToObjectArray(step.Token); sls.Add(step.EffectType.FullName + ":" + step.Name, step.Name, propertiesAndFields[0], propertiesAndFields[1], Pair.Create(step.PrimaryColor, step.SecondaryColor)); } } return(sls); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { Rectangle selection = EnvironmentParameters.GetSelection(srcArgs.Surface.Bounds).GetBoundsInt(); Surface selectionSurface = new Surface(selection.Width, selection.Height); selectionSurface.CopySurface(srcArgs.Surface, selection); Surface stretchedSurface = new Surface(selection.Width * 2, selection.Height); stretchedSurface.FitSurface(ResamplingAlgorithm.Bicubic, selectionSurface); processedSurface = new Surface(srcArgs.Surface.Size); ColorBgra t; for (int y = 0; y < stretchedSurface.Height; y++) { if (IsCancelRequested) { return; } int v = selection.Left; for (int x = 0; x < stretchedSurface.Width; x += 2) { if (x % 2 == 0) { t.R = stretchedSurface[x, y].R; t.G = stretchedSurface[x + 1, y].G; if (x != stretchedSurface.Width - 2) { t.B = stretchedSurface[x + 2, y].B; } else { t.B = (byte)((stretchedSurface[stretchedSurface.Width - 1, y].B + stretchedSurface[stretchedSurface.Width - 2, y].B) >> 1); } processedSurface[v, y + selection.Top] = ColorBgra.FromBgr(t.B, t.G, t.R); v++; } } } base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { this.horMargin = newToken.GetProperty <Int32Property>(PropertyNames.HorMargin).Value; this.verMargin = newToken.GetProperty <Int32Property>(PropertyNames.VerMargin).Value; this.position = newToken.GetProperty <DoubleVectorProperty>(PropertyNames.Position).Value; Rectangle selection = this.EnvironmentParameters.GetSelection(srcArgs.Surface.Bounds).GetBoundsInt(); if (this.trimmedSurface is null) { Rectangle trimmedBounds = GetTrimmedBounds(srcArgs.Surface, selection); this.trimmedSurface = new Surface(trimmedBounds.Size); this.trimmedSurface.CopySurface(srcArgs.Surface, Point.Empty, trimmedBounds); } base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
/// <summary> /// Apply the selected property values /// </summary> /// <param name="newToken">UI property data</param> /// <param name="dstArgs">Destination information</param> /// <param name="srcArgs">Source information</param> protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { var start = newToken.GetProperty <Int32Property>(PropertyNames.PaletteStartIndex).Value; var end = newToken.GetProperty <Int32Property>(PropertyNames.PaletteEndIndex).Value; var palettes = Services.GetService <PaintDotNet.AppModel.IPalettesService>(); paletteBgra = palettes.CurrentPalette.Skip(start - 1).Take(end - start + 1).ToArray(); dithering = (DitheringMethods)((int)newToken.GetProperty <StaticListChoiceProperty>( PropertyNames.DitheringMethod).Value); ditheringAmount = (float)newToken.GetProperty <DoubleProperty>( PropertyNames.DitheringAmount).Value; keepOpacity = newToken.GetProperty <BooleanProperty>(PropertyNames.IgnoreAlpha).Value; base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { this.pencilTipSize = newToken.GetProperty<Int32Property>(PropertyNames.PencilTipSize).Value; this.colorRange = newToken.GetProperty<Int32Property>(PropertyNames.ColorRange).Value; PropertyBasedEffectConfigToken blurToken = new PropertyBasedEffectConfigToken(this.blurProps); blurToken.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, this.pencilTipSize); this.blurEffect.SetRenderInfo(blurToken, dstArgs, srcArgs); PropertyBasedEffectConfigToken bacToken = new PropertyBasedEffectConfigToken(this.bacProps); bacToken.SetPropertyValue(BrightnessAndContrastAdjustment.PropertyNames.Brightness, this.colorRange); bacToken.SetPropertyValue(BrightnessAndContrastAdjustment.PropertyNames.Contrast, -this.colorRange); this.bacAdjustment.SetRenderInfo(bacToken, dstArgs, dstArgs); this.desaturateEffect.SetRenderInfo(null, dstArgs, dstArgs); this.invertEffect.SetRenderInfo(null, dstArgs, dstArgs); base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { PropertyCollection blurValues = this.blurProps.Clone(); blurValues[GaussianBlurEffect.PropertyNames.Radius].Value = newToken.GetProperty<Int32Property>(PropertyNames.Radius).Value; PropertyBasedEffectConfigToken blurToken = new PropertyBasedEffectConfigToken(blurValues); this.blurEffect.SetRenderInfo(blurToken, dstArgs, srcArgs); PropertyCollection bcValues = this.bcProps.Clone(); bcValues[BrightnessAndContrastAdjustment.PropertyNames.Brightness].Value = newToken.GetProperty<Int32Property>(PropertyNames.Brightness).Value; bcValues[BrightnessAndContrastAdjustment.PropertyNames.Contrast].Value = newToken.GetProperty<Int32Property>(PropertyNames.Contrast).Value; PropertyBasedEffectConfigToken bcToken = new PropertyBasedEffectConfigToken(bcValues); this.bcAdjustment.SetRenderInfo(bcToken, dstArgs, dstArgs); // have to do adjustment in place, hence dstArgs for both 'args' parameters base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { this.angle = newToken.GetProperty<DoubleProperty>(PropertyNames.Angle).Value; this.distance = newToken.GetProperty<Int32Property>(PropertyNames.Distance).Value; this.centered = newToken.GetProperty<BooleanProperty>(PropertyNames.Centered).Value; PointF start = new PointF(0, 0); double theta = ((double)(this.angle + 180) * 2 * Math.PI) / 360.0; double alpha = (double)distance; double x = alpha * Math.Cos(theta); double y = alpha * Math.Sin(theta); PointF end = new PointF((float)x, (float)(-y)); if (this.centered) { start.X = -end.X / 2.0f; start.Y = -end.Y / 2.0f; end.X /= 2.0f; end.Y /= 2.0f; } this.points = new PointF[((1 + this.distance) * 3) / 2]; if (this.points.Length == 1) { this.points[0] = new PointF(0, 0); } else { for (int i = 0; i < this.points.Length; ++i) { float frac = (float)i / (float)(this.points.Length - 1); this.points[i] = Utility.Lerp(start, end, frac); } } base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { this.hue = newToken.GetProperty<Int32Property>(PropertyNames.Hue).Value; this.saturation = newToken.GetProperty<Int32Property>(PropertyNames.Saturation).Value; this.lightness = newToken.GetProperty<Int32Property>(PropertyNames.Lightness).Value; // map the range [0,100] -> [0,100] and the range [101,200] -> [103,400] if (this.saturation > 100) { this.saturation = ((this.saturation - 100) * 3) + 100; } if (this.hue == 0 && this.saturation == 100 && this.lightness == 0) { this.pixelOp = new UnaryPixelOps.Identity(); } else { this.pixelOp = new UnaryPixelOps.HueSaturationLightness(this.hue, this.saturation, this.lightness); } base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { int red = newToken.GetProperty<Int32Property>(PropertyNames.RedLevels).Value; int green = newToken.GetProperty<Int32Property>(PropertyNames.GreenLevels).Value; int blue = newToken.GetProperty<Int32Property>(PropertyNames.BlueLevels).Value; this.op = new PosterizePixelOp(red, green, blue); base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { double minRadiusP = newToken.GetProperty<DoubleProperty>(PropertyNames.MinScatterRadius).Value; this.minRadius = Math.Min(minRadiusP, Math.Min(srcArgs.Width, srcArgs.Height) / 2); this.maxRadius = newToken.GetProperty<DoubleProperty>(PropertyNames.MaxScatterRadius).Value; this.sampleCount = newToken.GetProperty<Int32Property>(PropertyNames.NumSamples).Value; base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo2(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { double scale = newToken.GetProperty<DoubleProperty>(PropertyNames.Scale).Value; double refraction = newToken.GetProperty<DoubleProperty>(PropertyNames.Refraction).Value; double detail1 = newToken.GetProperty<DoubleProperty>(PropertyNames.Roughness).Value; double detail2 = detail1; double roughness = detail2; double turbulence = newToken.GetProperty<DoubleProperty>(PropertyNames.Tension).Value; int quality = newToken.GetProperty<Int32Property>(PropertyNames.Quality).Value; byte newSeed = (byte)newToken.GetProperty<Int32Property>(PropertyNames.Seed).Value; this.seed = (byte)(this.instanceSeed ^ newSeed); this.scaleR = (400.0 / base.DefaultRadius) / scale; this.refractionScale = (refraction / 100.0) / scaleR; this.theta = Math.PI * 2.0 * turbulence / 10.0; this.roughness = roughness / 100.0; double detail3 = 1.0 + (detail2 / 10.0); // we don't want the perlin noise frequency components exceeding // the nyquist limit, so we will limit 'detail' appropriately double maxDetail = Math.Floor(Math.Log(this.scaleR) / Math.Log(0.5)); if (detail3 > maxDetail && maxDetail >= 1.0) { this.detail = maxDetail; } else { this.detail = detail3; } base.Quality = quality; base.OnSetRenderInfo2(newToken, dstArgs, srcArgs); }
void Render(Surface dst, Surface src, Rectangle rect) { // Setup for calling the Gaussian Blur effect GaussianBlurEffect blurEffect = new GaussianBlurEffect(); PropertyCollection blurProps = blurEffect.CreatePropertyCollection(); PropertyBasedEffectConfigToken BlurParameters = new PropertyBasedEffectConfigToken(blurProps); BlurParameters.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, Amount1); blurEffect.SetRenderInfo(BlurParameters, new RenderArgs(bluredSurface), new RenderArgs(alignedSurface)); // Call the Gaussian Blur function blurEffect.Render(new Rectangle[1] { rect }, 0, 1); // Setup for calling the Brightness and Contrast Adjustment function BrightnessAndContrastAdjustment bacAdjustment = new BrightnessAndContrastAdjustment(); PropertyCollection bacProps = bacAdjustment.CreatePropertyCollection(); PropertyBasedEffectConfigToken bacParameters = new PropertyBasedEffectConfigToken(bacProps); bacParameters.SetPropertyValue(BrightnessAndContrastAdjustment.PropertyNames.Brightness, Amount2); bacParameters.SetPropertyValue(BrightnessAndContrastAdjustment.PropertyNames.Contrast, 0); bacAdjustment.SetRenderInfo(bacParameters, new RenderArgs(lightSurface), new RenderArgs(bluredSurface)); // Call the Brightness and Contrast Adjustment function bacAdjustment.Render(new Rectangle[1] { rect }, 0, 1); for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) return; for (int x = rect.Left; x < rect.Right; x++) { if (Amount4) { dst[x, y] = normalOp.Apply(lightSurface[x, y], src[x, y]); } else { dst[x, y] = lightSurface[x, y]; } } } }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { this.amount = newToken.GetProperty<Int32Property>(PropertyNames.Amount).Value; this.offset = newToken.GetProperty<DoubleVectorProperty>(PropertyNames.Offset).Value; base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { int colorValue = newToken.GetProperty<Int32Property>(PropertyNames.Int32ColorWheel).Value; this.color = ColorBgra.FromOpaqueInt32(colorValue); base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { Amount1 = newToken.GetProperty<Int32Property>(PropertyNames.Amount1).Value; Amount2 = newToken.GetProperty<Int32Property>(PropertyNames.Amount2).Value; Amount3 = newToken.GetProperty<DoubleVectorProperty>(PropertyNames.Amount3).Value; Amount4 = newToken.GetProperty<BooleanProperty>(PropertyNames.Amount4).Value; Rectangle selection = EnvironmentParameters.GetSelection(srcArgs.Surface.Bounds).GetBoundsInt(); double ratio = (double)selection.Height / selection.Width; Bitmap srcBitmap = srcArgs.Surface.CreateAliasedBitmap(selection); Bitmap croppedBitmap = TrimBitmap(srcBitmap, ratio, Amount3.First, Amount3.Second); srcBitmap.Dispose(); if (croppedBitmap == null) croppedBitmap = new Bitmap(srcArgs.Surface.Width, srcArgs.Surface.Height); Surface croppedSurface = Surface.CopyFromBitmap(croppedBitmap); croppedBitmap.Dispose(); if (enlargedSurface == null) enlargedSurface = new Surface(selection.Size); enlargedSurface.FitSurface(ResamplingAlgorithm.Bicubic, croppedSurface); if (alignedSurface == null) alignedSurface = new Surface(srcArgs.Surface.Size); if (selection.Size != srcArgs.Surface.Size) { for (int y = Math.Max(0, selection.Top - 200); y < Math.Min(alignedSurface.Height, selection.Bottom + 200); y++) { if (IsCancelRequested) return; for (int x = Math.Max(0, selection.Left - 200); x < Math.Min(alignedSurface.Width, selection.Right + 200); x++) { alignedSurface[x, y] = enlargedSurface.GetBilinearSampleClamped(x - selection.Left, y - selection.Top); } } } else { alignedSurface = enlargedSurface; } if (bluredSurface == null) bluredSurface = new Surface(srcArgs.Surface.Size); if (lightSurface == null) lightSurface = new Surface(srcArgs.Surface.Size); base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { this.angle = newToken.GetProperty<DoubleProperty>(PropertyNames.Angle).Value; this.offsetX = newToken.GetProperty<DoubleVectorProperty>(PropertyNames.Offset).ValueX; this.offsetY = newToken.GetProperty<DoubleVectorProperty>(PropertyNames.Offset).ValueY; this.quality = newToken.GetProperty<Int32Property>(PropertyNames.Quality).Value; base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { this.brushSize = newToken.GetProperty<Int32Property>(PropertyNames.BrushSize).Value; this.coarseness = (byte)newToken.GetProperty<Int32Property>(PropertyNames.Coarseness).Value; base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { Rectangle selection = EnvironmentParameters.GetSelection(srcArgs.Surface.Bounds).GetBoundsInt(); Surface selectionSurface = new Surface(selection.Width, selection.Height); selectionSurface.CopySurface(srcArgs.Surface, selection); Surface stretchedSurface = new Surface(selection.Width * 2, selection.Height); stretchedSurface.FitSurface(ResamplingAlgorithm.Bicubic, selectionSurface); processedSurface = new Surface(srcArgs.Surface.Size); ColorBgra t; for (int y = 0; y < stretchedSurface.Height; y++) { if (IsCancelRequested) return; int v = selection.Left; for (int x = 0; x < stretchedSurface.Width; x += 2) { if (x % 2 == 0) { t.R = stretchedSurface[x, y].R; t.G = stretchedSurface[x + 1, y].G; if (x != stretchedSurface.Width - 2) { t.B = stretchedSurface[x + 2, y].B; } else { t.B = (byte)((stretchedSurface[stretchedSurface.Width - 1, y].B + stretchedSurface[stretchedSurface.Width - 2, y].B) >> 1); } processedSurface[v, y + selection.Top] = ColorBgra.FromBgr(t.B, t.G, t.R); v++; } } } base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { this.brightness = newToken.GetProperty<Int32Property>(PropertyNames.Brightness).Value; this.contrast = newToken.GetProperty<Int32Property>(PropertyNames.Contrast).Value; if (this.contrast < 0) { this.multiply = this.contrast + 100; this.divide = 100; } else if (this.contrast > 0) { this.multiply = 100; this.divide = 100 - this.contrast; } else { this.multiply = 1; this.divide = 1; } if (this.rgbTable == null) { this.rgbTable = new byte[65536]; } if (this.divide == 0) { for (int intensity = 0; intensity < 256; ++intensity) { if (intensity + this.brightness < 128) { this.rgbTable[intensity] = 0; } else { this.rgbTable[intensity] = 255; } } } else if (this.divide == 100) { for (int intensity = 0; intensity < 256; ++intensity) { int shift = (intensity - 127) * this.multiply / this.divide + 127 - intensity + this.brightness; for (int col = 0; col < 256; ++col) { int index = (intensity * 256) + col; this.rgbTable[index] = Utility.ClampToByte(col + shift); } } } else { for (int intensity = 0; intensity < 256; ++intensity) { int shift = (intensity - 127 + this.brightness) * this.multiply / this.divide + 127 - intensity; for (int col = 0; col < 256; ++col) { int index = (intensity * 256) + col; this.rgbTable[index] = Utility.ClampToByte(col + shift); } } } base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { this.softness = newToken.GetProperty<Int32Property>(PropertyNames.Softness).Value; this.lighting = newToken.GetProperty<Int32Property>(PropertyNames.Lighting).Value; this.warmth = newToken.GetProperty<Int32Property>(PropertyNames.Warmth).Value; PropertyBasedEffectConfigToken blurToken = new PropertyBasedEffectConfigToken(this.blurProps); blurToken.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, this.softness * 3); this.blurEffect.SetRenderInfo(blurToken, dstArgs, srcArgs); PropertyBasedEffectConfigToken bacToken = new PropertyBasedEffectConfigToken(this.bacProps); bacToken.SetPropertyValue(BrightnessAndContrastAdjustment.PropertyNames.Brightness, this.lighting); bacToken.SetPropertyValue(BrightnessAndContrastAdjustment.PropertyNames.Contrast, -this.lighting / 2); this.bacAdjustment.SetRenderInfo(bacToken, dstArgs, dstArgs); base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override sealed void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { Rectangle selection = this.EnvironmentParameters.GetSelection(srcArgs.Bounds).GetBoundsInt(); this.defaultRadius = Math.Min(selection.Width, selection.Height) * 0.5; this.defaultRadius2 = this.defaultRadius * this.defaultRadius; this.defaultRadiusR = 1.0 / this.defaultRadius; this.width = selection.Width; this.height = selection.Height; OnSetRenderInfo2(newToken, dstArgs, srcArgs); this.xCenterOffset = selection.Left + (this.width * (1.0 + this.offset.First) * 0.5); this.yCenterOffset = selection.Top + (this.height * (1.0 + this.offset.Second) * 0.5); base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected virtual void OnSetRenderInfo2(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { Amount1 = newToken.GetProperty<Int32Property>(PropertyNames.Amount1).Value; Amount2 = newToken.GetProperty<Int32Property>(PropertyNames.Amount2).Value; Amount3 = (byte)((int)newToken.GetProperty<StaticListChoiceProperty>(PropertyNames.Amount3).Value); Amount4 = ColorBgra.FromOpaqueInt32(newToken.GetProperty<Int32Property>(PropertyNames.Amount4).Value); Amount5 = ColorBgra.FromOpaqueInt32(newToken.GetProperty<Int32Property>(PropertyNames.Amount5).Value); Amount6 = ColorBgra.FromOpaqueInt32(newToken.GetProperty<Int32Property>(PropertyNames.Amount6).Value); Amount7 = ColorBgra.FromOpaqueInt32(newToken.GetProperty<Int32Property>(PropertyNames.Amount7).Value); Rectangle selection = EnvironmentParameters.GetSelection(srcArgs.Bounds).GetBoundsInt(); Bitmap tattersallBitmap = new Bitmap(selection.Width, selection.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); Graphics tattersallGraphics = Graphics.FromImage(tattersallBitmap); // Fill with white Rectangle backgroundRect = new Rectangle(0, 0, selection.Width, selection.Height); using (SolidBrush backColor = new SolidBrush(Amount7)) tattersallGraphics.FillRectangle(backColor, backgroundRect); // Set Brush Styles Brush brush1, brush2, brush3; switch (Amount3) { case 0: // Solid 33% Opacity brush1 = new SolidBrush(Color.FromArgb(85, Amount4)); brush2 = new SolidBrush(Color.FromArgb(85, Amount5)); brush3 = new SolidBrush(Color.FromArgb(85, Amount6)); break; case 1: // Solid 66% Opacity brush1 = new SolidBrush(Color.FromArgb(170, Amount4)); brush2 = new SolidBrush(Color.FromArgb(170, Amount5)); brush3 = new SolidBrush(Color.FromArgb(170, Amount6)); break; case 2: // Diagonal Lines Up brush1 = new HatchBrush(HatchStyle.DarkUpwardDiagonal, Amount4, Amount7); brush2 = new HatchBrush(HatchStyle.DarkUpwardDiagonal, Amount5, Amount7); brush3 = new HatchBrush(HatchStyle.DarkUpwardDiagonal, Amount6, Amount7); break; case 3: // Diagonal Lines Down brush1 = new HatchBrush(HatchStyle.DarkDownwardDiagonal, Amount4, Amount7); brush2 = new HatchBrush(HatchStyle.DarkDownwardDiagonal, Amount5, Amount7); brush3 = new HatchBrush(HatchStyle.DarkDownwardDiagonal, Amount6, Amount7); break; case 4: // 50/50 Dots brush1 = new HatchBrush(HatchStyle.Percent50, Amount4, Amount7); brush2 = new HatchBrush(HatchStyle.Percent50, Amount5, Amount7); brush3 = new HatchBrush(HatchStyle.Percent50, Amount6, Amount7); break; default: brush1 = new SolidBrush(Color.FromArgb(85, Amount4)); brush2 = new SolidBrush(Color.FromArgb(85, Amount5)); brush3 = new SolidBrush(Color.FromArgb(85, Amount6)); break; } // Set pen styles. Pen pen1 = new Pen(brush1, Amount1); brush1.Dispose(); Pen pen2 = new Pen(brush2, Amount1); brush2.Dispose(); Pen pen3 = new Pen(brush3, Amount1); brush3.Dispose(); // Calculate the number of lines will fit in the selection int xLoops = (int)Math.Ceiling((double)selection.Height / ((Amount1 + Amount2) * 3)); int yLoops = (int)Math.Ceiling((double)selection.Width / ((Amount1 + Amount2) * 3)); // Draw Horizontal Lines for (int i = 0; i < xLoops; i++) { // Create points that define line. Point point1 = new Point(0, Amount1 / 2 + (Amount1 + Amount2) * i * 3); Point point2 = new Point(selection.Width, Amount1 / 2 + (Amount1 + Amount2) * i * 3); // Draw line to screen. tattersallGraphics.DrawLine(pen1, point1, point2); // Create points that define line. Point point3 = new Point(0, Amount1 / 2 + (Amount1 + Amount2) * i * 3 + (Amount1 + Amount2)); Point point4 = new Point(selection.Width, Amount1 / 2 + (Amount1 + Amount2) * i * 3 + (Amount1 + Amount2)); // Draw line to screen. tattersallGraphics.DrawLine(pen2, point3, point4); // Create points that define line. Point point5 = new Point(0, Amount1 / 2 + (Amount1 + Amount2) * i * 3 + (Amount1 + Amount2) * 2); Point point6 = new Point(selection.Width, Amount1 / 2 + (Amount1 + Amount2) * i * 3 + (Amount1 + Amount2) * 2); // Draw line to screen. tattersallGraphics.DrawLine(pen3, point5, point6); } // Draw Vertical Lines for (int i = 0; i < yLoops; i++) { // Create points that define line. Point point1 = new Point(Amount1 / 2 + (Amount1 + Amount2) * i * 3, 0); Point point2 = new Point(Amount1 / 2 + (Amount1 + Amount2) * i * 3, selection.Height); // Draw line to screen. tattersallGraphics.DrawLine(pen1, point1, point2); // Create points that define line. Point point3 = new Point(Amount1 / 2 + (Amount1 + Amount2) * i * 3 + (Amount1 + Amount2), 0); Point point4 = new Point(Amount1 / 2 + (Amount1 + Amount2) * i * 3 + (Amount1 + Amount2), selection.Height); // Draw line to screen. tattersallGraphics.DrawLine(pen2, point3, point4); // Create points that define line. Point point5 = new Point(Amount1 / 2 + (Amount1 + Amount2) * i * 3 + (Amount1 + Amount2) * 2, 0); Point point6 = new Point(Amount1 / 2 + (Amount1 + Amount2) * i * 3 + (Amount1 + Amount2) * 2, selection.Height); // Draw line to screen. tattersallGraphics.DrawLine(pen3, point5, point6); } pen1.Dispose(); pen2.Dispose(); pen3.Dispose(); tattersallSurface = Surface.CopyFromBitmap(tattersallBitmap); tattersallBitmap.Dispose(); base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { Amount1 = newToken.GetProperty<DoubleProperty>(PropertyNames.Amount1).Value; Amount2 = newToken.GetProperty<Int32Property>(PropertyNames.Amount2).Value; Amount3 = newToken.GetProperty<BooleanProperty>(PropertyNames.Amount3).Value; Amount4 = ColorBgra.FromOpaqueInt32(newToken.GetProperty<Int32Property>(PropertyNames.Amount4).Value); Amount5 = newToken.GetProperty<DoubleVectorProperty>(PropertyNames.Amount5).Value; base.OnSetRenderInfo(newToken, dstArgs, srcArgs); Bitmap puzzleBitmap = new Bitmap((int)(100 * Amount1), (int)(100 * Amount1), System.Drawing.Imaging.PixelFormat.Format32bppArgb); Graphics puzzleGraphics = Graphics.FromImage(puzzleBitmap); puzzleGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; Pen puzzlePen = new Pen(Amount4, Amount2); // Create points that define the horizontal curve. Point horPoint0 = new Point((int)(-50 * Amount1), (int)(16 * Amount1)); Point horPoint1 = new Point((int)(0 * Amount1), (int)(16 * Amount1)); Point horPoint2 = new Point((int)(13 * Amount1), (int)(28 * Amount1)); Point horPoint3 = new Point((int)(9 * Amount1), (int)(50 * Amount1)); Point horPoint4 = new Point((int)(49 * Amount1), (int)(49 * Amount1)); Point horPoint5 = new Point((int)(90 * Amount1), (int)(49 * Amount1)); Point horPoint6 = new Point((int)(86 * Amount1), (int)(71 * Amount1)); Point horPoint7 = new Point((int)(99 * Amount1), (int)(83 * Amount1)); Point horPoint8 = new Point((int)(149 * Amount1), (int)(83 * Amount1)); Point[] horCurvePoints = { horPoint0, horPoint1, horPoint2, horPoint3, horPoint4, horPoint5, horPoint6, horPoint7, horPoint8 }; // Draw the horizontal curve to graphics object. puzzleGraphics.DrawCurve(puzzlePen, horCurvePoints); // Create points that define the vertical curve. Point verPoint0 = new Point((int)(83 * Amount1), (int)(-50 * Amount1)); Point verPoint1 = new Point((int)(83 * Amount1), (int)(0 * Amount1)); Point verPoint2 = new Point((int)(73 * Amount1), (int)(13 * Amount1)); Point verPoint3 = new Point((int)(49 * Amount1), (int)(9 * Amount1)); Point verPoint4 = new Point((int)(50 * Amount1), (int)(50 * Amount1)); Point verPoint5 = new Point((int)(50 * Amount1), (int)(90 * Amount1)); Point verPoint6 = new Point((int)(28 * Amount1), (int)(86 * Amount1)); Point verPoint7 = new Point((int)(16 * Amount1), (int)(99 * Amount1)); Point verPoint8 = new Point((int)(16 * Amount1), (int)(149 * Amount1)); Point[] verCurvePoints = { verPoint0, verPoint1, verPoint2, verPoint3, verPoint4, verPoint5, verPoint6, verPoint7, verPoint8 }; // Draw the vertical curve to graphics object. puzzleGraphics.DrawCurve(puzzlePen, verCurvePoints); puzzlePen.Dispose(); puzzleSurface = Surface.CopyFromBitmap(puzzleBitmap); puzzleBitmap.Dispose(); }