Jump to content

Color Cut


DataDink
 Share

Recommended Posts

I am, however, making every effort to ensure that these plugins are truly "open source" allowing anyone to make such contributions via well-established technologies such as those provided by the open-source community at github.com.

 

Free Software is better than Open Source. B)

 

P,S, I do wish there was better "official" documentation on the PDN libraries. I'm currently reflecting into PDN libraries and tracing code paths with a fair amount of sadness.

Indeed. Many months ago I ran VSdocman on the paint.net v3.3 source code, but it was of no worth as so much has changed.

(VSdocman generates MSDN-style documentation for a code base)

Link to comment
Share on other sites

https://www.gnu.org/philosophy/free-sw.html

 

A program is free software if the program's users have the four essential freedoms:

  • The freedom to run the program as you wish, for any purpose (freedom 0).
  • The freedom to study how the program works, and change it so it does your computing as you wish (freedom 1). Access to the source code is a precondition for this.
  • The freedom to redistribute copies so you can help your neighbor (freedom 2).
  • The freedom to distribute copies of your modified versions to others (freedom 3). By doing this you can give the whole community a chance to benefit from your changes. Access to the source code is a precondition for this.
 

Another group uses the term “open source” to mean something close (but not identical) to “free software”. We prefer the term “free software” because, once you have heard that it refers to freedom rather than price, it calls to mind freedom. The word “open” never refers to freedom.

Link to comment
Share on other sites

It certainly is not my intention to offend and this is clearly a debate I don't want to be a part of so please feel free to apply whatever labels you feel are appropriate.

 

Just want to include some "git" terms you will find where I have the source uploaded and the possible "freedom software" translations. Some of this will just be "source-control" basics if you are already familiar with the term.

  • Repository - This is a publicly visible location where anyone can access, study, and download the source code actually used to build the final product. You also have the right to do so. You can also feel free to use any of my stuff however you see fit as long as you don't try to hold me responsible for damages, or anything else, ever. Note: GitHub also offers private repositories allowing you to use GitHub services for your personal stuff that you don't want the world to see)
  • Pull Request - This is an actual code change you have made and can send to the project moderator who can choose to accept or deny this change to the primary / original project. This is usually accepted or declined based on if it is deemed something that the whole community is likely to agree is a benefit to the project they already know and love (maybe love).
  • Fork - You can start your own version of any project and base it on the original source allowing you to take it a different direction with no restrictions. You become the moderator of the forked project which can now be changed and redistributed as you see fit. The bonus of this is that you maintain a connection or lineage with the original project(s) and can then easily accept or deny changes from the original source as you see fit for your fork/version. With your forked project you will also build a forked community that sees things more your way.
  • Branch - This is like a fork but the intention is that it will be eventually merged back into the original project so going a completely different direction here is much less likely.
  • History - a memory of changes is maintained for every project, branch, fork, etc. Forks and branches can be made off of any of these points in history. Forks can also fork off of forks and still maintain the benefits of lineage without suppressing your rights as a free developer.
  • Contributor - This is someone who takes at least partial credit for the current state of the source code as it currently stands.
  • Moderator - This is someone authorized to accept or reject changes to a project (and so also become a contributor to the project)

- Cheers!

Link to comment
Share on other sites

It certainly is not my intention to offend and this is clearly a debate I don't want to be a part of so please feel free to apply whatever labels you feel are appropriate.

I doubt anyone has been offended or wants to debate either.

Calling it open source is fine, as open source gives the software freedoms. (it's just not overt about it; that's the only difference)

Sorry I brought it up. :roll:

Link to comment
Share on other sites

No sorry on your part needed at all - you enlightened me to an issue I had never even heard of before. My intention is to promote easy community contribution to my project thereby relieving myself of responsibility that would ultimately lead to abandonware and reduce the value of my own contribution. What I now know is the label I have been using is better replaced with a "please feel free to contribute or fork this project here" link and let people call it whatever they want. So thank you for the enlightenment!

- Cheers!

Link to comment
Share on other sites

  • 1 year later...

Looks like just what the Dr ordered for doing chroma key work for our photography... would love to try it but get plugin error on launching after PDN loads successfully...

Error Details:

 

