NinthDesertDude Posted December 6, 2013 Share Posted December 6, 2013 (edited) OverviewThis overwrites the alpha channel with saturation. Basically, it makes colors with less saturation more transparent (or vice versa). The effect can be found under the Effects --> Transparency tab. EDIT: Note that my channel ops plugin can do all of this as well, so the only thing this plugin is good for is convenience if used frequently. Purpose and applicationsThis changes the transparency of each pixel based on the saturation to preserve colors.This tool is very useful in making backgrounds transparent for your drawings that have color. The more saturation a pixel has, the less transparent it will appear. OptionsInvert Alpha: Inverts the alpha by performing (255 - alpha). RemarksLocated in the Transparency folder under the Effects tab. This used to be called "color to alpha" back when it sucked. It has been highly improved by using the saturation channel instead of luminosity to convert to alpha. This is open source and derivatives are encouraged. By the way, it converts the pixels to HSV in order to get the saturation channel and if you make plugins, you might know how difficult it is (and HsvColor uses HSL, so it's not the same). If you want the source with HsvToRgb() as well, which has been excluded because I don't need it, you can get it here. Source: I declare this to be public domain. #region UICode bool Amount1 = false; //[0,1] Invert Alpha #endregion //This function finds the max value of a range of floats. private float Max(params float[] numbers) { float max = Single.MinValue; foreach (float num in numbers) { if (num > max) { max = num; } } return max; } //This function finds the min value of a range of floats. private float Min(params float[] numbers) { float min = Single.MaxValue; foreach (float num in numbers) { if (num < min) { min = num; } } return min; } void RgbToHsv(float r, float g, float b, out float h, out float s, out float v) { float min, max, delta; min = Min(r, g, ; max = Max(r, g, ; v = max; delta = max - min; if (max != 0) { s = delta / max; } else { s = 0; h = 0; return; } if (r == max) { h = (g - / delta; // between yellow & magenta } else if (g == max) { h = 2 + (b - r) / delta; // between cyan & yellow } else { h = 4 + (r - g) / delta; // between magenta & cyan } h *= 60; // degrees if (h < 0) { h += 360; } } void Render(Surface dst, Surface src, Rectangle rect) { ColorBgra CurrentPixel; for (int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { //Creates the color variables for rgb and hsv. float r, g, b, h, s, v; //Gets the current pixel color. CurrentPixel = src[x,y]; //Sets the values for rgb. //These are 0-1 for RgbToHsv to use. r = (float)CurrentPixel.R / 255; g = (float)CurrentPixel.G / 255; b = (float)CurrentPixel.B / 255; //Calculates the values for hsv. //h is 0-360, s and v are 0-1. RgbToHsv(r, g, b, out h, out s, out v); //Sets the alpha values. if (Amount1) { CurrentPixel.A = (byte)(s * 255); } else { CurrentPixel.A = (byte)(255 - (s * 255)); } //Writes the pixels to the destination surface. dst[x,y] = CurrentPixel; } } } Saturation to Alpha.zip Edited February 29, 2016 by AnthonyScoffler Quote Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted December 6, 2013 Share Posted December 6, 2013 Recommend you choose another name. We already have two plugins named "Color to Alpha" Please advise where the effect is found. I have very full menus and can't seem to locate it. 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...
NinthDesertDude Posted December 6, 2013 Author Share Posted December 6, 2013 Recommend you choose another name. We already have two plugins named "Color to Alpha" Please advise where the effect is found. I have very full menus and can't seem to locate it. I didn't mean to report it to you . I thought that I hit the quote button... Anyway, you won't get in trouble for not saying anything and all I wrote was my response in the report anyway. Hopefully I don't get banned. The effect is under the effects tab in the object submenu Quote Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted December 7, 2013 Share Posted December 7, 2013 The accidental report is not a problem Thanks for updating the post.Ok. Found it. It's appearing under the Object menu as "Switch Color to Alpha".1. I recommend you rename the plugin to something like Switch Color to Alpha to differentiate from the others. 2. I don't really think it belongs under the Object menu. That's for plugins which act on groups of pixels surrounded by transparency (i.e. objects). Other options might be the Color menu (the other Color-To-Alpha's are there) or even the Transparency menu (with AlphaThreshold, Selection2clear and Tweak Transparency). Your call. 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...
NinthDesertDude Posted December 7, 2013 Author Share Posted December 7, 2013 Thanks for your feedback and attentive responses. It really lets me know that other people are on this site because, despite the views each topic gets, it otherwise feels rather empty. 1. I recommend you rename the plugin to something like Switch Color to Alpha to differentiate from the others. 2. I don't really think it belongs under the Object menu. That's for plugins which act on groups of pixels surrounded by transparency (i.e. objects). Other options might be the Color menu (the other Color-To-Alpha's are there) or even the Transparency menu (with AlphaThreshold, Selection2clear and Tweak Transparency). Your call. I would rename the plugin and put it in a different category, but as I've said before, I'm trying to replicate the style of BoltBait's plugin as closely as possible. His was in the object file, and is called "gray to alpha". My icon is even the same as his with the small exception that it's colored. I meant it to be used with his gray to alpha plugin or to replace it seamlessly. Quote Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted December 7, 2013 Share Posted December 7, 2013 Mimicing BoltBait's plugin is not a problem. I would argue that his plugin is also probably due a relocation (he'll read this, then I'll have some explaining to do ). Location aside, I think you should do a little renaming to make it clear how to find the plugin. I would change this thread title and the plugin name and the dll filename to "Switch Color to Alpha". Otherwise users are going to struggle to find it. Like I did. If the Alpha version of pdn4.0 didin't show the plugin path as a tooltip I would never have found it. Re: forum activity. There is lots going on. Check out the Pictorium for lots of new images and posts. 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...
barbieq25 Posted December 7, 2013 Share Posted December 7, 2013 AnthonyScoffler, good to have someone else write plugins here. Not sure if yours will have any bearing on my work. The forums is humming along nicely but it would be better if people took more time to respond to posts esp. in the pictorium where people showcase their works. Galleries are a good place to see what types of works are being created & the kinds of plugins people are using & what we are lacking. I don't write plugins - no idea on codes & can barely manage a simple link. Anything that starts with Alpha makes my eyes glaze over because I just struggle with the whole concept. I'm not alone in this either. I was wondering if you could post up a couple of before & after images to show folk how to use it. Or even write a tute on it. I'm wondering how many plugins are under-utilised because people don't understand how to use them? E.g. I love BoltBait's Lomography but the slider doesn't go far enough to the right (I should ask about this, shouldn't I). I don't understand what Lomography is other than I just adore the effect it gives. Quote Knowledge is no burden to carry. April Jones, 2012 Gallery My DA Gallery Link to comment Share on other sites More sharing options...
BoltBait Posted December 8, 2013 Share Posted December 8, 2013 I would argue that his plugin is also probably due a relocation (he'll read this, then I'll have some explaining to do). One day I'll write a tutorial on how to use my effect and you'll understand why it is perfectly located. Quote Click to play: Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game Link to comment Share on other sites More sharing options...
NinthDesertDude Posted December 8, 2013 Author Share Posted December 8, 2013 (edited) I would change this thread title and the plugin name and the dll filename to "Switch Color to Alpha" How do I change the name of the thread? Edited December 8, 2013 by AnthonyScoffler Quote Link to comment Share on other sites More sharing options...
nitenurse79 Posted December 8, 2013 Share Posted December 8, 2013 How do I change the name of the thread? EER is referring to the name of the plugin, not the thread Quote Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted December 8, 2013 Share Posted December 8, 2013 Plugin and ALSO the thread. For simplicity, keeping the thread the same name as a plugin makes locating both a great deal easier. @Anthony: Edit the first post then click the button "Use Full Editor" at the foot of the editing window. The full editor has the option to change the thread title. 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...
NinthDesertDude Posted August 21, 2014 Author Share Posted August 21, 2014 I changed the entire plugin because the old one was junk. This one is much better and it uses the saturation channel instead of luminosity. Hope nobody misses the old clutter . Quote Link to comment Share on other sites More sharing options...
Djisves Posted August 22, 2014 Share Posted August 22, 2014 (edited) Thank you for the update Anthony. Is it at all possible to provide an alternative way to download other than FileToLink? I do not have (and I don't want to have) accounts with Facebook or Google+. EDIT: I downloaded your other three plugins from FileToLink without any problem. It's just this one that asks me for verification through Fb or Google because it says it has been uploaded by an "unregistered user". Fancy that! Edited August 22, 2014 by Djisves Quote Link to comment Share on other sites More sharing options...
david.atwell Posted August 22, 2014 Share Posted August 22, 2014 You could just upload it as a ZIP attachment to this post. Quote The Doctor: There was a goblin, or a trickster, or a warrior... A nameless, terrible thing, soaked in the blood of a billion galaxies. The most feared being in all the cosmos. And nothing could stop it, or hold it, or reason with it. One day it would just drop out of the sky and tear down your world.Amy: But how did it end up in there?The Doctor: You know fairy tales. A good wizard tricked it.River Song: I hate good wizards in fairy tales; they always turn out to be him. Link to comment Share on other sites More sharing options...
NinthDesertDude Posted August 22, 2014 Author Share Posted August 22, 2014 I downloaded your other three plugins from FileToLink without any problem. If I log in with my google account and post it, the link doesn't hassle others. I must've forgot. I updated the link. 1 Quote Link to comment Share on other sites More sharing options...
Djisves Posted August 23, 2014 Share Posted August 23, 2014 Thank you. I was able to download it today without any problem. 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.