Jump to content
Paint.NET 5.1 is now available! ×

Recommended Posts

Posted (edited)
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

Posted

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

Posted

I seem to have lost it somehow. Basically it's an effect that applies the Frosted Glass effect, followed by the Median effect. But I don't know how to show it to you. I apologize.

Big McThankies From McSpankies!

sakana sig resized.png

Posted (edited)

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

Posted

Weirdly the error seems to have gone, but now it makes the picture look all weird and glitchy - NOT the kind of effect I want.

 

The picture below proves it:

 

crayon-error.png

 

How to fix this, please?

Big McThankies From McSpankies!

sakana sig resized.png

Posted
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)

  • 2 weeks later...
Posted (edited)

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

Posted

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

  • 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...