File: C:\Program Files\Paint.NET\Effects\ColorCut.dll
      Effect Name: ColorCut.Plugin
      Full error message: System.MethodAccessException: Attempt by method 'DinkPDN.Effects.Simple.ConfigurableIntAttribute.Create(System.Reflection.PropertyInfo)' to access method 'PaintDotNet.IndirectUI.ControlInfo.CreateConcreteControl(System.Object)' failed.
   at DinkPDN.Effects.Simple.ConfigurableIntAttribute.Create(PropertyInfo property)
   at DinkPDN.Effects.Simple.BaseConfigurableEffect.CreateConfigDialog()
   at PaintDotNet.Menus.EffectMenuBase.RunEffectImpl(Type effectType) in D:\src\pdn\src\PaintDotNet\Menus\EffectMenuBase.cs:line 910

 

 

not sure if this is my installation of PDN v 4.0.13  (final 4.13.6191.1824) W10 platform... or a conflict with another plugin... or ????... did not see any other bug rpts in this thread

 

thanks in advance

Link to comment
Share on other sites

It looks like this plugin need to be recompiled. It's open source - so someone with the time and inclination should be able to do it.

Link to comment
Share on other sites

  • 3 months later...

Well @Ego Eram Reputo I had the time - but the error it generates is beyond my understanding. Seems to be missing an EOF statement or something.

The only error it shows in codelab looks like this -

 

Error at line 114: Type or namespace definition, or end-of-file expected (CS1022)

 

Seems the source code is not quite complete.

A very minor issue as this plugin is a bit outdated but is still a good learning source. A simple fix for any professionals around. B)

qG3vze.png

 

Link to comment
Share on other sites

You're probably missing a closing } at the end of the file. Check that the brackets are correctly paired.

Link to comment
Share on other sites

5 hours ago, AndrewDavid said:

... but the error it generates is beyond my understanding. Seems to be missing an EOF statement or something.

The only error it shows in codelab looks like this ....

The source code for this plugin is not compatible with CodeLab, so you'd need to use Visual Studio. Further more, a simple recompile won't be enough; it needs to be rewritten.

DataDink was deriving from IndirectUI in ways that Rick didn't mean to make possible. Rick fixed the mistake in paint.net v4.0.10, and thus DataDink plugins became inoperable.

 

 

Link to comment
Share on other sites

  • 4 years later...
On 1/17/2017 at 7:57 PM, Ego Eram Reputo said:

It looks like this plugin need to be recompiled. It's open source - so someone with the time and inclination should be able to do it.

Once again, Punk'n finds a plugin that's eluded every previous search I've conducted; however jumped to the front when browsing the library for the heck of it. HAHAHA! Fashionably (and fantastically) late entrances are my forte, even when sporting my footy-pajamas! But, I digress ---

 

When I clicked both the GitHub & Download links, my arch nemesis "Dr. 404" reared his ugly head and killed the feeling of excitement I held to just try this out on a current project that this exact "tool" would be perfect for!  Does anybody [here] know if this is due to the plugin being recompiled?  Or if it's a "dead horse", is there another equally useful plugin out there that can do the same job as this one?  I don't mind waiting if this is indeed to be updated in the near future... but I lost my stick when I was out poking bears so, being [myself] means having a "concentration leak" and total lack of talent in the multi-tasking department. This means there's more than just a small chance that this is a repeated question which I missed while reading.... oooohhh shiny!!!! 

Link to comment
Share on other sites

43 minutes ago, PunkN13 said:

is there another equally useful plugin out there that can do the same job as this one?

Hi @PunkN13

You can try Color Replace, Recolour Choice, or Replace Colors just to name a few. All found in the Plugin Index.

It really is determined by the graphic you are modifying. Some work well, some don't.

Sad the author never returned and abandoned his GitHub post.

I very much doubt the plugin will be rewritten due to other available choices.

Hope this helps.

qG3vze.png

 

Link to comment
Share on other sites

2 hours ago, AndrewDavid said:

very much doubt the plugin will be rewritten due to other available choices

I don't think all is lost if someone has the dll file. If one has earlier version of pdn, and a copy of the dll, then one can move forward to make an update or see if existing alternative does the same.

 

I managed to send the author a mail.

Edited by Reptillian

G'MIC Filter Developer

Link to comment
Share on other sites

15 hours ago, PunkN13 said:

