Rick Brewster

CodeLab v4.4 (for advanced users) Released November 23, 2019

Recommended Posts

Alright, CodeLab keeps crashing and it is by calling integers. If I were to call on an int x and then give value to it later on CodeLab completely stalls up. Are there particular variables that are not allowed because of the plugin template?

Share this post


Link to post
Share on other sites
Alright, CodeLab keeps crashing and it is by calling integers. If I were to call on an int x and then give value to it later on CodeLab completely stalls up. Are there particular variables that are not allowed because of the plugin template?

Of course!

Let's look at the default script:

#region UICode
int Amount1=0;    //[0,100]Slider 1 Description
int Amount2=0;    //[0,100]Slider 2 Description
int Amount3=0;    //[0,100]Slider 3 Description
#endregion

void Render(Surface dst, Surface src, Rectangle rect)
{
   // Delete any of these lines you don't need
   Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
   long CenterX = (long)(((selection.Right - selection.Left) / 2)+selection.Left);
   long CenterY = (long)(((selection.Bottom - selection.Top) / 2)+selection.Top);
   ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;
   ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor;
   int BrushWidth = (int)EnvironmentParameters.BrushWidth;

   ColorBgra CurrentPixel;
   for(int y = rect.Top; y     {
       for (int x = rect.Left; x         {
           CurrentPixel = src[x,y];
           // TODO: Add pixel processing code here
           // Access RGBA values this way, for example:
           // CurrentPixel.R = (byte)PrimaryColor.R;
           // CurrentPixel.G = (byte)PrimaryColor.G;
           // CurrentPixel.B = (byte)PrimaryColor.B;
           // CurrentPixel.A = (byte)PrimaryColor.A;
           dst[x,y] = CurrentPixel;
       }
   }
}

Obviously, you can't use the following variables:

Amount1, Amount2, Amount3... etc. -- these are use for UI elements

dst, src -- pointers to the destination and source surfaces

rect -- rectangle of the current part of the selection that we are working on

selection -- this is used to get the bounds of the current selection

CenterX, CenterY -- used to point to the center pixel of the current selection

PrimaryColor, SecondaryColor -- used to hold current color values

BrushWidth -- used to hold the current brush width as set in the main PdN UI

CurrentPixel -- used in the main loop for working with the current pixel

x, y -- loop variables

That's about it. Of course, there are others, but these are the obvious ones.

Share this post


Link to post
Share on other sites

Excuse me, I have a problem with codelab. When I click "Build dll" button an error message appears. it says

"Error at line 0: Impossible to create 'c:/Program Files/Paint.NET/Effects/CSC68A7.tmp' temporary file -- Access denied. (CS1619).

What shall I do?

Share this post


Link to post
Share on other sites

There is a bug in Version 1.0 of CodeLab. Every plugin built by this version that contains a color wheel contains the bug.

To see the bug, select a color in the color docker window that is not 100% opaque, then run an effect built by CodeLab that contains a color wheel control. This causes an unhandled exception in the plugin that is caught by Paint.NET. No data loss should occur.

I will publish a fixed version of CodeLab soon. When a revised CodeLab is published, developers will only need to rebuild an effected plugin to fix the problem. I already have the fix working on my computer. I will test it and publish very soon.

Workaround: Users, be sure that your primary color's opacity is set to 255 (100%) before running any plugin built by CodeLab.

Share this post


Link to post
Share on other sites

Hey Guys! I'm new to this forum, and new to CodeLab.

I downloaded CodeLab yesterday, and went to see BoltBaits tutorials. I made the Colour Balance Effect, but when I went to File > Save As DLL I get this error:

Error at line 0: Cannot create temporary file 'c:\Program Files\Paint.NET\Effects\CSC1120.tmp' -- Access denied. (CS1619)

I am on the Administrator Account of this computer, as it is the only account. I am not sure what else to try.

Could anyone please help me? Also, I downloaded the Plug-in from BoltBait's CodeLab page, by clicking the link in his signature.

Thanks, heri!

Share this post


Link to post
Share on other sites

If you are running in Vista, try running Paint.NET as an administrator (Yes, I know you are on an administrator account, but if you right click on a shortcut or .exe file you should see the option to run as administrator)

Share this post


Link to post
Share on other sites
If you are running in Vista, try running Paint.NET as an administrator (Yes, I know you are on an administrator account, but if you right click on a shortcut or .exe file you should see the option to run as administrator)

Yes, I am running Vista, and I read your post, and tried it. I now am discovering even more errors for some reason. I do not know what the problem is, but now I am getting at least 10 errors instead of just that one.

Share this post


Link to post
Share on other sites

CodeLab 1.1 has been released.

1.1 Release

- Colorwheel Bug Fixed

- Fixed a bug where the namespace could have bad characters in it

- Second colorwheel in a UI now defaults to secondary color

- Floating point slider control added (requested by MadJik)

- Drop-Down List Box control added

- "UserBlendOp" control added

- Script comment parsed for default effect name:

// Name: Effect Name

- Minor UI typo fixes

Go get it here: http://boltbait.com/pdn/codelab/

Share this post


Link to post
Share on other sites
CodeLab 1.1 has been released.

1.1 Release

- Colorwheel Bug Fixed

- Fixed a bug where the namespace could have bad characters in it

- Second colorwheel in a UI now defaults to secondary color

- Floating point slider control added (requested by MadJik)

- Drop-Down List Box control added

- "UserBlendOp" control added

- Script comment parsed for default effect name:

// Name: Effect Name

- Minor UI typo fixes

Go get it here: http://boltbait.com/pdn/codelab/

By the way, the CodeLab help file has been updated with a ton of example scripts here: http://www.boltbait.com/pdn/codelab/hel ... ments.asp

And, the source code to CodeLab itself has been published to the bottom of this page: http://boltbait.com/pdn/codelab/

Enjoy. 8)

Share this post


Link to post
Share on other sites
CodeLab 1.1 has been released.

And a wonderful upgrade it is too :!:

I can't thank you enough BoltBait, particularly for the Drop-Down List Box and the BlendOp controls. I'm gonna have so much fun with these :D

[edit]

I was wondering if any of the controls can be set dynamically? Specifically the drop-down listbox. Can I populate the list at *.dll runtime (say with a list of fonts gleaned from the users PC)?

[/edit]

Share this post


Link to post
Share on other sites
[edit]

I was wondering if any of the controls can be set dynamically? Specifically the drop-down listbox. Can I populate the list at *.dll runtime (say with a list of fonts gleaned from the users PC)?

[/edit]

Paint.NET IndirectUI does not support such behavior.

HOWEVER... I might be able to give you something like that similar to the UserBlendOp control. Give me a few days... ;)

