fasdfsa commited on
Commit
f76c291
·
1 Parent(s): f4ae1c5

显示大图

Browse files
src/WeChatOcrCpp/WeChatOcrCpp.vcxproj CHANGED
@@ -46,7 +46,7 @@
46
  <CharacterSet>Unicode</CharacterSet>
47
  </PropertyGroup>
48
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
49
- <ConfigurationType>Application</ConfigurationType>
50
  <UseDebugLibraries>false</UseDebugLibraries>
51
  <PlatformToolset>v143</PlatformToolset>
52
  <WholeProgramOptimization>true</WholeProgramOptimization>
 
46
  <CharacterSet>Unicode</CharacterSet>
47
  </PropertyGroup>
48
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
49
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
50
  <UseDebugLibraries>false</UseDebugLibraries>
51
  <PlatformToolset>v143</PlatformToolset>
52
  <WholeProgramOptimization>true</WholeProgramOptimization>
src/WeChatOcrCpp/main.cpp CHANGED
@@ -115,7 +115,7 @@ void StartHttpServer(int port) {
115
  res.status = 500;
116
  res.set_content("{\"error\":\"服务器内部错误: " + std::string(e.what()) + "\"}", "application/json");
117
  }
118
- });
119
 
120
  // 添加一个简单的GET接口,用于测试服务器是否正常运行
121
  svr.Get("/", [](const httplib::Request&, httplib::Response& res) {
 
115
  res.status = 500;
116
  res.set_content("{\"error\":\"服务器内部错误: " + std::string(e.what()) + "\"}", "application/json");
117
  }
118
+ });
119
 
120
  // 添加一个简单的GET接口,用于测试服务器是否正常运行
121
  svr.Get("/", [](const httplib::Request&, httplib::Response& res) {
src/WpfEditor/TextEditorControl.cs CHANGED
@@ -48,10 +48,13 @@ namespace WpfEditor
48
  );
49
  }
50
 
51
- public void ShowDraggableImageControl(Mat image)
52
- {
 
 
53
  // 将Mat转换为BitmapSource
54
  BitmapSource bitmapSource = MatToBitmapSource(image); // OpenCvSharp.Extensions.BitmapSourceConverter.ToBitmapSource(image);
 
55
 
56
  // 如果窗口已存在,则更新图片内容
57
  if (_imageWindow != null) // && _imageWindow.IsLoaded
@@ -67,6 +70,8 @@ namespace WpfEditor
67
 
68
  // 根据新图片调整窗口大小
69
  AdjustWindowSizeBasedOnImage(_imageWindow, bitmapSource.PixelWidth, bitmapSource.PixelHeight);
 
 
70
  }
71
  return;
72
  }
@@ -164,18 +169,27 @@ namespace WpfEditor
164
  border.ContextMenu = contextMenu;
165
 
166
  // 显示窗口
167
- _imageWindow.Show();
168
-
169
- // 根据图片大小调整窗口尺寸
170
  AdjustWindowSizeBasedOnImage(_imageWindow, bitmapSource.PixelWidth, bitmapSource.PixelHeight);
171
 
172
  // 设置初始位置(居中显示)
173
- var mainWindow = Window.GetWindow(this);
174
  if (mainWindow != null)
175
  {
176
  _imageWindow.Left = 0; // mainWindow.Left + (mainWindow.Width - _imageWindow.ActualWidth) / 2;
177
  _imageWindow.Top = mainWindow.Top + (mainWindow.Height - _imageWindow.ActualHeight) / 2;
178
  }
 
 
 
 
 
 
 
 
 
 
179
  }
180
 
181
  // 根据图片大小调整窗口尺寸的辅助方法
@@ -528,7 +542,7 @@ namespace WpfEditor
528
  Mat cut = im_orig.Clone(new OpenCvSharp.Rect(0, line_y, im_orig.Width, line_height));
529
 
530
  // 显示图片预览窗口
531
- ShowDraggableImageControl(cut);
532
 
533
  found = true;
534
  break;
 
48
  );
49
  }
50
 
51
+ public void ShowDraggableImageControl(Mat image, Mat image_orig)
52
+ {
53
+ var mainWindow = Window.GetWindow(this) as MainWindow;
54
+
55
  // 将Mat转换为BitmapSource
56
  BitmapSource bitmapSource = MatToBitmapSource(image); // OpenCvSharp.Extensions.BitmapSourceConverter.ToBitmapSource(image);
57
+ BitmapSource bitmapSource2 = MatToBitmapSource(image_orig);
58
 
59
  // 如果窗口已存在,则更新图片内容
60
  if (_imageWindow != null) // && _imageWindow.IsLoaded
 
70
 
71
  // 根据新图片调整窗口大小
72
  AdjustWindowSizeBasedOnImage(_imageWindow, bitmapSource.PixelWidth, bitmapSource.PixelHeight);
73
+
74
+ mainWindow?.ShowImageInPanel(bitmapSource2);
75
  }
76
  return;
77
  }
 
169
  border.ContextMenu = contextMenu;
170
 
171
  // 显示窗口
172
+ _imageWindow.Show(); // 单行文本图
173
+
174
+ // 根据图片大小调整窗口尺寸
175
  AdjustWindowSizeBasedOnImage(_imageWindow, bitmapSource.PixelWidth, bitmapSource.PixelHeight);
176
 
177
  // 设置初始位置(居中显示)
 
178
  if (mainWindow != null)
179
  {
180
  _imageWindow.Left = 0; // mainWindow.Left + (mainWindow.Width - _imageWindow.ActualWidth) / 2;
181
  _imageWindow.Top = mainWindow.Top + (mainWindow.Height - _imageWindow.ActualHeight) / 2;
182
  }
183
+
184
+ if (mainWindow != null)
185
+ {
186
+ if (true || mainWindow.ImageViewer.Source == null)
187
+ {
188
+ mainWindow.ShowImageInPanel(bitmapSource2); // 全图
189
+ }
190
+ }
191
+
192
+
193
  }
194
 
195
  // 根据图片大小调整窗口尺寸的辅助方法
 
542
  Mat cut = im_orig.Clone(new OpenCvSharp.Rect(0, line_y, im_orig.Width, line_height));
543
 
544
  // 显示图片预览窗口
545
+ ShowDraggableImageControl(cut, im_orig);
546
 
547
  found = true;
548
  break;