Jump to content


Photo

Selection2clear


  • Please log in to reply
17 replies to this topic

#1 Red ochre

Red ochre
  • Members
  • 537 posts
  • LocationSurrey, England
  • Reputation:63

Posted 04 June 2012 - 03:43 PM

Selection2clear [makes the selection transparent, whilst leaving the selection active]

Hello all,

The problem: I spend ages isolating a complex selection, I delete the selection on one layer, move to the next layer to try to delete the same selection - but the selection is gone!

(This doesn't happen with 'fill selection' - only with delete. It caused me problems because I was trying to shape a cloud made up from many layers all interacting via different blending modes. Thought I'd try just changing the top layer and then use 'Alpha mask' on the other layers but Alpha mask didn't work for some reason - maybe due to the layer blend modes or because the transparency of the different layers were not fully opaque?)

The soloution: My simplest plugin yet! - select something, click 'selection2clear' (under Effects/selection), problem solved, selection clear but still active so I can now change layers and repeat the action.

No UI screen shot as no UI !

I'm probably the only person that will use this but if you encounter the same problem here's the .dll
Attached File  selection2clear.zip   3.67K   394 downloads

And here's the code for in-depth study!
/* =================================================== */

/* selection to clear*/
/* © 2012 Red Ochre	 */
/*	 */
/* Description: make selection transparent, plugins maintain the selection, delete doesnt    */
/*	 */
/* ========================================== ======== */

// Name: selection2clear
// Author: Red ochre (John Robbins)
// Submenu: Transparency
// URL: http://www.getpaint.net/redirect/plugins.html
// Title: selection2clear					 June 2012 Red Ochre


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 CurrentPixel = src[x,y];
		    CurrentPixel.A = 0; // now preserves BGR values as suggested by BoltBait
		    dst[x,y] = CurrentPixel;
	    }
    }
}

Posted Image
Red ochre Plugin pack............................................................... Diabolical Drawings

#2 Rick Brewster

Rick Brewster

    Paint.NET Author and Developer

  • Administrators
  • 12,567 posts
  • LocationKirkland, WA
  • Reputation:120

Posted 04 June 2012 - 03:50 PM

Why not just use Edit -> Fill Selection with a transparent color?
The Paint.NET Blog: http://blog.getpaint.net/
Donations are always appreciated! http://www.getpaint.net/donate.html

Posted Image

#3 Red ochre

Red ochre
  • Members
  • 537 posts
  • LocationSurrey, England
  • Reputation:63

Posted 04 June 2012 - 04:00 PM

Hi Rick,
Yes you can - I think it's easier to just click on one icon and have the selection clear rather than expanding the color window, then changing the primary color - then changing it back again - I did say I would probably be the only person using it!
Posted Image
Red ochre Plugin pack............................................................... Diabolical Drawings

#4 yellowman

yellowman
  • Members
  • 1,489 posts
  • Reputation:63

Posted 04 June 2012 - 06:16 PM

Good idea Red Ochre,
Boltbait plugin Transparency, I use it for same purpose.

#5 midora

midora
  • Members
  • 336 posts
  • Reputation:12

Posted 05 June 2012 - 08:08 AM

You may use cut and paste to do the trick.

1. Select something in a layer
2. Cut
3. Switch to another layer
4. Paste (this restores the selection)
5. Cut
6. Goto 3.

But I would also vote to decouple Delete and Deselect.
Posted Image

#6 Rick Brewster

Rick Brewster

    Paint.NET Author and Developer

  • Administrators
  • 12,567 posts
  • LocationKirkland, WA
  • Reputation:120

Posted 06 June 2012 - 07:25 PM

Hi Rick,
Yes you can - I think it's easier to just click on one icon and have the selection clear rather than expanding the color window, then changing the primary color - then changing it back again - I did say I would probably be the only person using it!

Well then if it's easier for you, why not :)
The Paint.NET Blog: http://blog.getpaint.net/
Donations are always appreciated! http://www.getpaint.net/donate.html

Posted Image

#7 barbieq25

barbieq25
  • Members
  • 4,267 posts
  • LocationQueensland, Australia
  • Reputation:106

Posted 06 June 2012 - 08:45 PM

Well, I never knew of some of the suggestions (except the copy paste, which is what I used to do) but I like the idea of the plugin. I'll give it whirl! Thankies!

Sig2.png


Knowledge is no burden to carry.

 

April Jones, 2012

 

Gallery

My DA Gallery


#8 Red ochre

Red ochre
  • Members
  • 537 posts
  • LocationSurrey, England
  • Reputation:63

Posted 06 June 2012 - 10:02 PM