I do not understand this // Name: Effect Name stuff at all. Can you give an example?

Mike, the File > Save as DLL screen includes several fields of information that you need to fill in in order to build a DLL. It includes things like the author's name, the Effects submenu and menu text, and a support URL that is displayed to the user if your effect fails. Here's the save screen:

BuildDLL.png

It is a pain to enter that info every time you go to build a DLL, so I included a shortcut...

If you include a comment in your effect in the following form, the appropriate field will be filled in with the supplied default information.

// FIELD: default value

You can override this default before actually saving the DLL file. It is only for conveince. It has no effect on the effect at all.

Here are some examples:

// Author: BoltBait

// Submenu: Blurs

// Name: Gaussian Blur+

// URL: http://www.BoltBait.com/pdn

etc.

This is all explained on the following page of the help file: http://www.boltbait.com/pdn/codelab/hel ... ngdll.asp

Share this post


Link to post
Share on other sites
[edit]

I was wondering if any of the controls can be set dynamically? Specifically the drop-down listbox. Can I populate the list at *.dll runtime (say with a list of fonts gleaned from the users PC)?

[/edit]

Paint.NET IndirectUI does not support such behavior.

HOWEVER... I might be able to give you something like that similar to the UserBlendOp control. Give me a few days... ;)

That is not available through IndirectUI.

Sure it is. Use the StaticListChoiceProperty.

string[] fontNames = ... you figure this part out ...;
StaticListChoiceProperty fontNamesProperty = new StaticListChoiceProperty(YourPropertyName, fontNames);

Share this post


Link to post
Share on other sites

I have modified the CodeLab source to add a new FontList control. There may be many bugs as I am new to the CodeLab codebase. The source code was too large to attach, so PM me your email address for a copy (although note that I will probably not be able to get back to you within two weeks).

Share this post


Link to post
Share on other sites

Simon, you almost had it. You just forgot to wireup the OnSetRenderInfo function so the selected font was never being return to the user. My code is a little different from yours because I had already started on the problem when you had posted.

I have posted an updated CodeLab that includes the font list control.

Go get CodeLab version 1.2 here: http://www.BoltBait.com/pdn/codelab

Changes:

- Added Font List control

How to use the new control:

When the Render function starts, the Amount1 FontFamily variable contains the selected font family. The name of the font can be used this way: Amount1.Name and the font can be created this way: Font MyFont = new Font(Amount1.Name, 10); where you replace 10 with the desired font size. You probably don't want to do that inside of your render loop--do it at the top of your render function.

Thanks Ego Eram Reputo for supplying sample code for this control on this page: http://www.boltbait.com/pdn/codelab/hel ... asp#Fonts

Share this post


Link to post
Share on other sites
Thanks Ego Eram Reputo for supplying sample code for this control on this page: http://www.boltbait.com/pdn/codelab/hel ... html#Fonts

That might be my code :wink: , but the idea to draw directly to the canvas using drawing routines definitely came from MadJik when he and I were discussing a plugin which later became Random Mazes: http://paintdotnet.forumer.com/viewtopic.php?p=148303#p148303.

MadJik used g.DrawLine to draw the walls of his maze and I adapted this to work with g.DrawString. I would not have figured this out by myself and simply ran with his idea.

Share this post


Link to post
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.