forked from amkovkov/GranuSightSoftware2
fix: OpenCvImage render clipping
This commit is contained in:
@@ -258,6 +258,8 @@ public class OpenCvImage : Control
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void Render(DrawingContext context)
|
public override void Render(DrawingContext context)
|
||||||
|
{
|
||||||
|
using (context.PushClip(new Rect(Bounds.Size)))
|
||||||
{
|
{
|
||||||
context.FillRectangle(new SolidColorBrush(Background), new Rect(0, 0, Bounds.Width, Bounds.Height));
|
context.FillRectangle(new SolidColorBrush(Background), new Rect(0, 0, Bounds.Width, Bounds.Height));
|
||||||
if (_bitmap is null)
|
if (_bitmap is null)
|
||||||
@@ -272,11 +274,16 @@ public class OpenCvImage : Control
|
|||||||
|
|
||||||
var drawWidth = _bitmap.PixelSize.Width * sx;
|
var drawWidth = _bitmap.PixelSize.Width * sx;
|
||||||
var drawHeight = _bitmap.PixelSize.Height * sy;
|
var drawHeight = _bitmap.PixelSize.Height * sy;
|
||||||
var destRect = new Rect((Bounds.Width - drawWidth) / 2 + _panX, (Bounds.Height - drawHeight) / 2 + _panY, drawWidth, drawHeight);
|
var destRect = new Rect(
|
||||||
|
(Bounds.Width - drawWidth) / 2 + _panX,
|
||||||
|
(Bounds.Height - drawHeight) / 2 + _panY,
|
||||||
|
drawWidth, drawHeight
|
||||||
|
);
|
||||||
|
|
||||||
var srcRect = ComputeSourceRect(TileMode, _bitmap.PixelSize.Width, _bitmap.PixelSize.Height);
|
var srcRect = ComputeSourceRect(TileMode, _bitmap.PixelSize.Width, _bitmap.PixelSize.Height);
|
||||||
|
|
||||||
context.DrawImage(_bitmap, srcRect, destRect);
|
context.DrawImage(_bitmap, srcRect, destRect);
|
||||||
|
}
|
||||||
|
|
||||||
base.Render(context);
|
base.Render(context);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user