Jump to content
How to Install Plugins ×

Channel Swap - manipulate colour & alpha of image, tile clipboard, and more


Recommended Posts

Channel Swap is a effect that I've made recently.

It allows to manipulate colour and alpha channels of image, switching them between a number of options, and mixing them with clipboard contents.

It's interface looks like this:

4cb44a373b.png

And it can serve a lot of purposes, combining pixel data for use with other effects among other things, which can be used to make effects like this, for example:

328bbf5a7b.png

(I've also posted a step-by-step process of making that image on my blog)

Description of options:

Colour: Colour (RGB) value for output image

  • Colour - original RGB from image
  • InvColour - inverted RGB from image (255 - n)
  • Alpha - alpha channel from image (AAA)
  • InvAlpha - inverted alpha channel from image (AAA)
  • One - white (FFFFFF)
  • Zero - black (000000)
  • Foreground - uses RGB values from foreground colour
  • Background - uses RGB values from background colour
  • Use image from clipboard - if set, clipboard contents are used instead of source image

Alpha: Alpha (A) value for output image

  • Alpha - original A from image
  • InvAlpha - inverted A from image (255 - A)
  • Colour - computes average from RGB in image ((R + G + B) / 3)
  • InvColour - inverted average from RGB in image
  • One - fully opaque
  • Zero - fully transparent
  • Foreground alpha - uses A from foreground colour
  • Background alpha - uses A from background colour
  • Use image from clipboard - if set, clipboard contents are used instead of source image
  • Mix alpha - If turned on, resulting alpha is mixed with source, rA = sA * A / 255 (where A is defined by Alpha option)

Among it's sole uses, you can do the following with it:

  • Make image opaque (or of given alpha value)
  • Make image invisible (handy, as you can hide information in seemingly empty PNG images this way)
  • Fill image with colour while preserving alpha
  • Combine alpha of image with a constant value or alpha mask
  • Fill image with clipboard contents (with or without preserving alpha)
  • Invert alpha of image
  • Get alpha 'mask' of image
  • Apply existing alpha mask to image
  • (more possibilities)

Once installed, effect can be found as 'Effects/Color/Channel Swap...', and can be easily identified by a icon with green arrows, taken from FamFamFam icon pack to match up existing icons nicely.

Download: Zip file with effect DLL is attached to the post.

You can also download it from SolidFiles, if attachment doesn't work somehow.

Note: Currently, effect ignores alpha information of clipboard contents.

If someone (Rick Brewster?) could explain how normal clipboard manipulation works in Paint.NET (method reference?), it would be very helpful. My current implementation of clipboard reader part is as following:

private Surface _clipboard = null;
protected Surface clipboard { get {
if (_clipboard != null) return _clipboard;
System.Threading.Thread th = new System.Threading.Thread(
	new System.Threading.ThreadStart(_clipboard_get)
); th.SetApartmentState(System.Threading.ApartmentState.STA);
th.Start(); th.Join();
return _clipboard;
} }
private void _clipboard_get() {
Bitmap d = null;
System.Windows.Forms.IDataObject o;
try {
	o = System.Windows.Forms.Clipboard.GetDataObject();
	if (o != null) d = (Bitmap)o.GetData(typeof(System.Drawing.Bitmap));
} catch (Exception) { }
_clipboard = ((d != null) ? Surface.CopyFromBitmap(d) : null);
}

I've rechecked code not once now, and have made long searches, but all relevant results are using same methods to obtain clipboard data.

Have a nice day.

Channel Swap.zip

Edited by YellowAfterlife

o.png_.png_.gif

Link to comment
Share on other sites

Can you please make it more obvious what the different options actually do? Some screenshots would help. At least give us a rundown of the functions of each.

You might like to also explain how your plugin differs from these others so users have some idea what to use your plugin for.

  • Upvote 1
Link to comment
Share on other sites

Edited first post with description on what everything does.

Since options work separately for colour and alpha, it would take a lot of images to show everything.

About comparison to other plugins:

Color Replace - seems to do different actions. Also all links are broken, and download leads to topic where there isn't a copy of plugin available.

Channel Mixer - that's actually a very nice plugin, haven't seen that one. It serves similar purposes. My effect is slightly simpler than that (as can be seen, you can not specify modification for each separate R/G/B channel), allows to use clipboard, and theoretically would be faster to use.

o.png_.png_.gif

Link to comment
Share on other sites

Edited first post with description on what everything does.

Thanks!

Color Replace - seems to do different actions. Also all links are broken, and download leads to topic where there isn't a copy of plugin available.

The link correctly takes you to the thread for Jesse Chunn's plugin pack which contains the plugin. The downloadable ZIP is the very first link in the thread - and it downloads fine (I checked!)

Link to comment
Share on other sites

Paint.NET doesn't provide any extra Clipboard functionality for plugins, and I would not support or allow (at this time) using its internal ClipboardUtil class for a plugin, or the MaskedSurface data type for accessing the selection geometry. At some point in the magical future I'd love to tidy these up such that plugins as well as other applications could handle them, but there just isn't any time for that just yet.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

  • 2 years later...

Paint.NET doesn't provide any extra Clipboard functionality for plugins, and I would not support or allow (at this time) using its internal ClipboardUtil class for a plugin, or the MaskedSurface data type for accessing the selection geometry. At some point in the magical future I'd love to tidy these up such that plugins as well as other applications could handle them, but there just isn't any time for that just yet.

It has been a little while. Has anything changed? Or does one still need to add a text field (for specifying image path) just for transparency support?

o.png_.png_.gif

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.

×
×
  • Create New...