12
12
from .index_table import IndexTable
13
13
from .utils import MyTestEvent , get_resource_path
14
14
from .utils_img import ImgManager
15
+ import os
15
16
16
17
17
18
class MulimgViewer (MulimgViewerGui ):
@@ -211,9 +212,9 @@ def slider_value_change(self, event):
211
212
self .SetStatusText_ (["Skip" , "-1" , "-1" , "-1" ])
212
213
213
214
def save_img (self , event ):
214
- layout_params = self .set_img_layout ()
215
- if layout_params != False :
216
- self .ImgManager .layout_params = layout_params
215
+ # layout_params = self.set_img_layout()
216
+ # if layout_params != False:
217
+ # self.ImgManager.layout_params = layout_params
217
218
type_ = self .choice_output .GetSelection ()
218
219
if self .auto_save_all .Value :
219
220
last_count_img = self .ImgManager .action_count
@@ -244,7 +245,6 @@ def save_img(self, event):
244
245
except :
245
246
pass
246
247
flag = self .ImgManager .save_img (self .out_path_str , type_ )
247
- self .refresh (event )
248
248
if flag == 0 :
249
249
self .SetStatusText_ (
250
250
["Save" , str (self .ImgManager .action_count ), "Save success!" , "-1" ])
@@ -263,6 +263,9 @@ def save_img(self, event):
263
263
elif flag == 4 :
264
264
self .SetStatusText_ (
265
265
["-1" , str (self .ImgManager .action_count ), "***Error: No magnification box, the magnified image can not be saved***" , "-1" ])
266
+ elif flag == 5 :
267
+ self .SetStatusText_ (
268
+ ["-1" , str (self .ImgManager .action_count ), "***Error: First, need to select the input dir***" , "-1" ])
266
269
self .SetStatusText_ (["Save" , "-1" , "-1" , "-1" ])
267
270
268
271
def refresh (self , event ):
@@ -616,7 +619,7 @@ def img_left_move(self, event):
616
619
x , y = event .GetPosition ()
617
620
id = self .get_img_id_from_point ([x , y ])
618
621
xy_grid = self .ImgManager .xy_grid [id ]
619
- RGBA = self .ImgManager . img .getpixel ((int (x ), int (y )))
622
+ RGBA = self .show_bmp_in_panel .getpixel ((int (x ), int (y )))
620
623
x = x - xy_grid [0 ]
621
624
y = y - xy_grid [1 ]
622
625
self .m_statusBar1 .SetStatusText (str (x )+ "," + str (y )+ "/" + str (RGBA ), 0 )
@@ -911,10 +914,12 @@ def set_img_layout(self):
911
914
0 ).split (',' )
912
915
magnifer_resolution = [int (x ) for x in magnifer_resolution ]
913
916
914
- magnifier_show_scale = self .magnifier_show_scale .GetLineText (0 ).split (',' )
917
+ magnifier_show_scale = self .magnifier_show_scale .GetLineText (
918
+ 0 ).split (',' )
915
919
magnifier_show_scale = [float (x ) for x in magnifier_show_scale ]
916
920
917
- magnifier_out_scale = self .magnifier_out_scale .GetLineText (0 ).split (',' )
921
+ magnifier_out_scale = self .magnifier_out_scale .GetLineText (
922
+ 0 ).split (',' )
918
923
magnifier_out_scale = [float (x ) for x in magnifier_out_scale ]
919
924
920
925
if self .checkBox_auto_draw_color .Value :
@@ -987,7 +992,7 @@ def set_img_layout(self):
987
992
output_scale , # 5
988
993
img_resolution , # 6
989
994
1 if self .magnifier .Value else 0 , # 7
990
- magnifier_show_scale , # 8
995
+ magnifier_show_scale , # 8
991
996
color , # 9
992
997
line_width , # 10
993
998
self .move_file .Value , # 11
@@ -1010,9 +1015,14 @@ def set_img_layout(self):
1010
1015
magnifer_resolution , # 28
1011
1016
magnifer_row_col , # 29
1012
1017
self .onetitle .Value , # 30
1013
- magnifier_out_scale ] # 31
1018
+ magnifier_out_scale , # 31
1019
+ self .customfunc .Value , # 32
1020
+ self .out_path_str ] # 33
1014
1021
1015
1022
def show_img (self ):
1023
+ if self .customfunc .Value and self .out_path_str == "" :
1024
+ self .out_path (None )
1025
+ self .ImgManager .layout_params [33 ] = self .out_path_str
1016
1026
# check layout_params change
1017
1027
try :
1018
1028
if self .layout_params_old [0 :2 ] != self .ImgManager .layout_params [0 :2 ] or (self .layout_params_old [19 ] != self .ImgManager .layout_params [19 ]):
@@ -1048,10 +1058,19 @@ def show_img(self):
1048
1058
self .slider_img .SetMax (self .ImgManager .max_action_num - 1 )
1049
1059
self .ImgManager .get_flist ()
1050
1060
1061
+ # show the output image processed by the custom func; return cat(bmp, processed_bmp)
1062
+ if self .customfunc .Value :
1063
+ bmp_processed = self .process_by_custom_func ()
1064
+ else :
1065
+ bmp_processed = None
1066
+
1051
1067
flag = self .ImgManager .stitch_images (
1052
1068
0 , copy .deepcopy (self .xy_magnifier ))
1053
1069
if flag == 0 :
1054
1070
bmp = self .ImgManager .img
1071
+ if self .customfunc .Value and bmp_processed != None :
1072
+ bmp = self .ImgManager .ImgF .cat_img (bmp , bmp_processed )
1073
+ self .show_bmp_in_panel = bmp
1055
1074
self .img_size = bmp .size
1056
1075
bmp = self .ImgManager .ImgF .PIL2wx (bmp )
1057
1076
@@ -1097,7 +1116,7 @@ def show_img(self):
1097
1116
["-1" , "-1" , "No image is displayed! Check Show original/Show 🔍️/Show title." , "-1" ])
1098
1117
else :
1099
1118
self .SetStatusText_ (
1100
- ["-1" , "-1" , "***Error: no image in this dir! Maybe you can choose parallel mode! ***" , "-1" ])
1119
+ ["-1" , "-1" , "***Error: no image in this dir!***" , "-1" ])
1101
1120
self .auto_layout ()
1102
1121
self .SetStatusText_ (["Stitch" , "-1" , "-1" , "-1" ])
1103
1122
@@ -1168,6 +1187,16 @@ def init_min_size(self):
1168
1187
self .scrolledWindow_img .SetMinSize (
1169
1188
wx .Size ((50 , self .Size [1 ]- 150 )))
1170
1189
1190
+ def process_by_custom_func (self ):
1191
+ flag = self .ImgManager .stitch_images (
1192
+ 0 , copy .deepcopy (self .xy_magnifier ))
1193
+ bmp_processed = self .ImgManager .img
1194
+ self .ImgManager .layout_params [32 ] = False # customfunc
1195
+ if flag == 0 :
1196
+ return bmp_processed
1197
+ else :
1198
+ return None
1199
+
1171
1200
def split_sash_pos_changing (self , event ):
1172
1201
1173
1202
self .init_min_size ()
@@ -1263,13 +1292,6 @@ def title_auto_fc(self, event):
1263
1292
for title in titles :
1264
1293
title .Enabled = True
1265
1294
1266
- # def show_scale_change(self, event):
1267
- # self.show_scale_proportion = 0
1268
- # self.refresh(event)
1269
-
1270
- # self.show_scale = wx.TextCtrl( self.scrolledWindow_set, wx.ID_ANY, u"1,1", wx.DefaultPosition, wx.Size( 60,-1 ), style=wx.TE_PROCESS_ENTER)
1271
- # wSizer6.Add( self.show_scale, 0, wx.ALL, 5 )
1272
-
1273
1295
def select_img_box_func (self , event ):
1274
1296
if self .select_img_box .Value :
1275
1297
self .box_id = - 1
0 commit comments