Jump to content

-- Add a new layer   -- paint it white -- put the layer underneath -- Control-M to merge <---  is there a shortcut that combines these 4 steps ?


Recommended Posts

i'm working on  a picture, and

 

              -- Add a new layer

              -- paint it all white

              -- put the layer underneath

              -- Control-M to merge

 

----------  is there a shortcut that combines these 4 steps ?

Link to comment
Share on other sites

It would be trivial to create a plugin to do this.

 

PlaceOverWhite.zip

 

Source Code:

Spoiler
// Name: Place Over White
// Submenu: Object
// Author: BoltBait
// Title: Place over White v1.0
// Version: 1.0
// Desc: Make transparent areas white
// URL: https://BoltBait.com/pdn
// Help: Copyright (C)2024 BoltBait, all rights reserved.

protected override IDeviceImage OnCreateOutput(IDeviceContext deviceContext)
{
    // create white surface
    CroppedFloodEffect solidColorEffect = new CroppedFloodEffect(deviceContext);
    solidColorEffect.Properties.Color.SetValue((ColorRgba128Float)ColorBgra.White);
    solidColorEffect.Properties.Rect.SetValue(Environment.SourceImage.GetLocalBounds(deviceContext));

    // combine the current layer with a white background
    CompositeEffect blendNormal = new CompositeEffect(deviceContext);
    blendNormal.SetInput(0, solidColorEffect); // Input 0 is the bottom layer
    blendNormal.SetInput(1, Environment.SourceImage); // Input 1 is the top layer
    blendNormal.Properties.Mode.SetValue(CompositeMode.SourceOver);

    return blendNormal;
}

 

 

  • Upvote 5
Link to comment
Share on other sites

19 hours ago, HenryH said:

is there a shortcut that combines these 4 steps


No, because such a shortcut would be specific to your particular way of doing this.


So, either use @BoltBait's code, or this sequence of shortcut keys:

- Add a new layer                 Ctrl+Shift+N

 

- Move layer down               Alt+L+O

 

- Fill it with Pri/Sec colour   Ctrl+A  then  Shift+Backspace to fill selection with the Secondary colour (the paint.net default is white)
                                                               or  Backspace to fill selection with the Primary colour

 

- Merge layer above down  Alt+PgUp  then Ctrl+M

 
 

This sequence can be activated by a single shortcut Ctrl+Shift+Alt+M for Secondary colour (or Ctrl+Alt+M for Primary colour) using AutoHotkey 

 

Source Code:

Spoiler
; PlaceOverColour.ahk

#Requires AutoHotkey v2
#SingleInstance Force

; Ctrl+Shift+Alt+M to place the current layer over the Secondary colour & merge
; Ctrl+Alt+M       to place the current layer over the Primary colour & merge

#HotIf WinActive("ahk_exe paintdotnet.exe")
^+!m::   
^!m::   
{
    Send "^+n"   ; New layer
    Send "!lo"   ; Move layer down
    Send "^a"    ; Select all

    ; Did the pressed hotkey include Shift?
    if InStr(A_ThisHotkey, "+")
        Send "+{Backspace}"    ; Fill with Secondary colour
    else
        Send "{Backspace}"     ; Fill with Primary colour

    Send "!{PgUp}"   ; Go to layer above
    Send "^m"        ; Merge down
}

 

 

 

 

  • 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.

×
×
  • Create New...