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

Recommended Posts

Posted (edited)

I just created a interlace plugin, that adds horizontal/vertical stripes of configurable width and "color" (primary/secondary/transparent) to the image.

 

Plugin:

  Download

 

Sources:

http://koti.mbnet.fi/tunedude/pdn/InterlaceSources.zip

 

English, with Swedish and Finnish localization available.

 

Version history:

1.0.0.5:

- reordered OK/cancel buttons to be in line with the rest of the software

 

Edited by toe_head2001
Added plugin as an attachment
Posted

Bug:*

When you zoom in on an image so that it is not all viewable on the screen and render your effect the area in view looks different than the area that was not viewable.

*maybe

 

Take responsibility for your own intelligence. 😉 -Rick Brewster

Posted
Bug:*

When you zoom in on an image so that it is not all viewable on the screen and render your effect the area in view looks different that the area that was not viewable.

*maybe

Hmm, I'm unable to reproduce that behavior if I understood you correctly

Posted

My PDN screen's resolution is 958x772 (I only know that cuz I took a screen shot).

I opened this image.

I zoomed in to 200%.

Then I ran the "interlace" effect.

Source: Primary

Stripe Width: 15

I get this.

 

Take responsibility for your own intelligence. 😉 -Rick Brewster

Posted
I just created a interlace plugin, that adds stripes of configurable width and "color" (primary/secondary/transparent) to the image.

Why not just make a slight change to the Grid plugin that I already wrote?

Like this:

int Amount1=5; //[2,25]Scanline Width
int Amount2=0; //[0,1]Primary Color           Secondary Color
int Amount3=1; //[1,5]Brush Width

void Render(Surface dst, Surface src, Rectangle rect)
{
   // User Interface elements
   int GridSize = Amount1;
   bool SwapColors = (Amount2 == 1);

   // Other variables
   PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds);
   Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
   ColorBgra CurrentPixel;
   ColorBgra PrimaryColor;
   ColorBgra SecondaryColor;
   bool Odd = false;

   // Get the current brush width for grids
   int w = Amount3;

   // Grab the primary and secondary colors (swapping if specified in the UI)
   if (SwapColors) {
       PrimaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor;
       SecondaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;
   } else {
       PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;
       SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor;
   }

   // Loop through all the pixels
   for(int y = rect.Top; y < rect.Bottom; y++)
   {
       for (int x = rect.Left; x < rect.Right; x++)
       {
           // Only work with a pixel if it is selected
           // (this handles convex & concave selections)
           if (selectionRegion.IsVisible(x, y))
           {
               // Get the source pixel
               CurrentPixel = src[x,y];
            Odd = false;
            for (int t=0; t<w; t++)
            {
               if (((y-t) % GridSize) == 0)
                  Odd = true;
            }
            if ( Odd )
            {
                CurrentPixel.R = (byte)PrimaryColor.R;
                CurrentPixel.G = (byte)PrimaryColor.G;
                CurrentPixel.B = (byte)PrimaryColor.B;
                CurrentPixel.A = (byte)PrimaryColor.A;
            }
               // Save the (modified?) pixel
               dst[x,y] = CurrentPixel;
           }
       }
   }
}

And, no preview issues. :D

Posted

Why not just make a slight change to the Grid plugin that I already wrote?

Why spoil the fun?

Anyway, turns out I didn't realize you had to write every pixel in dstArgs even if it didn't change. Fixed version is online.

Posted

Thanks, this is cool, someone help him fix the preview.

I just created a interlace plugin, that adds stripes of configurable width and "color" (primary/secondary/transparent) to the image.

Get it here:

http://koti.mbnet.fi/tunedude/pdn/InterlacePlugin.zip

Currently only the binary available, eventually I will probably publish source and installer.

English, with swedish and finnish localization available.

Known issues:

- the live preview thing doesn't seem to work, suggestions how to fix welcome!

Posted

Can you have an option to do this as vertical as well?

Actually BoltBait, I was able to use your code to do that myself, I am just having trouble adding the 4th slider, does code lab allow more than 3 sliders?

I removed the primary / secondary option since thats not really needed. Will have to try working with the source code for pdn instead of codelab.

offtopic, I can't save the dll from codelab unless I run pdn as administrator in vista, any other work around?

Posted
Thanks, this is cool, someone help him fix the preview.

I already did.

No you didn't, you rolled your own.

Your attitude isn't helping anyone (especially considering this is my first publicly released plugin), and isn't exactly increasing my eagerness to make any new plugins.

That said, I did manage to fix the preview issue with a little Reflector help..

(How was I to know that I needed to call FinishTokenUpdate on every value change?)

A new version is online, also with horizontal option

Posted

Thanks for updating it, btw your vertical/horizontal are incorrect. Vertical does horizontal and vice-versa.

Thanks, this is cool, someone help him fix the preview.

I already did.

No you didn't, you rolled your own.

Your attitude isn't helping anyone (especially considering this is my first publicly released plugin), and isn't exactly increasing my eagerness to make any new plugins.