Once again, Punk'n finds a plugin that's eluded every previous search I've conducted; however jumped to the front when browsing the library for the heck of it. HAHAHA! Fashionably (and fantastically) late entrances are my forte, even when sporting my footy-pajamas! But, I digress ---

 

When I clicked both the GitHub & Download links, my arch nemesis "Dr. 404" reared his ugly head and killed the feeling of excitement I held to just try this out on a current project that this exact "tool" would be perfect for!  Does anybody [here] know if this is due to the plugin being recompiled?  Or if it's a "dead horse", is there another equally useful plugin out there that can do the same job as this one?  I don't mind waiting if this is indeed to be updated in the near future... but I lost my stick when I was out poking bears so, being [myself] means having a "concentration leak" and total lack of talent in the multi-tasking department. This means there's more than just a small chance that this is a repeated question which I missed while reading.... oooohhh shiny!!!! 

I have said before - it would be (edit:nice) advisable that all "donated" plugins be donated with source - and when, not if, that author fades away, then the authorities can then manage the plugin. Commercial plugins are a separate issue.

 

(I think there is a lot of ego that is involved - albeit warranted, but not necessarily deserved)

Edited by Panchdara
Link to comment
Share on other sites

I rewrote it for CodeLab. Please feel free to do improvements on it.

 

Description of options:

Color Threshold: The max deviation in color from the background a pixel can have to be affected.

Shade Threshold: The max deviation in shade from the background a pixel can have to be affected.

Alpha Falloff: The ratio at which the alpha channel will be tapered off.

 

Spoiler
// Name: ColorCut
// Submenu: Color
// Author: 
// Title:
// Version: 1.0.0.0
// Desc:
// Keywords:
// URL:
// Help:
#region UICode
IntSliderControl colorThreshold = 40; // [0,256] Color Threshold
DoubleSliderControl shadeThreshold = 1; // [0,1] Shade Threshold
DoubleSliderControl alphaFalloff = .5; // [0,1] Alpha Falloff
#endregion

private ColorBgra bgColor;
private double bgShade;
private ColorBgra bgNormal;

void PreRender(Surface dst, Surface src)
{
    bgColor = EnvironmentParameters.SecondaryColor;
    bgShade = bgColor.ToColor().GetBrightness();
    bgNormal = Normalize(bgColor);
}

void Render(Surface dst, Surface src, Rectangle rect)
{
    for (int y = rect.Top; y < rect.Bottom; y++)
    {
        for (int x = rect.Left; x < rect.Right; x++)
        {
            ColorBgra initial = src[x, y];
            float shade = initial.ToColor().GetBrightness();
            if (Math.Abs(shade - bgShade) > shadeThreshold)
            {
                dst[x,y] = initial;
                continue;
            }

            var norm = Normalize(initial);
            if (Math.Abs(bgNormal.R - norm.R) > colorThreshold
                || Math.Abs(bgNormal.G - norm.G) > colorThreshold
                || Math.Abs(bgNormal.B - norm.B) > colorThreshold)
            {
                dst[x, y] = initial;
                continue;
            }

            var alpha = (byte)(Math.Min(255, Math.Max(0,
                Math.Max(Math.Max(
                    Math.Abs(bgColor.R - initial.R),
                    Math.Abs(bgColor.G - initial.G)),
                    Math.Abs(bgColor.B - initial.B)))
                * (1d - alphaFalloff)));

            dst[x, y] = ColorBgra.FromBgra(initial.B, initial.G, initial.R, alpha);
        }
    }
}

private static ColorBgra Normalize(ColorBgra color)
{
    var nbase = Math.Min(Math.Min(color.R, color.G), color.B);
    return ColorBgra.FromBgr((byte)(color.B - nbase), (byte)(color.G - nbase), (byte)(color.R - nbase));
}

 

 

  • Like 2
  • Upvote 1
  • You're a Smart Cookie! 1
Link to comment
Share on other sites

10 hours ago, otuncelli said:

I rewrote it for CodeLab.

 

I urge you to republish this in its own right (i.e. thread). We can subsequently lock this thread as "Incompatible".

 

Naturally, if @DataDink ever returns we can revisit the value of unlocking this thread, or merging them.

  • Like 1
  • Upvote 1
Link to comment
Share on other sites

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.

 Share

×
×
  • Create New...