bitchcraft Posted February 18, 2018 Share Posted February 18, 2018 hey guys, i'm looking for a very simple plugin & i'm sure it already exists, i just can't find it. all i want is a plugin that will change an entire layer's colour to a hex/rgb code that i can input. i don't want any info on the colour changer tool or using the fill bucket, for clarification; i want a plugin that will allow me to put in a hex/rgb code and when applied will change the entire layer to said colour (other than transparent areas, obviously). thanks in advance! Quote Link to comment Share on other sites More sharing options...
BoltBait Posted February 18, 2018 Share Posted February 18, 2018 (edited) Here is a CodeLab script to do what you want: // Name: with Named Color // Submenu: Fill // Author: BoltBait // Title: Fill with Named Color // Version: 1.0 // Desc: Fill selection with named color // Keywords: fill|hex // URL: http://www.BoltBait.com/pdn // Help: Fill with Named Color v1.0\nCopyright ©2018 by BoltBait\nAll rights reserved. #region UICode TextboxControl Amount1 = "#0088ff"; // [0,255] Enter a color by name (green) or by hex code (#00ff00): CheckboxControl Amount2 = true; // [0,1] Keep original alpha #endregion void Render(Surface dst, Surface src, Rectangle rect) { bool Valid = true; ColorConverter c = new ColorConverter(); ColorBgra nc; try { nc = (Color)c.ConvertFromString(Amount1); } catch { nc = Color.Red; Valid = false; } for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) return; for (int x = rect.Left; x < rect.Right; x++) { if (Valid) { if (Amount2) nc.A = src[x,y].A; dst[x,y] = nc; } else { dst[x,y] = src[x,y]; } } } } It prompts you for a string. You can enter any of the standard color names or if you start with a hash tag, you can enter a hex code. It supports the following entries: https://www.w3schools.com/colors/colors_names.asp How to use this script? Easy! Just go here: http://boltbait.com/pdn/codelab and download and install CodeLab. Paste this script into CodeLab and build yourself a DLL to install into paint.net. Edited February 18, 2018 by BoltBait Fix untested, sloppy code. 2 Quote Download: BoltBait's Plugin Pack | CodeLab | and a Computer Dominos Game Link to comment Share on other sites More sharing options...
bitchcraft Posted February 18, 2018 Author Share Posted February 18, 2018 first off, thanks so much for your help, i really appreciate it! i've created the dll and it seems to be working properly in terms of prompting me for a colour or hex, but for some reason when i enter any value at all, it crashes immediately i'm probably just doing something stupid but i'm awful with code so if you know what it is i'm doing wrong i'd really appreciate more help :'D here's the error message: File: C:\Program Files\Paint.NET\Effects\ColourChange.dll Name: MyScriptEffect.MyScriptEffectPlugin Version: 1.0.6623.22273 Author: Copyright ©2018 by BoltBait Copyright: Fill selection with named color Website: http://www.boltbait.com/pdn Full error message: PaintDotNet.WorkerThreadException: Worker thread threw an exception ---> System.Exception: r is not a valid value for Int32. ---> System.FormatException: Input string was not in a correct format. at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at System.ComponentModel.Int32Converter.FromString(String value, NumberFormatInfo formatInfo) at System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) --- End of inner exception stack trace --- at System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) at System.Drawing.ColorConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) at MyScriptEffect.MyScriptEffectPlugin.Render(Surface dst, Surface src, Rectangle rect) at MyScriptEffect.MyScriptEffectPlugin.OnRender(Rectangle[] rois, Int32 startIndex, Int32 length) at PaintDotNet.Effects.Effect`1.Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, Int32 startIndex, Int32 length) in D:\src\pdn\src\Effects\Effect`1.cs:line 98 at PaintDotNet.Effects.BackgroundEffectRenderer.RenderWithClipMask(Effect effect, EffectConfigToken token, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, IRenderer`1 clipMaskRenderer) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 170 at PaintDotNet.Effects.BackgroundEffectRenderer.RendererContext.RenderTile(EffectConfigToken token, Int32 tileIndex) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 150 at PaintDotNet.Effects.BackgroundEffectRenderer.RendererContext.RenderNextTile(EffectConfigToken token) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 142 at PaintDotNet.Effects.BackgroundEffectRenderer.ThreadFunction() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 239 --- End of inner exception stack trace --- at PaintDotNet.Effects.BackgroundEffectRenderer.DrainExceptions() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 418 at PaintDotNet.Effects.BackgroundEffectRenderer.Abort() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 374 at PaintDotNet.Effects.BackgroundEffectRenderer.Start() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 320 at PaintDotNet.Menus.EffectMenuBase.<>c__DisplayClass42_4.<RunEffectImpl>b__4() in D:\src\pdn\src\PaintDotNet\Menus\EffectMenuBase.cs:line 982 Quote Link to comment Share on other sites More sharing options...
BoltBait Posted February 18, 2018 Share Posted February 18, 2018 6 hours ago, bitchcraft said: i'm probably just doing something stupid but i'm awful with code Nope. It was me. All fixed. If you enter something invalid, it just won't change the image. That means, as you type a color word, R-E-D, for example, you won't see a change until you type the letter D. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Computer Dominos Game Link to comment Share on other sites More sharing options...
Woodsy Posted February 19, 2018 Share Posted February 19, 2018 (edited) Welcome Bitchcraft! You might want to try Remake's Color Range plugin. Edited February 19, 2018 by Woodsy Quote My PDN Gallery Link to comment Share on other sites More sharing options...
Djisves Posted February 19, 2018 Share Posted February 19, 2018 On 2/18/2018 at 7:12 AM, bitchcraft said: hey guys, i'm looking for a very simple plugin & i'm sure it already exists, i just can't find it. all i want is a plugin that will change an entire layer's colour to a hex/rgb code that i can input. i don't want any info on the colour changer tool or using the fill bucket, for clarification; i want a plugin that will allow me to put in a hex/rgb code and when applied will change the entire layer to said colour (other than transparent areas, obviously). thanks in advance! 1 Quote Link to comment Share on other sites More sharing options...
bitchcraft Posted February 19, 2018 Author Share Posted February 19, 2018 boltbait, thank you so much for your help, the code works perfectly now! i've donated on the codelab page, sorry i can't afford much thanks to everyone else too for your additional suggestions 1 Quote 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.