That said, I did manage to fix the preview issue with a little Reflector help..

(How was I to know that I needed to call FinishTokenUpdate on every value change?)

A new version is online, also with horizontal option

Posted

I mean when I click vertical on your effect, it does horizontal lines instead of vertical. Not which is the default it is doing.

Thanks for updating it, btw your vertical/horizontal are incorrect. Vertical does horizontal and vice-versa.

Well, I was unsure of which way it should be. It depends on what you think describes the orientation.

I visited http://en.wikipedia.org/wiki/Interlace and got the impression that "normal" interlacing is vertical so...

Posted
I mean when I click vertical on your effect, it does horizontal lines instead of vertical. Not which is the default it is doing.

yes, I know, and I *think* that way (the original way that is) is correct 'terminologically speaking'. However, I see that the way you say is probably more intuitive for Joe User, so I uploaded a version where the Vertical produces vertical stripes.

Posted
Thanks, this is cool, someone help him fix the preview.

I already did.

No you didn't, you rolled your own.

Your attitude isn't helping anyone (especially considering this is my first publicly released plugin), and isn't exactly increasing my eagerness to make any new plugins.

Sorry, I really didn't mean to step on your toes. Now that you've fixed your plugin it is clearly better than mine. Good job!

(For me, it was easier to modify my own code than to try and find the bug in yours. I was hoping you would be able to compare my code to your own in order to find your issue.)

That said, I did manage to fix the preview issue with a little Reflector help..

(How was I to know that I needed to call FinishTokenUpdate on every value change?)

That is explained here: http://paintdotnet.12.forumer.com/viewt ... 4136#24136

A new version is online, also with horizontal option

I recommend you go back and update your first post to let people know that it no longer has an issue with the preview mode.

Again, let me say "Good Job!" I'm sorry that I didn't help you.

Now that you do have a good handle on how to write effects, I hope you do write more. Since Rick does not accept code changes, this is the one area where people like you and I can contribute to making Paint.NET a better program.

I am just having trouble adding the 4th slider, does code lab allow more than 3 sliders?

CodeLab only allows 1, 2, or 3 sliders OR a single direction control. These are the only built-in dialog boxes that CodeLab has access to. It would be WAAAYYY to complex to modify CodeLab to allow for other different dialog boxes that do not currently already exist in Paint.NET.

Posted

(For me, it was easier to modify my own code than to try and find the bug in yours. I was hoping you would be able to compare my code to your own in order to find your issue.)

That said, I did manage to fix the preview issue with a little Reflector help..

(How was I to know that I needed to call FinishTokenUpdate on every value change?)

That is explained here: http://paintdotnet.12.forumer.com/viewt ... 4136#24136

Oh, now I see it when I know that it's there (and now that it's not 1am)...

8. Double-click on a new control and add "FinishtokenUpdate();" to the function. Repeat this for all new controls.

That's how you do it "with hand holding", but from that you need to extrapolate that the double clicking a control will create a default event handler, that usually is some kind of value changed, and that calling FinishTokenUpdate is what tells the pdn that something has changed. I'd probably say something along the lines of "you need to call FinishTokenUpdate whenever a configuration option changes in order for preview to work properly".

The "problem" with you posting CodeLab code was that it was not the effect code that was buggy, it was the UI "integration" with the effect code, and CodeLab code doesn't have that part... But anyway it works now.

Another gotcha that I hit, that might be good to spell out in the plugin tutorial was the fact that you need to do

dstArgs.Surface[x, y] = srcArgs.Surface[x, y];

if you aren't modifying a particular pixel.

I recommend you go back and update your first post to let people know that it no longer has an issue with the preview mode.

Done

Again, let me say "Good Job!" I'm sorry that I didn't help you.

thanks, no problem!

Posted

Hey tunedude,

I was used (sometimes) to add a new layer and create a checker on it, then select a single row (or column) of pixels and then move to enlarge it for left to right (or up to down) to have what you call interlace.

So your plugin is great enought to make this easier to me. Thanks for that.

BTW, one improvement could be a check box to choose if we want to start the interlace by 'black' or by 'picture' (with the checker it's based on the row I've selected)...

And, it's the first plugin I see with multi language. I would appreciate to learn how to do that for my own plugins (source?).

Thanks.

Posted

BTW, one improvement could be a check box to choose if we want to start the interlace by 'black' or by 'picture' (with the checker it's based on the row I've selected)...

Heh, I figured that such an option might be needed, but then somehow forgot about it.. I'll try to remember to fix that..

And, it's the first plugin I see with multi language. I would appreciate to learn how to do that for my own plugins (source?).

I'll post the source after I've done some cleanup.

Meanwhile as a pointer, I just did it the standard .NET way, meaning you flip the Localizable property on the configuration dialog, and then switch languages and translate as necessary. Constant strings in the source goes into Project properties -> Resources.

Not sure if this is how it should be done in Pdn though...

Thanks.

You're welcome!

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