forked from andrewkirillov/AForge.NET
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathBitmapDataVisualizer.cs
47 lines (41 loc) · 1.46 KB
/
BitmapDataVisualizer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// AForge debugging visualizers
// AForge.NET framework
// http://www.aforgenet.com/framework/
//
// Copyright © AForge.NET, 2011
// contacts@aforgenet.com
//
using System;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
using System.Runtime.Serialization.Formatters.Binary;
using Microsoft.VisualStudio.DebuggerVisualizers;
[assembly: System.Diagnostics.DebuggerVisualizer(
typeof( AForge.DebuggerVisualizers.BitmapDataVisualizer ),
typeof( AForge.DebuggerVisualizers.BitmapDataObjectSource ),
Target = typeof( System.Drawing.Imaging.BitmapData ),
Description = "Bitmap Data Visualizer" )]
namespace AForge.DebuggerVisualizers
{
class BitmapDataVisualizer : DialogDebuggerVisualizer
{
override protected void Show( IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider )
{
Image image = (Image) objectProvider.GetObject( );
ImageView imageViewer = new ImageView( );
imageViewer.SetImage( image );
windowService.ShowDialog( imageViewer );
}
}
public class BitmapDataObjectSource : VisualizerObjectSource
{
public override void GetData( object target, Stream outgoingData )
{
BinaryFormatter bf = new BinaryFormatter( );
bf.Serialize( outgoingData,
( new AForge.Imaging.UnmanagedImage( (BitmapData) target ) ).ToManagedImage( ) );
}
}
}