forked from PintaProject/Pinta
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated MoveSelectedTool.cs to convert the selected pixels to 100% op…
…acity with a Normal blend mode, since they're going to be merged back into the layer that has its persistent BlendMode and opacity anyway. See issue PintaProject#819.
- Loading branch information
Showing
1 changed file
with
32 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
// | ||
// | ||
// MoveSelectedTool.cs | ||
// | ||
// | ||
// Author: | ||
// Jonathan Pobst <[email protected]> | ||
// | ||
// | ||
// Copyright (c) 2010 Jonathan Pobst | ||
// | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
|
@@ -75,17 +75,37 @@ protected override void OnStartTransform (Document document) | |
// Copy the selection to the temp layer | ||
document.Layers.CreateSelectionLayer (); | ||
document.Layers.ShowSelectionLayer = true; | ||
// Use same BlendMode, Opacity and Visibility for SelectionLayer | ||
document.Layers.SelectionLayer.BlendMode = document.Layers.CurrentUserLayer.BlendMode; | ||
document.Layers.SelectionLayer.Opacity = document.Layers.CurrentUserLayer.Opacity; | ||
document.Layers.SelectionLayer.Hidden = document.Layers.CurrentUserLayer.Hidden; | ||
// Make the SelectionLayer fully opaque and visible. | ||
document.Layers.SelectionLayer.BlendMode = BlendMode.Normal; | ||
document.Layers.SelectionLayer.Opacity = 1.0; | ||
document.Layers.SelectionLayer.Hidden = false; | ||
|
||
var g = new Context (document.Layers.SelectionLayer.Surface); | ||
g.AppendPath (document.Selection.SelectionPath); | ||
g.FillRule = FillRule.EvenOdd; | ||
g.SetSourceSurface (document.Layers.CurrentUserLayer.Surface, 0, 0); | ||
g.Clip (); | ||
g.Paint (); | ||
|
||
// Ensure that the pixels we copy have 100% opacity. The layer we're pasting them back into | ||
// still has its opacity (which may be less than 1.0) set as a persistent property, so as | ||
// soon as the move operation is committed, that opacity will apply to them once again. | ||
// Within the context of the layer, we want the pixels to be moved as though they are | ||
// opaque. | ||
var savedOpacity = document.Layers.CurrentUserLayer.Opacity; | ||
var savedBlendMode = document.Layers.CurrentUserLayer.BlendMode; | ||
|
||
try | ||
{ | ||
document.Layers.CurrentUserLayer.Opacity = 1.0; | ||
document.Layers.CurrentUserLayer.BlendMode = BlendMode.Normal; | ||
|
||
g.Clip (); | ||
g.Paint (); | ||
} | ||
finally | ||
{ | ||
document.Layers.CurrentUserLayer.Opacity = savedOpacity; | ||
document.Layers.CurrentUserLayer.BlendMode = savedBlendMode; | ||
} | ||
|
||
var surf = document.Layers.CurrentUserLayer.Surface; | ||
|
||
|