From 74c4e7634dd57c39db762534e5af5ef0dfd7806b Mon Sep 17 00:00:00 2001 From: Chinesehou97 <202169359@qq.com> Date: Wed, 8 Jan 2025 17:39:59 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4Gap=E7=9A=84=E6=94=BE?= =?UTF-8?q?=E5=A4=A7=E6=A1=86=E9=97=B4=E9=9A=94=E4=BC=9A=E4=BD=BF=E6=94=BE?= =?UTF-8?q?=E5=A4=A7=E5=9B=BE=E5=83=8F=E8=B6=8A=E7=95=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- output.json | 90 ++-- src/mulimgviewer/configs/output.json | 46 ++ src/mulimgviewer/configs/output_s.json | 46 ++ src/mulimgviewer/gui/about_gui.fbp | 643 +++++++++++++------------ src/mulimgviewer/src/main.py | 16 +- src/mulimgviewer/src/utils_img.py | 42 +- 6 files changed, 495 insertions(+), 388 deletions(-) create mode 100644 src/mulimgviewer/configs/output.json create mode 100644 src/mulimgviewer/configs/output_s.json diff --git a/output.json b/output.json index 6cae587..90bd7c0 100644 --- a/output.json +++ b/output.json @@ -1,46 +1,46 @@ { - "row_col": "1,1", - "row_col_one_img": "1,1", - "show_scale": "1,1", - "row_col_img_unit": "3,1", - "gap": "10,10,5,5,3,3,2,2", - "magnifer_row_col": "1,1", - "output_scale": "1,1", - "img_resolution": "-1,-1", - "magnifer_resolution": "-1,-1", - "magnifier_show_scale": "-1,-1", - "line_width": "2,2", - "magnifier_out_scale": "1,1", - "title_font_size": "20", - "box_position": 0, - "choice_normalized_size": 0, - "choice_output": 0, - "image_interp": 2, - "Magnifier_format": 1, - "title_font": 0, - "parallel_sequential": false, - "parallel_to_sequential": false, - "auto_save_all": false, - "move_file": false, - "img_vertical": false, - "one_img_vertical": false, - "img_unit_vertical": false, - "magnifer_vertical": true, - "show_original": true, - "show_magnifer": true, - "title_show": true, - "auto_layout_check": false, - "one_img": false, - "onetitle": false, - "customfunc": false, - "show_box": true, - "show_box_in_crop": true, - "select_img_box": false, - "title_auto": true, - "title_exif": false, - "title_show_parent": false, - "title_show_prefix": true, - "title_show_name": true, - "title_show_suffix": false, - "title_down_up": false - } + "row_col": "1,2", + "row_col_one_img": "1,1", + "show_scale": "1,1", + "row_col_img_unit": "3,1", + "gap": "10,10,5,5,3,3,2,2", + "magnifer_row_col": "1,1", + "output_scale": "1,1", + "img_resolution": "-1,-1", + "magnifer_resolution": "-1,-1", + "magnifier_show_scale": "-1,-1", + "line_width": "2,2", + "magnifier_out_scale": "1,1", + "title_font_size": "20", + "box_position": 0, + "choice_normalized_size": 0, + "choice_output": 0, + "image_interp": 2, + "Magnifier_format": 1, + "title_font": 0, + "parallel_sequential": false, + "parallel_to_sequential": false, + "auto_save_all": false, + "move_file": false, + "img_vertical": false, + "one_img_vertical": false, + "img_unit_vertical": false, + "magnifer_vertical": true, + "show_original": true, + "show_magnifer": true, + "title_show": true, + "auto_layout_check": false, + "one_img": false, + "onetitle": false, + "customfunc": false, + "show_box": true, + "show_box_in_crop": true, + "select_img_box": false, + "title_auto": true, + "title_exif": false, + "title_show_parent": false, + "title_show_prefix": true, + "title_show_name": true, + "title_show_suffix": false, + "title_down_up": false +} \ No newline at end of file diff --git a/src/mulimgviewer/configs/output.json b/src/mulimgviewer/configs/output.json new file mode 100644 index 0000000..6cae587 --- /dev/null +++ b/src/mulimgviewer/configs/output.json @@ -0,0 +1,46 @@ +{ + "row_col": "1,1", + "row_col_one_img": "1,1", + "show_scale": "1,1", + "row_col_img_unit": "3,1", + "gap": "10,10,5,5,3,3,2,2", + "magnifer_row_col": "1,1", + "output_scale": "1,1", + "img_resolution": "-1,-1", + "magnifer_resolution": "-1,-1", + "magnifier_show_scale": "-1,-1", + "line_width": "2,2", + "magnifier_out_scale": "1,1", + "title_font_size": "20", + "box_position": 0, + "choice_normalized_size": 0, + "choice_output": 0, + "image_interp": 2, + "Magnifier_format": 1, + "title_font": 0, + "parallel_sequential": false, + "parallel_to_sequential": false, + "auto_save_all": false, + "move_file": false, + "img_vertical": false, + "one_img_vertical": false, + "img_unit_vertical": false, + "magnifer_vertical": true, + "show_original": true, + "show_magnifer": true, + "title_show": true, + "auto_layout_check": false, + "one_img": false, + "onetitle": false, + "customfunc": false, + "show_box": true, + "show_box_in_crop": true, + "select_img_box": false, + "title_auto": true, + "title_exif": false, + "title_show_parent": false, + "title_show_prefix": true, + "title_show_name": true, + "title_show_suffix": false, + "title_down_up": false + } diff --git a/src/mulimgviewer/configs/output_s.json b/src/mulimgviewer/configs/output_s.json new file mode 100644 index 0000000..6cae587 --- /dev/null +++ b/src/mulimgviewer/configs/output_s.json @@ -0,0 +1,46 @@ +{ + "row_col": "1,1", + "row_col_one_img": "1,1", + "show_scale": "1,1", + "row_col_img_unit": "3,1", + "gap": "10,10,5,5,3,3,2,2", + "magnifer_row_col": "1,1", + "output_scale": "1,1", + "img_resolution": "-1,-1", + "magnifer_resolution": "-1,-1", + "magnifier_show_scale": "-1,-1", + "line_width": "2,2", + "magnifier_out_scale": "1,1", + "title_font_size": "20", + "box_position": 0, + "choice_normalized_size": 0, + "choice_output": 0, + "image_interp": 2, + "Magnifier_format": 1, + "title_font": 0, + "parallel_sequential": false, + "parallel_to_sequential": false, + "auto_save_all": false, + "move_file": false, + "img_vertical": false, + "one_img_vertical": false, + "img_unit_vertical": false, + "magnifer_vertical": true, + "show_original": true, + "show_magnifer": true, + "title_show": true, + "auto_layout_check": false, + "one_img": false, + "onetitle": false, + "customfunc": false, + "show_box": true, + "show_box_in_crop": true, + "select_img_box": false, + "title_auto": true, + "title_exif": false, + "title_show_parent": false, + "title_show_prefix": true, + "title_show_name": true, + "title_show_suffix": false, + "title_down_up": false + } diff --git a/src/mulimgviewer/gui/about_gui.fbp b/src/mulimgviewer/gui/about_gui.fbp index 13348f1..fb114d7 100644 --- a/src/mulimgviewer/gui/about_gui.fbp +++ b/src/mulimgviewer/gui/about_gui.fbp @@ -1,339 +1,346 @@ - + - - - ; - Python - 1 - source_name - 0 - 0 - res - UTF-8 - connect - about_gui - 1000 - none - - - 0 - MyProject2 - - D:\ncfey\Desktop\github\MulimgViewer\src\mulimgviewer\gui - - 1 - 1 - 1 - 1 - UI - 0 - 0 - 0 - - 0 - wxAUI_MGR_DEFAULT + + + Python + ; + 1 + connect + none + + + 0 + 0 + res + UTF-8 + about_gui + 1000 + 0 + 1 + UI + MyProject2 + D:\ncfey\Desktop\github\MulimgViewer\src\mulimgviewer\gui + 0 + source_name + 1 + 0 + source_name + + + 1 + 1 + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 0 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + AboutGui + + 484,350 + wxDEFAULT_FRAME_STYLE + ; ; forward_declare + About + + 0 + + + wxTAB_TRAVERSAL + 1 + + 1 + wxBOTH + + + 0 + + fgSizer1 + wxFLEX_GROWMODE_SPECIFIED + none + 0 + 0 + + 5 + wxEXPAND | wxALL + 1 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + - wxBOTH + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left + 0 1 - impl_virtual - + 1 + 0 0 wxID_ANY + + 0 + + 0 - AboutGui + 1 + about_txt + 1 + + + protected + 1 - 490,350 - wxDEFAULT_FRAME_STYLE + Resizable + 1 + 490,250 + ; ; forward_declare - About + 0 - 0 + + wxFILTER_NONE + wxDefaultValidator + + - wxTAB_TRAVERSAL - 1 - - 1 - wxBOTH - - - 0 + wxVSCROLL|wxHSCROLL|wxNO_BORDER|wxWANTS_CHARS + + + + 5 + wxEXPAND + 1 + + wxWRAPSIZER_DEFAULT_FLAGS + -1,-1 + wSizer1 + wxHORIZONTAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + + wxID_ANY + Github + + 0 + + + 0 + + 1 + m_hyperlink1 + + 1 + + + protected + 1 + + Resizable + 1 + + wxHL_DEFAULT_STYLE + ; ; forward_declare + 0 + + https://github.com/nachifur/MulimgViewer + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + + wxID_ANY + License + + 0 + + + 0 + + 1 + m_hyperlink2 + + 1 + + + protected + 1 + + Resizable + 1 + + wxHL_DEFAULT_STYLE + ; ; forward_declare + 0 + + https://github.com/nachifur/MulimgViewer/blob/master/LICENSE + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + + wxID_ANY + Download + + 0 + + + 0 - fgSizer1 - wxFLEX_GROWMODE_SPECIFIED - none - 0 - 0 - - 5 - wxEXPAND | wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - about_txt - 1 - - - protected - 1 - - Resizable - 1 - 490,250 - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - wxVSCROLL|wxHSCROLL|wxNO_BORDER|wxWANTS_CHARS - - - - 5 - wxEXPAND - 1 - - wxWRAPSIZER_DEFAULT_FLAGS - -1,-1 - wSizer1 - wxHORIZONTAL - none - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - - wxID_ANY - Github - - 0 - - - 0 - - 1 - m_hyperlink1 - - 1 - - - protected - 1 - - Resizable - 1 - - wxHL_DEFAULT_STYLE - ; ; forward_declare - 0 - - https://github.com/nachifur/MulimgViewer - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - - wxID_ANY - License - - 0 - - - 0 - - 1 - m_hyperlink2 - - 1 - - - protected - 1 - - Resizable - 1 - - wxHL_DEFAULT_STYLE - ; ; forward_declare - 0 - - https://github.com/nachifur/MulimgViewer/blob/master/LICENSE - - - - - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - - wxID_ANY - Download - - 0 - - - 0 - - 1 - m_hyperlink3 - - 1 - - - protected - 1 - - Resizable - 1 - - wxHL_DEFAULT_STYLE - ; ; forward_declare - 0 - - https://github.com/nachifur/MulimgViewer/releases - - - - - - - - + 1 + m_hyperlink3 + + 1 + + + protected + 1 + + Resizable + 1 + + wxHL_DEFAULT_STYLE + ; ; forward_declare + 0 + + https://github.com/nachifur/MulimgViewer/releases + + + + + + + + diff --git a/src/mulimgviewer/src/main.py b/src/mulimgviewer/src/main.py index bf69678..e46a6bc 100644 --- a/src/mulimgviewer/src/main.py +++ b/src/mulimgviewer/src/main.py @@ -115,6 +115,8 @@ def __init__(self, parent, UpdateUI, get_type, default_path=None): except: pass + self.load_configuration( None , config_name="output.json") + def EVT_MY_TEST_OnHandle(self, event): self.about_gui(None, update=True, new_version=event.GetEventArgs()) @@ -1384,12 +1386,15 @@ def save_configuration(self, event): 'title_show_suffix': self.title_show_suffix.GetValue(), 'title_down_up': self.title_down_up.GetValue(), } - - with open('output.json', 'w') as file: + flip_cursor_path = Path(get_resource_path(str(Path("configs")))) + flip_cursor_path = str(flip_cursor_path / "output.json") + with open(flip_cursor_path, 'w') as file: json.dump(data, file, indent=1) def load_configuration(self, event, config_name="output.json"): - with open(config_name, 'r') as file: + flip_cursor_path = Path(get_resource_path(str(Path("configs")))) + flip_cursor_path = str(flip_cursor_path / config_name) + with open(flip_cursor_path, 'r') as file: data = json.load(file) self.row_col.SetValue(data['row_col']) self.row_col_one_img.SetValue(data['row_col_one_img']) @@ -1437,5 +1442,8 @@ def load_configuration(self, event, config_name="output.json"): self.title_down_up.SetValue(data['title_down_up']) def reset_configuration(self, event): + json_path = Path(get_resource_path(str(Path("configs")))) + output_json_path = str(json_path / "output.json") + output_s_json_path = str(json_path / "output_s.json") self.load_configuration(event, config_name="output_s.json") - shutil.copy("output_s.json", "output.json") + shutil.copy(output_s_json_path, output_json_path) diff --git a/src/mulimgviewer/src/utils_img.py b/src/mulimgviewer/src/utils_img.py index d14292e..c874907 100644 --- a/src/mulimgviewer/src/utils_img.py +++ b/src/mulimgviewer/src/utils_img.py @@ -172,34 +172,34 @@ def cal_magnifier_size(self, magnifier_scale, crop_size, img_mode, gap, img_size if (int(to_width) > int(img_width / magnifer_row_col[1])): to_height = int(int(to_height) / int(to_width) * int(img_width / magnifer_row_col[1])) to_width = int(img_width / magnifer_row_col[1]) - if (int(to_height) > int(img_height / magnifer_row_col[0])): + if (int(to_height * magnifer_row_col[0]+gap[1]*(magnifer_row_col[0]-1)) > int(img_height)): to_width = int(to_width / to_height * img_height / magnifer_row_col[0]) - to_height = int(img_height / magnifer_row_col[0]) + to_height = int((img_height-(magnifer_row_col[0]-1)*gap[1]) / magnifer_row_col[0]) else: - if (int(to_width) > int(img_width / magnifer_row_col[1])): + if (int(to_width * magnifer_row_col[1] + gap[0] * (magnifer_row_col[1] - 1)) > int(img_width)): to_height = int(int(to_height) / int(to_width) * int(img_width / magnifer_row_col[1])) - to_width = int(img_width / magnifer_row_col[1]) + to_width = int((img_width - (magnifer_row_col[1] - 1) * gap[0]) / magnifer_row_col[1]) elif magnifier_format == 2: if row_col_img_unit[1] == 1: if (to_height > int(int(img_height) / int(magnifer_row_col[0]))): to_width = int(int(to_width) / int(to_height) * int(int(img_height) / int(magnifer_row_col[0]))) to_height = int(int(img_height) / int(magnifer_row_col[0])) - if (int(to_width) > int(img_width / magnifer_row_col[1])): + if (int(to_width*magnifer_row_col[1] + gap[0]*(magnifer_row_col[1]-1)) > int(img_width)): to_height =int(int(to_height) / int(to_width) * int(img_width / magnifer_row_col[1])) - to_width = int(img_width / magnifer_row_col[1]) + to_width = int((img_width-(magnifer_row_col[1]-1)*gap[0]) / magnifer_row_col[1]) else : - if (to_height > int(int(img_height) / int(magnifer_row_col[0]))): + if (int(to_height * magnifer_row_col[0]+gap[1]*(magnifer_row_col[0]-1)) > int(img_height)): to_width = int(int(to_width) / int(to_height) * int(int(img_height) / int(magnifer_row_col[0]))) - to_height = int(int(img_height) / int(magnifer_row_col[0])) + to_height = int((img_height-(magnifer_row_col[0]-1)*gap[1]) / magnifer_row_col[0]) else: - if to_height > int(int(img_height) / int(magnifer_row_col[0])): + if (int(to_height * magnifer_row_col[0]+gap[1]*(magnifer_row_col[0]-1)) > int(img_height)): to_width = int(int(to_width) / int(to_height) * int(img_height/ int(magnifer_row_col[0]))) - to_height = int(img_height / int(magnifer_row_col[0])) - if to_width > int(int(img_width) / int(magnifer_row_col[1])): - to_height = int(int(to_height) / int(to_width) * int(img_width/ int(magnifer_row_col[1]))) - to_width = int(img_width / int(magnifer_row_col[1])) + to_height = int((img_height-(magnifer_row_col[0]-1)*gap[1]) / magnifer_row_col[0]) + if (int(to_width * magnifer_row_col[1] + gap[0] * (magnifer_row_col[1] - 1)) > int(img_width)): + to_height = int(int(to_height) / int(to_width) * int(img_width / magnifer_row_col[1])) + to_width = int((img_width - (magnifer_row_col[1] - 1) * gap[0]) / magnifer_row_col[1]) else: # auto magnifier scale width_all = width * \ @@ -216,18 +216,18 @@ def cal_magnifier_size(self, magnifier_scale, crop_size, img_mode, gap, img_size to_height = int(to_width / width * height) if magnifier_format == 1: to_height = int(int(to_height) / int(to_width) * int(img_width/magnifer_row_col[1])) - to_width = int(img_width/magnifer_row_col[1]) + to_width = int((img_width - (magnifer_row_col[1] - 1) * gap[0])/magnifer_row_col[1]) if row_col_img_unit[1] >= 2: - if(int(to_height) > int(img_height/magnifer_row_col[0])): - to_width = int(to_width/to_height*img_height/magnifer_row_col[0]) - to_height = int(img_height/magnifer_row_col[0]) + if (int(to_height * magnifer_row_col[0] + gap[1] * (magnifer_row_col[0] - 1)) > int(img_height)): + to_width = int(int(to_width) / int(to_height) * int(img_height / int(magnifer_row_col[0]))) + to_height = int((img_height - (magnifer_row_col[0] - 1) * gap[1]) / magnifer_row_col[0]) elif magnifier_format == 2: to_width = int(int(to_width) / int(to_height) * int(int(img_height)/int(magnifer_row_col[0]))) - to_height = int(int(img_height)/int(magnifer_row_col[0])) + to_height = int(int(img_height - (magnifer_row_col[0] - 1) * gap[1])/int(magnifer_row_col[0])) if row_col_img_unit[1] == 1: - if(int(to_width) > int(img_width/magnifer_row_col[1])): - to_height = int(to_height/to_width*img_width/magnifer_row_col[1]) - to_width = int(img_width/magnifer_row_col[1]) + if (int(to_width * magnifer_row_col[1] + gap[0] * (magnifer_row_col[1] - 1)) > int(img_width)): + to_height = int(int(to_height) / int(to_width) * int(img_width / magnifer_row_col[1])) + to_width = int((img_width - (magnifer_row_col[1] - 1) * gap[0]) / magnifer_row_col[1]) else : if (int(to_height) > int(img_height)): to_width = int(int(img_width) / int(to_height) * int(img_height))