tunedude Posted April 10, 2007 Posted April 10, 2007 (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 September 9, 2018 by toe_head2001 Added plugin as an attachment Quote
barkbark00 Posted April 10, 2007 Posted April 10, 2007 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 Quote Take responsibility for your own intelligence. 😉 -Rick Brewster
tunedude Posted April 10, 2007 Author Posted April 10, 2007 BoltBait made me realize it's hard to get help without posting source so... http://koti.mbnet.fi/tunedude/pdn/InterlaceSources.zip Quote
tunedude Posted April 10, 2007 Author Posted April 10, 2007 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 Quote
barkbark00 Posted April 10, 2007 Posted April 10, 2007 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. Quote Take responsibility for your own intelligence. 😉 -Rick Brewster
Illnab1024 Posted April 10, 2007 Posted April 10, 2007 Sounds to me like his math isn't based on the proper rectangle values Quote ~~
BoltBait Posted April 10, 2007 Posted April 10, 2007 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. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game
tunedude Posted April 10, 2007 Author Posted April 10, 2007 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. Quote
moc426 Posted April 11, 2007 Posted April 11, 2007 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! Quote
usedHONDA Posted April 11, 2007 Posted April 11, 2007 So... can I use this in the PDN Plugin Pack? Quote "The greatest thing about the Internet is that you can write anything you want and give it a false source." ~Ezra Pound twtr | dA | tmblr | yt | fb
BoltBait Posted April 11, 2007 Posted April 11, 2007 Thanks, this is cool, someone help him fix the preview. I already did. The codelab script I posted above does not have any issues. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game
usedHONDA Posted April 11, 2007 Posted April 11, 2007 So is your version original enough to add to the PPP without tunedude's permission? Quote "The greatest thing about the Internet is that you can write anything you want and give it a false source." ~Ezra Pound twtr | dA | tmblr | yt | fb
BoltBait Posted April 11, 2007 Posted April 11, 2007 So is your version origional enough to add to the PPP without tunedude's permission? Yes. But, if he wants to fix his instead, I'm fine with that. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game
moc426 Posted April 11, 2007 Posted April 11, 2007 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? Quote
tunedude Posted April 11, 2007 Author Posted April 11, 2007 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 Quote
tunedude Posted April 11, 2007 Author Posted April 11, 2007 So... can I use this in the PDN Plugin Pack? sure, just make sure you use the version posted minutes ago... Quote
moc426 Posted April 11, 2007 Posted April 11, 2007 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 Quote
tunedude Posted April 11, 2007 Author Posted April 11, 2007 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... Quote
moc426 Posted April 11, 2007 Posted April 11, 2007 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... Quote
tunedude Posted April 11, 2007 Author Posted April 11, 2007 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. Quote
BoltBait Posted April 11, 2007 Posted April 11, 2007 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. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game
tunedude Posted April 11, 2007 Author Posted April 11, 2007 (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! Quote
MadJik Posted April 11, 2007 Posted April 11, 2007 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. Quote My DeviantArt | My Pictorium | My Plugins | Donate via Paypal
tunedude Posted April 11, 2007 Author Posted April 11, 2007 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! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.