Jump to content

Calling an effect the new way


Simon Brown
 Share

Recommended Posts

AddNoiseEffect ane;
PropertyCollection aneProps;
PropertyBasedEffectConfigToken aneToken;

ane = new AddNoiseEffect();
aneProps = ane.CreatePropertyCollection();
aneToken = new PropertyBasedEffectConfigToken(aneProps);
aneToken.SetPropertyValue(AddNoiseEffect.PropertyNames.Intensity, 40);
aneToken.SetPropertyValue(AddNoiseEffect.PropertyNames.Saturation, 0);
aneToken.SetPropertyValue(AddNoiseEffect.PropertyNames.Coverage, 100); //This line is not necessary, really, because 100 is the default...
ane.SetRenderInfo(aneToken, dstArgs, srcArgs);
ane.OnRender(rois, startIndex, length);

Is the general gist of it. Obviously, you need to separate some of those lines into their appropriate methods...

xZYt6wl.png

ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to comment
Share on other sites

AddNoiseEffect ane;
PropertyCollection aneProps;
PropertyBasedEffectConfigToken aneToken;

ane = new AddNoiseEffect();
aneProps = ane.CreatePropertyCollection();
aneToken = new PropertyBasedEffectConfigToken(aneProps);
aneToken.SetPropertyValue(AddNoiseEffect.PropertyNames.Intensity, 40);
aneToken.SetPropertyValue(AddNoiseEffect.PropertyNames.Saturation, 0);
aneToken.SetPropertyValue(AddNoiseEffect.PropertyNames.Coverage, 100); //This line is not necessary, really, because 100 is the default...
ane.SetRenderInfo(aneToken, dstArgs, srcArgs);
ane.OnRender(rois, startIndex, length);

Is the general gist of it. Obviously, you need to separate some of those lines into their appropriate methods...

Thanks :)

But I do wander why they changed it.

KaHuc.png
Link to comment
Share on other sites

Why would I make it backward compatible? This new method is far better, and allows strong typing at compile time as well as runtime discoverability of an effect's inputs and constraints.

"Backwards compatible" just entails having a bunch of compatibility props with [Obsolete] on them so that old plugins can still work. There's only 1 effect that warranted that, which was BlurEffect.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

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.

 Share

×
×
  • Create New...