Sakana Oji Posted January 3, 2019 Share Posted January 3, 2019 (edited) Created with a little help from ReMake, BoltBait and others! Color Intensifier is based on this tutorial by xmario, while HDR is based on applying an inverted, blurred and black and white overlay on the original image. Download Color Intensifier here: ColorIntensifier.zip Download HDR here: HDR.zip Here is the code for Color Intensifier: // Name: Color Intensifier // Submenu: Color // Author: Sakana Oji // Title: Color Intensifier // Version: 1.0 // Desc: Intensifies the colors of the picture // Keywords: intensity|color // URL: http://www.getpaint.net/redirect/plugins.html // Help: #region UICode #endregion // Setup for calling the Brightness and Contrast Adjustment function BrightnessAndContrastAdjustment bacAdjustment = new BrightnessAndContrastAdjustment(); PropertyCollection bacProps; // Setup for using pixel op private UnaryPixelOps.Desaturate desaturateOp = new UnaryPixelOps.Desaturate(); private UnaryPixelOps.Invert invertOp = new UnaryPixelOps.Invert(); // Setup for using Reflect blend op private BinaryPixelOp reflectOp = LayerBlendModeUtil.CreateCompositionOp(LayerBlendMode.Reflect); protected override void OnDispose(bool disposing) { // Release any surfaces or effects you've created. if (bacAdjustment != null) bacAdjustment.Dispose(); bacAdjustment = null; base.OnDispose(disposing); } void PreRender(Surface dst, Surface src) { bacProps = bacAdjustment.CreatePropertyCollection(); PropertyBasedEffectConfigToken bacParameters = new PropertyBasedEffectConfigToken(bacProps); bacParameters.SetPropertyValue(BrightnessAndContrastAdjustment.PropertyNames.Brightness, 0); bacParameters.SetPropertyValue(BrightnessAndContrastAdjustment.PropertyNames.Contrast, -1); bacAdjustment.SetRenderInfo(bacParameters, new RenderArgs(dst), new RenderArgs(src)); } // Here is the main render loop function void Render(Surface dst, Surface src, Rectangle rect) { // Call the Brightness and Contrast Adjustment function bacAdjustment.Render(new Rectangle[1] {rect},0,1); // Now in the main render loop, the dst canvas has an adjusted version of the src canvas for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) return; for (int x = rect.Left; x < rect.Right; x++) { ColorBgra CurrentPixel = dst[x,y]; // TODO: Add additional pixel processing code here CurrentPixel = desaturateOp.Apply(CurrentPixel); CurrentPixel = invertOp.Apply(CurrentPixel); CurrentPixel = reflectOp.Apply(src[x,y], CurrentPixel); dst[x,y] = CurrentPixel; } } } And this code is for HDR: // Name: HDR // Submenu: Adjustments // Author: Sakana Oji // Title: HDR // Version: 1.0 // Desc: Adds a HDR effect to the image // Keywords: hdr|enhancement|enhance|blur // URL: // Help: #region UICode IntSliderControl Amount1 = 2; // [0,200] Radius #endregion // Setup for calling the Gaussian Blur effect GaussianBlurEffect blurEffect = new GaussianBlurEffect(); PropertyCollection blurProps; // Setup for using pixel op private UnaryPixelOps.Desaturate desaturateOp = new UnaryPixelOps.Desaturate(); private UnaryPixelOps.Invert invertOp = new UnaryPixelOps.Invert(); // Setup for using Overlay blend op private BinaryPixelOp overlayOp = LayerBlendModeUtil.CreateCompositionOp(LayerBlendMode.Overlay); protected override void OnDispose(bool disposing) { // Release any surfaces or effects you've created. if (blurEffect != null) blurEffect.Dispose(); blurEffect = null; base.OnDispose(disposing); } void PreRender(Surface dst, Surface src) { blurProps = blurEffect.CreatePropertyCollection(); PropertyBasedEffectConfigToken BlurParameters = new PropertyBasedEffectConfigToken(blurProps); BlurParameters.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, Amount1); blurEffect.SetRenderInfo(BlurParameters, new RenderArgs(dst), new RenderArgs(src)); } // Here is the main render loop function void Render(Surface dst, Surface src, Rectangle rect) { // Call the Gaussian Blur function 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 < rect.Bottom; y++) { if (IsCancelRequested) return; for (int x = rect.Left; x < rect.Right; x++) { ColorBgra CurrentPixel = dst[x,y]; // TODO: Add additional pixel processing code here CurrentPixel = desaturateOp.Apply(CurrentPixel); CurrentPixel = invertOp.Apply(CurrentPixel); CurrentPixel = overlayOp.Apply(src[x,y], CurrentPixel); dst[x,y] = CurrentPixel; } } } Edited January 5, 2019 by Sakana Oji Removed Takeafile link, removed Dropbox links and added zip attachments Quote Big McThankies From McSpankies! Link to comment Share on other sites More sharing options...
Sakana Oji Posted January 3, 2019 Author Share Posted January 3, 2019 AHAHAHAHAHAHHAAA! Oh my grease, the code tag turned that last word into a code! Well at least I know that they work... Quote Big McThankies From McSpankies! Link to comment Share on other sites More sharing options...
toe_head2001 Posted January 3, 2019 Share Posted January 3, 2019 I have some feedback regarding ways to improve and simplify your code. I'm about the walk out the door, so I'll get back to later tonight. 41 minutes ago, Sakana Oji said: while HDR is based on applying an inverted, blurred and black and white overlay on the original image. How does that equate to HDR? 45 minutes ago, Sakana Oji said: Download them as a 2-plugin pack: https://takeafile.com/?f=wananekike No offense directed to you, but what a awful way to distribute your plugins. Please use a different service or host, or better yet, attach a ZIP file to the forum. Quote (September 25th, 2023) Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted January 3, 2019 Share Posted January 3, 2019 Yup. I'm backing toe_head2001 with the request for an attached ZIP. Neither source code compiles as posted. Both give me this error in codeLab.... Quote Exception has been thrown by the target of an invocation. Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
toe_head2001 Posted January 4, 2019 Share Posted January 4, 2019 You aren't doing any per-pixel processing in either effect, so you don't need the X,Y loops. For example, your "HDR" plugin can go from this: void Render(Surface dst, Surface src, Rectangle rect) { // Call the Gaussian Blur function 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 < rect.Bottom; y++) { if (IsCancelRequested) return; for (int x = rect.Left; x < rect.Right; x++) { ColorBgra CurrentPixel = dst[x,y]; // TODO: Add additional pixel processing code here CurrentPixel = desaturateOp.Apply(CurrentPixel); CurrentPixel = invertOp.Apply(CurrentPixel); CurrentPixel = overlayOp.Apply(src[x,y], CurrentPixel); dst[x,y] = CurrentPixel; } } } To this: void Render(Surface dst, Surface src, Rectangle rect) { // Call the Gaussian Blur function blurEffect.Render(new Rectangle[] {rect}, 0, 1); desaturateOp.Apply(dst, rect); invertOp.Apply(dst, rect); overlayOp.Apply(dst, src, dst, rect); } Also a note about the Dispose override. Please place objects within a diposing condition. Yes, I know CodeLab wrote this code for you, but you used an old version. The newest version of CodeLab corrects this oversight. protected override void OnDispose(bool disposing) { if (disposing) { // Release any surfaces or effects you've created. if (blurEffect != null) blurEffect.Dispose(); blurEffect = null; } base.OnDispose(disposing); } Quote (September 25th, 2023) Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
Sakana Oji Posted January 4, 2019 Author Share Posted January 4, 2019 12 hours ago, Ego Eram Reputo said: Yup. I'm backing toe_head2001 with the request for an attached ZIP. Neither source code compiles as posted. Both give me this error in codeLab.... Maybe you have the error because you don't have the latest version of CodeLab - and you know what? I'm done with Takeafile now anyway. I'm heading back to Dropbox from now on. Quote Big McThankies From McSpankies! Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted January 4, 2019 Share Posted January 4, 2019 Just attach a zipped file to the first post. Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
Sakana Oji Posted January 5, 2019 Author Share Posted January 5, 2019 21 hours ago, Ego Eram Reputo said: Just attach a zipped file to the first post. I think I already did... did I? Quote Big McThankies From McSpankies! Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted January 5, 2019 Share Posted January 5, 2019 No. You posted Dropbox links to the zipped files. You can attach the files directly to the first post in this thread. This is the preferred method as users don't have to rely on any external host. Meaning the plugins will be available to forum users because they are actually attached to the forum. Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
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.