Jump to content

Plugin development by Sakana Oji


Recommended Posts

On 11/16/2015 at 5:31 AM, MJW said:

The following plugin has an initial blur, followed by a brightness and contrast adjustment

Is there a way to call the brightness and contrast adjustment before applying the blur? I want to add this to my HDR effect, though I already built it without the adjustment and blur as Version 1.0 (I still haven't shared it btw)

 

Edit: (Actually, I just already did - along with my Color Intensifier plugin.)

Edited by Sakana Oji
Already shared it.

Big McThankies From McSpankies!

sakana sig resized.png

Link to comment
Share on other sites

How do i fix this error message? It appears in the error message box.

Quote

Unhandled Exception at line 0: 
System.InvalidOperationException: SetRenderInfo() was not called, nor was render info available implicitely
   at PaintDotNet.ExceptionUtil.ThrowInvalidOperationException(String message) in D:\src\pdn\src\Base\ExceptionUtil.cs:line 161
   at PaintDotNet.Effects.Effect`1.Render(Rectangle[] renderRects, Int32 startIndex, Int32 length) in D:\src\pdn\src\Effects\Effect`1.cs:line 52
   at PaintDotNet.Effects.UserScript.Render(Surface dst, Surface src, Rectangle rect)
   at PaintDotNet.Effects.UserScript.Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, Int32 startIndex, Int32 length)
   at PaintDotNet.Effects.CodeLab.Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, Int32 startIndex, Int32 length)

 

Big McThankies From McSpankies!

sakana sig resized.png

Link to comment
Share on other sites

I tried my best to recreate it:

// Name: Gaussian Blur with Brightness and Contrast
// Submenu: Blurs
// Author: MJW
// Title: Gaussian Blur with Brighness and Contrast
// Desc: Gaussian Blur with Brightness and Contrast (test multiple built-in effects)
// Keywords: Gaussian blur contrast brightness test multiple built-in effects
// URL:
// Help:
#region UICode
DoubleSliderControl Amount1 = 3; // [0,5] Pressure
DoubleSliderControl Amount2 = 0; // [0,200] Minimum Scatter Radius
IntSliderControl Amount3 = 2; // [1,8] Quality
IntSliderControl Amount4=1; // [1,200] Radius
IntSliderControl Amount5=10; // [0,100] Percentile
#endregion


// Here is the main render loop function
void Render(Surface dst, Surface src, Rectangle rect)
{
    // Setup for calling the Frosted Glass effect
    FrostedGlassEffect frostedEffect = new FrostedGlassEffect();
    PropertyCollection frostedProps = frostedEffect.CreatePropertyCollection();
    PropertyBasedEffectConfigToken FrostedParameters = new PropertyBasedEffectConfigToken(frostedProps);
    FrostedParameters.SetPropertyValue(FrostedGlassEffect.PropertyNames.MaxScatterRadius, Amount1);
    FrostedParameters.SetPropertyValue(FrostedGlassEffect.PropertyNames.MinScatterRadius, Amount2);
    FrostedParameters.SetPropertyValue(FrostedGlassEffect.PropertyNames.NumSamples, Amount3);
    frostedEffect.SetRenderInfo(FrostedParameters, new RenderArgs(dst), new RenderArgs(src));
    // Call the Frosted Glass function
    frostedEffect.Render(new Rectangle[1] {rect}, 0, 1);  
    
    // Adjust median.
    MedianEffect medianEffect = new MedianEffect();
    PropertyCollection medianProps = medianEffect.CreatePropertyCollection();
    PropertyBasedEffectConfigToken medianParameters = new PropertyBasedEffectConfigToken(medianProps);
    medianParameters.SetPropertyValue(MedianEffect.PropertyNames.Radius, Amount4);
    medianParameters.SetPropertyValue(MedianEffect.PropertyNames.Percentile, Amount5);
    medianEffect.SetRenderInfo(medianParameters, new RenderArgs(dst), new RenderArgs(dst));
    // Call the Median function
    medianEffect.Render(new Rectangle[1] {rect}, 0, 1);

    // Now in the main render loop, the dst canvas has a crayon version of the src canvas
    // The dst canvas has the contrast adjusted.
}
Edited by Sakana Oji

Big McThankies From McSpankies!

sakana sig resized.png

Link to comment
Share on other sites

4 minutes ago, Sakana Oji said:

How to fix this, please?

 

Here's your problem:

 

medianEffect.SetRenderInfo(medianParameters, new RenderArgs(dst), new RenderArgs(dst));

You can't render the median effect to the same canvas you're rendering from.

 

You should probably read the tutorials on my web site:

 

https://boltbait.com/pdn/CodeLab/help/

 

(specifically part 3 & 7)

Link to comment
Share on other sites

  • 2 weeks later...

Okay here's my real actual code that I first worked on (not recreated):

 

// Name: Crayon
// Submenu: Artistic
// Author: Sakana Oji
// Title: Crayon
// Desc: Gives the image a crayon effect
// Keywords: crayon artistic
// URL:
// Help:
#region UICode
DoubleSliderControl Amount1 = 3; // [0,10] Thickness
DoubleSliderControl Amount2 = 0; // [0,200] Minimum Scatter Radius
IntSliderControl Amount3 = 2; // [1,8] Quality
IntSliderControl Amount4=1; // [1,5] Radius
IntSliderControl Amount5=10; // [0,100] Percentile
#endregion


// Here is the main render loop function
void Render(Surface dst, Surface src, Rectangle rect)
{
    // Setup for calling the Frosted Glass effect
    FrostedGlassEffect frostedEffect = new FrostedGlassEffect();
    PropertyCollection frostedProps;
    // Call the Frosted Glass function
    frostedEffect.Render(new Rectangle[1] { rect }, 0, 1); 
    
    // Adjust median
    MedianEffect medianEffect = new MedianEffect();
    PropertyCollection medianProps = medianEffect.CreatePropertyCollection();
    PropertyBasedEffectConfigToken medianParameters = new PropertyBasedEffectConfigToken(medianProps);
    medianParameters.SetPropertyValue(MedianEffect.PropertyNames.Radius, Amount4);
    medianParameters.SetPropertyValue(MedianEffect.PropertyNames.Percentile, Amount5);
    medianEffect.SetRenderInfo(medianParameters, new RenderArgs(dst), new RenderArgs(dst));
    // Call the Median function
    medianEffect.Render(new Rectangle[1] {rect},0,1);

}

Edited by Sakana Oji

Big McThankies From McSpankies!

sakana sig resized.png

Link to comment
Share on other sites

As ReMake has indicated, this discussion has wandered off the original topic. I've split into it's own thread.

Link to comment
Share on other sites

  • toe_head2001 changed the title to Plugin development by Sakana Oji

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...