markus / ImageComparer / ComparerTestWPF / MainWindow.xaml.cs @ b4a1c7ff
이력 | 보기 | 이력해설 | 다운로드 (5.06 KB)
1 | 6b6e937c | taeseongkim | 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 | 9f61d7b6 | taeseongkim | using (Markus.Image.ImageCompare imageCompare = new Markus.Image.ImageCompare()) |
63 | 6b6e937c | taeseongkim | { |
64 | var original = new System.Drawing.Bitmap(TxtOriginalImage.Text); |
||
65 | var target = new System.Drawing.Bitmap(TxtTargetImage.Text); |
||
66 | |||
67 | 9f61d7b6 | taeseongkim | var result = imageCompare.CompareDrawRects(original, target, new System.Drawing.Size(20, 20)); |
68 | 6b6e937c | taeseongkim | |
69 | 9f61d7b6 | taeseongkim | bitmapSource = imageCompare.CreateWriteableBitmapFromBitmap(result); |
70 | 6b6e937c | taeseongkim | |
71 | //var result2 = imageComparer.CompareDrawRects(target, original, new System.Drawing.Size(20, 20)); |
||
72 | //TargetSource = imageComparer.CreateBitmapSourceFromBitmap(result2); |
||
73 | //result2.Dispose(); |
||
74 | //result2 = null; |
||
75 | |||
76 | original.Dispose(); |
||
77 | target.Dispose(); |
||
78 | } |
||
79 | |||
80 | |||
81 | ImageView imageView = new ImageView(bitmapSource); |
||
82 | |||
83 | imageView.Show(); |
||
84 | |||
85 | |||
86 | //ImageView imageView2 = new ImageView(TargetSource); |
||
87 | |||
88 | //imageView2.Show(); |
||
89 | } |
||
90 | |||
91 | private async void btTask_Click(object sender, RoutedEventArgs e) |
||
92 | { |
||
93 | BitmapSource bitmapSource = null; |
||
94 | BitmapSource TargetSource = null; |
||
95 | |||
96 | 9f61d7b6 | taeseongkim | using (Markus.Image.ImageCompare imageComparer = new Markus.Image.ImageCompare()) |
97 | 6b6e937c | taeseongkim | { |
98 | |||
99 | var original = new System.Drawing.Bitmap(TxtOriginalImage.Text); |
||
100 | var target = new System.Drawing.Bitmap(TxtTargetImage.Text); |
||
101 | |||
102 | var result = await imageComparer.CompareReturnRectsAsync(original, target, new System.Drawing.Size(20, 20)); |
||
103 | // bitmapSource = imageComparer.CreateWriteableBitmapFromBitmap(result); |
||
104 | |||
105 | lstView.ItemsSource = result; |
||
106 | |||
107 | var original2 = new System.Drawing.Bitmap(TxtOriginalImage.Text); |
||
108 | var target2 = new System.Drawing.Bitmap(TxtTargetImage.Text); |
||
109 | |||
110 | |||
111 | var result2 = await imageComparer.CompareReturnRectsAsync(target2, original2, new System.Drawing.Size(20, 20)); |
||
112 | |||
113 | lstView2.ItemsSource = result2; |
||
114 | //TargetSource = imageComparer.CreateWriteableBitmapFromBitmap(result2); |
||
115 | |||
116 | original.Dispose(); |
||
117 | target.Dispose(); |
||
118 | } |
||
119 | |||
120 | |||
121 | //ImageView imageView = new ImageView(bitmapSource); |
||
122 | |||
123 | //imageView.Show(); |
||
124 | |||
125 | //ImageView imageView2 = new ImageView(TargetSource); |
||
126 | |||
127 | //imageView2.Show(); |
||
128 | } |
||
129 | |||
130 | private async void btTaskUri_Click(object sender, RoutedEventArgs e) |
||
131 | { |
||
132 | 66351e6d | taeseongkim | BitmapSource bitmapSource = null; |
133 | 6b6e937c | taeseongkim | |
134 | 9f61d7b6 | taeseongkim | using (Markus.Image.ImageCompare imageComparer = new Markus.Image.ImageCompare()) |
135 | 6b6e937c | taeseongkim | { |
136 | 66351e6d | taeseongkim | var result = await imageComparer.CompareDrawRectsAsync("http://10.11.252.3/TileSource/LPG_Tile/215/21544/9.png" |
137 | , "http://10.11.252.3/TileSource/LPG_Tile/211/21107/9.png", new System.Drawing.Size(20, 20)); |
||
138 | 6b6e937c | taeseongkim | |
139 | 66351e6d | taeseongkim | bitmapSource = result; |
140 | 6b6e937c | taeseongkim | |
141 | 66351e6d | taeseongkim | //lstView.ItemsSource = result; |
142 | 6b6e937c | taeseongkim | |
143 | 66351e6d | taeseongkim | //var result2 = await imageComparer.CompareReturnRectsAsync("http://192.168.0.67:5977/TileSource/000000_Tile/110001/11000101/1.png" |
144 | // , "http://192.168.0.67:5977/TileSource/000000_Tile/110001/11000102/1.png", new System.Drawing.Size(20, 20)); |
||
145 | |||
146 | //lstView2.ItemsSource = result2; |
||
147 | 6b6e937c | taeseongkim | //TargetSource = imageComparer.CreateWriteableBitmapFromBitmap(result2); |
148 | |||
149 | } |
||
150 | 66351e6d | taeseongkim | |
151 | ImageView imageView = new ImageView(bitmapSource); |
||
152 | |||
153 | imageView.Show(); |
||
154 | 6b6e937c | taeseongkim | } |
155 | } |
||
156 | } |