mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
enhance: new image blend algorithm
This commit is contained in:
parent
2a85f26754
commit
73e450c684
1 changed files with 19 additions and 11 deletions
|
@ -239,19 +239,27 @@ namespace SourceGit.Views
|
||||||
var rect = new Rect(0, 0, Bounds.Width, Bounds.Height);
|
var rect = new Rect(0, 0, Bounds.Width, Bounds.Height);
|
||||||
var alpha = Alpha;
|
var alpha = Alpha;
|
||||||
var left = OldImage;
|
var left = OldImage;
|
||||||
if (left != null && alpha < 1)
|
|
||||||
{
|
|
||||||
var state = context.PushOpacity(1- alpha);
|
|
||||||
context.DrawImage(left, rect);
|
|
||||||
state.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
var right = NewImage;
|
var right = NewImage;
|
||||||
if (right != null && alpha > 0)
|
|
||||||
|
var drawLeft = left != null && alpha < 1.0;
|
||||||
|
var drawRight = right != null && alpha > 0;
|
||||||
|
if (drawLeft)
|
||||||
{
|
{
|
||||||
var state = context.PushOpacity(alpha);
|
using (context.PushRenderOptions(new RenderOptions() { BitmapBlendingMode = BitmapBlendingMode.Source }))
|
||||||
context.DrawImage(right, rect);
|
using (context.PushOpacity(1 - alpha))
|
||||||
state.Dispose();
|
context.DrawImage(left, rect);
|
||||||
|
|
||||||
|
if (drawRight)
|
||||||
|
{
|
||||||
|
using (context.PushRenderOptions(new RenderOptions() { BitmapBlendingMode = BitmapBlendingMode.Plus }))
|
||||||
|
using (context.PushOpacity(alpha))
|
||||||
|
context.DrawImage(right, rect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (drawRight)
|
||||||
|
{
|
||||||
|
using (context.PushOpacity(alpha))
|
||||||
|
context.DrawImage(right, rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue