Skip to content

Commit

Permalink
Project DebugVisualizers cleanup (#1534)
Browse files Browse the repository at this point in the history
Co-authored-by: Ioannis Kaliakatsos <[email protected]>
  • Loading branch information
jkalias and Ioannis Kaliakatsos authored Feb 28, 2023
1 parent 02e6600 commit 0498156
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 37 deletions.
21 changes: 6 additions & 15 deletions src/OpenCvSharp.DebuggerVisualizers/ImageViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,15 @@

namespace OpenCvSharp.DebuggerVisualizers
{
/// <summary>
///
/// </summary>
public partial class ImageViewer : Form
{
private readonly Bitmap bitmap;

/// <summary>
///
/// </summary>
public ImageViewer()
{
InitializeComponent();
}

/// <summary>
///
/// </summary>
/// <param name="proxy"></param>
public ImageViewer(MatProxy proxy)
: this()
{
Expand All @@ -42,10 +32,11 @@ public ImageViewer(string imgFile)
bitmap = new Bitmap(imgFile);
}

/// <summary>
///
/// </summary>
/// <param name="e"></param>
private void DisposeBitmap()
{
bitmap?.Dispose();
}

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Expand Down Expand Up @@ -86,7 +77,7 @@ private double ReformRatio(double ratio)

private void DisplayRatio(double ratio)
{
this.Text = $"ImageViewer Zoom: {ratio:P1}";
Text = $@"ImageViewer Zoom: {ratio:P1}";
}
}
}
5 changes: 3 additions & 2 deletions src/OpenCvSharp.DebuggerVisualizers/ImageViewer.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 10 additions & 11 deletions src/OpenCvSharp.DebuggerVisualizers/MatDebuggerVisualizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@ public class MatDebuggerVisualizer : DialogDebuggerVisualizer
protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
{
// MatProxyが送られてくるはず
using (var proxy = objectProvider.GetObject() as MatProxy)
var proxy = objectProvider.GetObject() as MatProxy;
if (proxy is null)
{
if (proxy is null)
{
throw new ArgumentException();
}
// Formに表示
using (var form = new ImageViewer(proxy))
{
windowService.ShowDialog(form);
}
}
throw new ArgumentException();
}

// Formに表示
using (var form = new ImageViewer(proxy))
{
windowService.ShowDialog(form);
}
}
}
}
2 changes: 1 addition & 1 deletion src/OpenCvSharp.DebuggerVisualizers/MatObjectSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ public override void GetData(object target, Stream outgoingData)
bf.Serialize(outgoingData, new MatProxy((Mat)target));
}
}
}
}
11 changes: 3 additions & 8 deletions src/OpenCvSharp.DebuggerVisualizers/MatProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@ namespace OpenCvSharp.DebuggerVisualizers
/// 送る際に、このProxyに表示に必要なシリアライズ可能なデータを詰めて送り、受信側で復元する。
/// </summary>
[Serializable]
public class MatProxy : IDisposable
public class MatProxy
{
public byte[] ImageData { get; private set; }

public MatProxy(Mat image)
{
ImageData = image.ToBytes(".png");
}

public void Dispose()
{
ImageData = null;
ImageData = image.ToBytes();
}

public Bitmap CreateBitmap()
Expand All @@ -34,4 +29,4 @@ public Bitmap CreateBitmap()
}
}
}
}
}

0 comments on commit 0498156

Please sign in to comment.