For some reason i got this error message:
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at PaintDotNet.SystemLayer.PdnNativeMethods.x64.EffectKernel_GaussianBlur(PdnBitmapData& dstBitmap, PdnBitmapData& srcBitmap, Rectangle* pRois, Int32 roisLength, Int32 blurRadius)
at PaintDotNet.SystemLayer.RenderingKernels.GaussianBlur(BitmapData dstBitmap, BitmapData srcBitmap, Rectangle[] rois, Int32 startIndex, Int32 length, Int32 blurRadius) in D:\src\pdn\src\SystemLayer\RenderingKernels.cs:line 521
at PaintDotNet.Effects.GaussianBlurEffect.OnRender(Rectangle[] rois, Int32 startIndex, Int32 length) in D:\src\pdn\src\Effects\GaussianBlurEffect.cs:line 141
at TDCEffect.TDCEffectPlugin.Render(Surface dst, Surface src, Rectangle rect)
at TDCEffect.TDCEffectPlugin.OnRender(Rectangle[] rois, Int32 startIndex, Int32 length)
at PaintDotNet.Effects.Effect`1.Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, Int32 startIndex, Int32 length) in D:\src\pdn\src\Effects\Effect`1.cs:line 99
at PaintDotNet.Effects.BackgroundEffectRenderer.RenderWithClipMask(Effect effect, EffectConfigToken token, RenderArgs dstArgs, RenderArgs srcArgs, RectInt32[] rois, Result`1 lazyClipMaskRenderer) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 193
at PaintDotNet.Effects.BackgroundEffectRenderer.RendererContext.RenderTile(EffectConfigToken token, Int32 tileIndex) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 173
at PaintDotNet.Effects.BackgroundEffectRenderer.RendererContext.RenderNextTile(EffectConfigToken token) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 165
at PaintDotNet.Effects.BackgroundEffectRenderer.ThreadFunction() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 283
--- End of inner exception stack trace ---
at PaintDotNet.Effects.BackgroundEffectRenderer.DrainExceptions() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 458
at PaintDotNet.Menus.EffectMenuBase.DoEffect(Effect effect, EffectConfigToken token, Result`1 lazySelectionScans, Result`1 lazyRegionToRenderScans, Result`1 lazyClipMaskRenderer, Surface originalSurface, Exception& exception) in D:\src\pdn\src\PaintDotNet\Menus\EffectMenuBase.cs:line 0
This is causing the plugin to not work at all.
Here is my modified script:
// Setup for calling the Gaussian Blur effect
GaussianBlurEffect gaussianblurEffect = new GaussianBlurEffect();
PropertyCollection gaussianblurProps;
protected override void OnDispose(bool disposing)
{
if (disposing)
{
// Release any surfaces or effects you've created
if (gaussianblurEffect != null) gaussianblurEffect.Dispose();
gaussianblurEffect = null;
}
base.OnDispose(disposing);
}
void PreRender(Surface dst, Surface src)
{
// Gaussian Blur
gaussianblurEffect.EnvironmentParameters = EnvironmentParameters;
gaussianblurProps = gaussianblurEffect.CreatePropertyCollection();
PropertyBasedEffectConfigToken gaussianblurParameters = new PropertyBasedEffectConfigToken(gaussianblurProps);
gaussianblurParameters.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, 70);
gaussianblurEffect.SetRenderInfo(gaussianblurParameters, new RenderArgs(dst), new RenderArgs(src));
}
void Render(Surface dst, Surface src, Rectangle rect)
{
dst.CopySurface(src, rect.Location, rect);
Rectangle sel = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
int sT = sel.Top;
int sB = sel.Bottom;
int sL = sel.Left;
int sR = sel.Right;
int x = 1064;
int y = 96;
Point left = new Point(sL, sT + x);
Point rite = new Point(sR, sT + x);
Point top = new Point(y + sL, sT);
Point bot = new Point(y + sL, sB);
int w = sR - sL;
int h = left.Y - sT;
Rectangle r1 = new Rectangle(0, 0, w, h);
w = sR - top.X;
h = sB - sT;
Rectangle r2 = new Rectangle(top.X, 0, w, h);;
// Now call the Gaussian Blur function from src surface to dst surface
gaussianblurEffect.Render(new Rectangle[1] {r1},0,1);
gaussianblurEffect.Render(new Rectangle[1] {r2},0,1);
}
Other than that, thanks for the code that you provided me!