@ yellowman - Boltbait's 'Transparency' plugin is always useful - the only slight advantage of this, for this job, is that it is in the effects section rather than adjustments, so if used on multiple layers the icon appears in the top 'apply last effect' section.

@ midora - I had'nt thought of doing it that way, clever!

@ Rick - I meant no criticism of the default selection behaviour. Just thought I'd share my soloution to this task.
As you can see from the code, I didn't waste too much time writing it, and now we have 4 ways to do it. ;)

@ barbieq25 - not as much fun (or as complicated) as some of my others I'm afraid, but it does what I wanted.
Thanks for saying thanks. :)
Posted Image
Red ochre Plugin pack............................................................... Diabolical Drawings

#9 Red ochre

Red ochre
  • Members
  • 537 posts
  • LocationSurrey, England
  • Reputation:63

Posted 09 June 2012 - 09:34 PM

? - no idea what you're on about ? :/
Posted Image
Red ochre Plugin pack............................................................... Diabolical Drawings

#10 65432123456

65432123456
  • Newbies
  • 2 posts
  • Reputation:0

Posted 10 June 2012 - 06:25 PM

? - no idea what you're on about ? :/


paint net is just middle kids between paintbrush and photoshop............get it?

#11 65432123456

65432123456
  • Newbies
  • 2 posts
  • Reputation:0

Posted 10 June 2012 - 06:31 PM

after using your plugin, my font is disappear ....can you fix it ...thanks

#12 BoltBait

BoltBait
  • Administrators
  • 8,913 posts
  • LocationCalifornia, USA
  • Reputation:103

Posted 10 June 2012 - 07:08 PM

I don't recommend putting this under the Selection menu. Because it doesn't use the "marching ants" selection path to affect the overall effect. You should put this under "Render > Transparent".

Also, your render loop should look like this:
ColorBgra CurrentPixel = src[x,y];
CurrentPixel.A=0;
dst[x,y]=CurrentPixel;
...this way the color information is retained. Done this way, you can bring back the pixels later using Adjustments > Transparency.

Visually, the result is the same. However, this way your effect is more useful.
Click to play:
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image
Download: BoltBait's Plugin Pack | CodeLab | More... and how about a Computer Dominos Game

#13 Red ochre

Red ochre
  • Members
  • 537 posts
  • LocationSurrey, England
  • Reputation:63

Posted 10 June 2012 - 07:57 PM

Ok - will change to preserve BGR values. Would Effects/transparency be ok.? (Render is very overcrowded, on my set up anyway).
Many thanks - I have updated the .dll and the source as suggested.
Posted Image
Red ochre Plugin pack............................................................... Diabolical Drawings

#14 Ego Eram Reputo

Ego Eram Reputo

    Master of Competition Ideas and 2012 Proton Award Winner

  • Moderators
  • 5,646 posts
  • LocationNorth Canterbury, New Zealand
  • Reputation:223

Posted 10 June 2012 - 10:15 PM

Arguably its an adjustment. Considered the Adjustments menu?

#15 Red ochre

Red ochre
  • Members
  • 537 posts
  • LocationSurrey, England
  • Reputation:63

Posted 10 June 2012 - 10:27 PM

Hi EER,
I wanted it in the effects menu because of the 'repeat last effect' option after using it once.
Technically (arguably) 'psychocolour' is an adjustment but it seemed more logical to put that under color :D

Starting to wish I hadn't bothered with this! :lol:
Posted Image
Red ochre Plugin pack............................................................... Diabolical Drawings

#16 Ego Eram Reputo

Ego Eram Reputo

    Master of Competition Ideas and 2012 Proton Award Winner

  • Moderators
  • 5,646 posts
  • LocationNorth Canterbury, New Zealand
  • Reputation:223

Posted 11 June 2012 - 12:15 AM

It's a good learning experience! :)

#17 Djisves

Djisves
  • Members
  • 148 posts
  • LocationCyprus
  • Reputation:4

Posted 13 June 2012 - 04:05 PM

...
I wanted it in the effects menu because of the 'repeat last effect' option after using it once.
...

I can smell a feature request just around the corner... "Repeat Last Adjustment", perhaps?
I know I'm off-topic but I wanted to comment.

No signature image good enough for this forum


#18 Ego Eram Reputo

Ego Eram Reputo

    Master of Competition Ideas and 2012 Proton Award Winner

  • Moderators
  • 5,646 posts
  • LocationNorth Canterbury, New Zealand
  • Reputation:223

Posted 13 June 2012 - 10:06 PM

I've been thinking about that one too. If it's good for the Effects, why not the Adjustments?