Jump to content

Can I call an Effect from within Codelab? How?


Recommended Posts

I would like to call an effect from within a Codelab *.dll. Say for example I wanted to call the CloudsEffect first, and then render something else over the top of that.

Is this possible?

Can anyone share some code to point me in the right direction?

Many thanks,

Link to comment
Share on other sites

I'm writing a page to describe how to write complex effects with CodeLab ("complex" meaning effects that call other effects).

Here's the script I plan on using:

#region UICode
int Amount1=10; // [0,100] Blur Amount
#endregion

// Setup for using a specific blend op
private UserBlendOps.DarkenBlendOp darkenOp = new UserBlendOps.DarkenBlendOp();

unsafe void Render(Surface dst, Surface src, Rectangle rect)
{
   // Setup for calling the Gaussian Blur effect
   GaussianBlurEffect blurEffect = new GaussianBlurEffect();
   PaintDotNet.PropertySystem.PropertyCollection blurProps;

   // Call the Gaussian Blur function
   blurProps = blurEffect.CreatePropertyCollection();
   PropertyBasedEffectConfigToken BlurParameters = new PropertyBasedEffectConfigToken(blurProps);
   BlurParameters.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, Amount1);
   blurEffect.SetRenderInfo(BlurParameters, new RenderArgs(dst), new RenderArgs(src));
   blurEffect.Render(new Rectangle[1] {rect},0,1);

   // Now in the main render loop, the dst canvas has a blurred version of the src canvas
   for (int y = rect.Top; y     {
       ColorBgra* srcPtr = src.GetPointAddressUnchecked(rect.Left, y);
       ColorBgra* dstPtr = dst.GetPointAddressUnchecked(rect.Left, y);
       for (int x = rect.Left; x         {
           ColorBgra CurrentPixel = *srcPtr;

           // TODO: Add additional pixel processing code here
           CurrentPixel = darkenOp.Apply(*dstPtr, CurrentPixel);

           *dstPtr = CurrentPixel;
           srcPtr++;
           dstPtr++;
       }
   }
}

Perhaps, you can get something out of the sample code without all of my flowery speech... :D

I think you're really going to like the next version of CodeLab ;)

Link to comment
Share on other sites

Thank you :!:

I was looking at something that Simon Brown wrote here: http://paintdotnet.forumer.com/viewtopic.php?p=170913#p170913, but I just couldn't get it to work in CodeLab. Your source will help me an awful lot.

I think you're really going to like the next version of CodeLab ;)

You keep doing this to me :lol:. I dream up something and ask about it, and you say "Hang on, I'll make Codelab do that for you". Marvelous! Thank you!

Link to comment
Share on other sites

Hey there, heythere (sorry :D )

Macros? Not exactly. I want to call (use) an existing PDN effect from within my new effect.

Lets say I wanted to create a "snowstorm" effect to apply to photos (I don't - but now that I think about it..., :wink: ). I might use the effects "Add Noise" + "Blur"/"Motion Blur" to get the basic snow blobs on the canvas, before doing some other very cool stuff with these basic building blocks.

I just wanted to know if this was achievable (it is) and how its done in CodeLab (see BoltBaits code - which uses GaussianBlurEffect).

Link to comment
Share on other sites

Hey there, heythere (sorry :D )

That's the exact reason I gave myself that name. :) You were the first to figure it out.

Now, back on topic.

Oh, well it looks fairly simple to implement. But the macros thing may be an idea for a feature suggestion. Or is that what ScriptLab does?

I think you're really going to like the next version of CodeLab ;)

So when's it coming? :wink:

Link to comment
Share on other sites

I think you're really going to like the next version of CodeLab ;)

So when's it coming? :wink:

Well, everything's ready on my end. However, Curtis was working on the text editor itself and and added some pretty cool features, however it is in a pretty bad shape right now. I have some bugs to track down in that space before I can release CodeLab v1.3.

Link to comment
Share on other sites

Well, everything's ready on my end. However, Curtis was working on the text editor itself and and added some pretty cool features, however it is in a pretty bad shape right now. I have some bugs to track down in that space before I can release CodeLab v1.3.

Off-topic: I have found an article on TheCodeProject that may help you implement auto-complete (remember that you should call it this in the feature list, rather than a Microsoft trademark) in CodeLab: http://www.codeproject.com/KB/cs/diy-intellisense.aspx.

KaHuc.png
Link to comment
Share on other sites

  • 3 weeks later...
  • 1 year later...

Help please... Сan I call two effects from the CodeLab script. Two effects should be run sequentially.

Thanks in advance!

Read this: How to write an effect plugin (part 3 of 4)

It explains that it is only possible if one of the two desired effects is a Unary Pixel Operation.

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.

×
×
  • Create New...