markus / ImageComparer / ComparerTestWPF / MainWindow.xaml.cs @ 0cda2a88
이력 | 보기 | 이력해설 | 다운로드 (5.01 KB)
1 |
using Microsoft.Win32; |
---|---|
2 |
using System; |
3 |
using System.Collections.Generic; |
4 |
using System.Linq; |
5 |
using System.Text; |
6 |
using System.Threading.Tasks; |
7 |
using System.Windows; |
8 |
using System.Windows.Controls; |
9 |
using System.Windows.Data; |
10 |
using System.Windows.Documents; |
11 |
using System.Windows.Input; |
12 |
using System.Windows.Media; |
13 |
using System.Windows.Media.Imaging; |
14 |
using System.Windows.Navigation; |
15 |
using System.Windows.Shapes; |
16 |
|
17 |
namespace ComparerTestWPF |
18 |
{ |
19 |
/// <summary> |
20 |
/// MainWindow.xaml에 대한 상호 작용 논리 |
21 |
/// </summary> |
22 |
public partial class MainWindow : Window |
23 |
{ |
24 |
public MainWindow() |
25 |
{ |
26 |
InitializeComponent(); |
27 |
} |
28 |
|
29 |
|
30 |
private void btFindOriginalFile_click(object sender, RoutedEventArgs e) |
31 |
{ |
32 |
TxtOriginalImage.Text = FileOpen(); |
33 |
} |
34 |
|
35 |
private void btFindTargetFile_click(object sender, RoutedEventArgs e) |
36 |
{ |
37 |
TxtTargetImage.Text = FileOpen(); |
38 |
} |
39 |
|
40 |
private string FileOpen() |
41 |
{ |
42 |
string result = null; |
43 |
|
44 |
OpenFileDialog openFileDialog = new OpenFileDialog(); |
45 |
|
46 |
openFileDialog.Filter = "Image Files|*.png;*.jpg;*.bmp"; |
47 |
|
48 |
if (openFileDialog.ShowDialog() == true) |
49 |
result = openFileDialog.FileName; |
50 |
else |
51 |
result = null; |
52 |
|
53 |
return result; |
54 |
} |
55 |
|
56 |
|
57 |
private void btNoneTask_Click(object sender, RoutedEventArgs e) |
58 |
{ |
59 |
BitmapSource bitmapSource = null; |
60 |
BitmapSource TargetSource = null; |
61 |
|
62 |
using (Markus.Image.ImageComparer imageComparer = new Markus.Image.ImageComparer()) |
63 |
{ |
64 |
|
65 |
var original = new System.Drawing.Bitmap(TxtOriginalImage.Text); |
66 |
var target = new System.Drawing.Bitmap(TxtTargetImage.Text); |
67 |
|
68 |
var result = imageComparer.CompareDrawRects(original, target, new System.Drawing.Size(20, 20)); |
69 |
|
70 |
bitmapSource = imageComparer.CreateWriteableBitmapFromBitmap(result); |
71 |
|
72 |
//var result2 = imageComparer.CompareDrawRects(target, original, new System.Drawing.Size(20, 20)); |
73 |
//TargetSource = imageComparer.CreateBitmapSourceFromBitmap(result2); |
74 |
//result2.Dispose(); |
75 |
//result2 = null; |
76 |
|
77 |
original.Dispose(); |
78 |
target.Dispose(); |
79 |
} |
80 |
|
81 |
|
82 |
ImageView imageView = new ImageView(bitmapSource); |
83 |
|
84 |
imageView.Show(); |
85 |
|
86 |
|
87 |
//ImageView imageView2 = new ImageView(TargetSource); |
88 |
|
89 |
//imageView2.Show(); |
90 |
} |
91 |
|
92 |
private async void btTask_Click(object sender, RoutedEventArgs e) |
93 |
{ |
94 |
BitmapSource bitmapSource = null; |
95 |
BitmapSource TargetSource = null; |
96 |
|
97 |
using (Markus.Image.ImageComparer imageComparer = new Markus.Image.ImageComparer()) |
98 |
{ |
99 |
|
100 |
var original = new System.Drawing.Bitmap(TxtOriginalImage.Text); |
101 |
var target = new System.Drawing.Bitmap(TxtTargetImage.Text); |
102 |
|
103 |
var result = await imageComparer.CompareReturnRectsAsync(original, target, new System.Drawing.Size(20, 20)); |
104 |
// bitmapSource = imageComparer.CreateWriteableBitmapFromBitmap(result); |
105 |
|
106 |
lstView.ItemsSource = result; |
107 |
|
108 |
var original2 = new System.Drawing.Bitmap(TxtOriginalImage.Text); |
109 |
var target2 = new System.Drawing.Bitmap(TxtTargetImage.Text); |
110 |
|
111 |
|
112 |
var result2 = await imageComparer.CompareReturnRectsAsync(target2, original2, new System.Drawing.Size(20, 20)); |
113 |
|
114 |
lstView2.ItemsSource = result2; |
115 |
//TargetSource = imageComparer.CreateWriteableBitmapFromBitmap(result2); |
116 |
|
117 |
original.Dispose(); |
118 |
target.Dispose(); |
119 |
} |
120 |
|
121 |
|
122 |
//ImageView imageView = new ImageView(bitmapSource); |
123 |
|
124 |
//imageView.Show(); |
125 |
|
126 |
//ImageView imageView2 = new ImageView(TargetSource); |
127 |
|
128 |
//imageView2.Show(); |
129 |
} |
130 |
|
131 |
private async void btTaskUri_Click(object sender, RoutedEventArgs e) |
132 |
{ |
133 |
|
134 |
using (Markus.Image.ImageComparer imageComparer = new Markus.Image.ImageComparer()) |
135 |
{ |
136 |
var result = await imageComparer.CompareReturnRectsAsync("http://192.168.0.67:5977/TileSource/000000_Tile/110001/11000102/1.png" |
137 |
, "http://192.168.0.67:5977/TileSource/000000_Tile/110001/11000101/1.png", new System.Drawing.Size(20, 20)); |
138 |
// bitmapSource = imageComparer.CreateWriteableBitmapFromBitmap(result); |
139 |
|
140 |
lstView.ItemsSource = result; |
141 |
|
142 |
var result2 = await imageComparer.CompareReturnRectsAsync("http://192.168.0.67:5977/TileSource/000000_Tile/110001/11000101/1.png" |
143 |
, "http://192.168.0.67:5977/TileSource/000000_Tile/110001/11000102/1.png", new System.Drawing.Size(20, 20)); |
144 |
|
145 |
lstView2.ItemsSource = result2; |
146 |
//TargetSource = imageComparer.CreateWriteableBitmapFromBitmap(result2); |
147 |
|
148 |
} |
149 |
} |
150 |
} |
151 |
} |