Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikachu2333 committed Aug 1, 2023
1 parent 9506d5a commit c43c5d0
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 56 deletions.
2 changes: 1 addition & 1 deletion default.aproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<project ver="10" name="RealesrganRimagePicImprove" libEmbed="true" icon="..." ui="win" output="RealesrganRimagePicImprove.exe" CompanyName="None" FileDescription="ImproveAnimePic" LegalCopyright="Copyright (C) MIKA 2023 MIT License" ProductName="AnimePicImprover" InternalName="RealesrganRimagePicImprove" FileVersion="1.0.0.03" ProductVersion="1.0.0.03" publishDir="/dist/" dstrip="true">
<project ver="10" name="RealesrganRimagePicImprove" libEmbed="true" icon="..." ui="win" output="RealesrganRimagePicImprove.exe" CompanyName="None" FileDescription="ImproveAnimePic" LegalCopyright="Copyright (C) MIKA 2023 MIT License" ProductName="AnimePicImprover" InternalName="RealesrganRimagePicImprove" FileVersion="1.0.1.06" ProductVersion="1.0.1.06" publishDir="/dist/" dstrip="true">
<file name="main.aardio" path="main.aardio" comment="main.aardio"/>
<folder name="资源文件" path="res" embed="true"/>
<folder name="窗体文件" path="dlg" comment="目录" embed="true"/>
Expand Down
112 changes: 57 additions & 55 deletions main.aardio
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import win.ui.tooltip
/*DSG{{*/
mainForm = win.form(cls="RIMG_GUI_FORM";text="RealesrganRimagePicImprove";right=587;bottom=346;border="thin";max=false)
mainForm.add(
auto_delete={cls="checkbox";text="自动删除";left=473;top=112;right=573;bottom=137;bgcolor=65535;checked=1;color=255;font=LOGFONT(h=-16;name='微软雅黑');z=10};
auto_delete={cls="checkbox";text="自动删除";left=473;top=112;right=573;bottom=137;bgcolor=65535;color=255;font=LOGFONT(h=-16;name='微软雅黑');z=10};
auto_improve={cls="checkbox";text="自动缩小";left=473;top=40;right=573;bottom=65;bgcolor=65535;checked=1;color=255;font=LOGFONT(h=-16;name='微软雅黑');z=13};
edit_o_d={cls="edit";left=156;top=317;right=454;bottom=342;autovscroll=false;edge=1;font=LOGFONT(h=-14;name='微软雅黑');readonly=1;z=9};
edit_o_q={cls="edit";text="90";left=504;top=182;right=541;bottom=207;align="center";edge=1;font=LOGFONT(h=-16;name='微软雅黑');multiline=1;num=1;z=6};
edit_o_q={cls="edit";text="90";left=499;top=182;right=545;bottom=207;align="center";edge=1;font=LOGFONT(h=-16;name='微软雅黑');multiline=1;num=1;z=6};
file_list={cls="listbox";left=8;top=35;right=454;bottom=282;edge=1;font=LOGFONT(h=-14;name='微软雅黑');hscroll=1;items={};vscroll=1;z=2};
out_format={cls="combobox";left=481;top=250;right=568;bottom=276;edge=1;font=LOGFONT(h=-16;name='微软雅黑');items={"jpg";"png";"oxipng"};mode="dropdown";z=8};
process_show={cls="edit";left=8;top=289;right=454;bottom=311;autovscroll=false;edge=1;font=LOGFONT(h=-14;name='微软雅黑');readonly=1;z=12};
Expand All @@ -22,13 +22,17 @@ static_out_quailty={cls="static";text="输出质量";left=473;top=154;right=573;
)
/*}}*/

if(not io.exist(io._exedir + "realesrgan_rimage\rimage.exe")){
if((not io.exist(io._exedir + "realesrgan_rimage\rimage.exe")) or (io.getSize(io._exedir + "realesrgan_rimage.7z") != 11701587)){
io.remove(io._exedir + "realesrgan_rimage.7z")
io.remove(io._exedir + "realesrgan_rimage\rimage.exe")
string.save(io._exedir + "realesrgan_rimage.7z",$"\res\realesrgan_rimage.7z",true)
var temp_7z = sevenZip.decoder2()
temp_7z.open(io._exedir + "realesrgan_rimage.7z")
temp_7z.extract(io._exedir)
temp_7z.close()
io.remove(io._exedir + "realesrgan_rimage.7z")
}

mainForm.process_show.text = "(双击清空)显示运行情况"
mainForm.file_list.add("双击左键添加,选中后使用右键删除")
mainForm.file_list.add("双击下方的(双击清空)以快速清空文件列表")
Expand All @@ -41,9 +45,17 @@ mainForm.process_show.wndproc = function(hwnd,message,wParam,lParam){
}
}

mainForm.edit_o_d.text = string.left(io._exedir,-2,true)
mainForm.edit_o_d.text = """" + string.left(io._exedir,-2,true) + """"

var count = null
mainForm.onDropFiles = function(files){
if(count == null){
mainForm.file_list.clear()
count = 0
}
for(k,v in files){mainForm.file_list.add(v)}
mainForm.edit_o_d.text = """" + string.left(io.splitpath(mainForm.file_list.getItemText(1)).dir,-2,true) + """"
}
mainForm.file_list.wndproc = function(hwnd,message,wParam,lParam){
select(message){
case 0x203/*_WM_LBUTTONDBLCLK*/{
Expand All @@ -54,6 +66,7 @@ mainForm.file_list.wndproc = function(hwnd,message,wParam,lParam){
var temp1,temp2 = fsys.dlg.openEx("图片 Picture|*.png;*.jpg;*.jpeg;*.webp","选择图片 Select IMGs",,mainForm.hwnd)
if(temp1 != null){
for(i,j in temp1){mainForm.file_list.add(j,1)}
mainForm.edit_o_d.text = """" + string.left(io.splitpath(mainForm.file_list.getItemText(1)).dir,-2,true) + """"
}else{
win.msgbox('请选择正确的图片\nPlease select Pics we support.',"Warning",,mainForm.hwnd,2000)
}
Expand All @@ -69,14 +82,11 @@ mainForm.edit_o_d.wndproc = function(hwnd,message,wParam,lParam){
case 0x203/*_WM_LBUTTONDBLCLK*/{
temp = fsys.dlg.openDir(,mainForm.hwnd,"请选择目录 Please select the Dir for output")
if(temp != null){
mainForm.edit_o_d.text = temp
mainForm.edit_o_d.text = """" + temp + """"
}else{
win.msgbox('请选择正确的目录\nPlease select right dir to save.',"Warning",,mainForm.hwnd,2000)
}
}
case 0x205/*_WM_RBUTTONUP*/{
win.msgbox(tips_table["edit_o_d"],"out dir")
}
}
}

Expand All @@ -85,64 +95,56 @@ mainForm.start_cov.oncommand = function(id,event){
win.msgbox('请选择正确的图片\nPlease select Pics we support before execute.',"Warning",,mainForm.hwnd,2000)
}else{
mainForm.process_show.text = "开始运行"
quality = mainForm.edit_o_q.text
format = mainForm.out_format.selText
if(mainForm.auto_delete.checked == true){auto_del = true}else{auto_del = false}
out_dir = string.slice(mainForm.edit_o_d.text,2,-2,true)
auto_hide = mainForm.show_hide.checked
auto_size = mainForm.auto_improve.checked
auto_del = mainForm.auto_delete.checked
for(count=1;mainForm.file_list.count;1){
var temp_filepath = io.splitpath(mainForm.file_list.getItemText(1))
var argvs = "-i """ + mainForm.file_list.getItemText(1) + """ -o """ + mainForm.edit_o_d.text + "\" + temp_filepath.name + "_out.png"" -n realesrgan-x4plus-anime"
mainForm.process_show.text = "RealModel开始 " + temp_filepath.name
if(mainForm.show_hide.checked){
process.executeWait(io._exedir + "\realesrgan_rimage\realesrgan-ncnn-vulkan.exe",argvs,,0/*_SW_HIDE*/)
mainForm.process_show.text = "RealModel完成 " + temp_filepath.name
if(mainForm.auto_improve.checked){
argvs = ""
argvs = """" + mainForm.edit_o_d.text + "\" + temp_filepath.name + "_out.png"""
argvs = argvs + " -q " + mainForm.edit_o_q.text
argvs = argvs + " -f " + mainForm.out_format.selText
argvs = argvs + " -t 4 -s _updated --quantization 50"
argvs = argvs + " -o """ + mainForm.edit_o_d.text + """"
mainForm.process_show.text = "Rimage开始 " + temp_filepath.name
process.executeWait("""" + io._exedir + "\realesrgan_rimage\rimage.exe""",argvs,,0/*_SW_HIDE*/)
mainForm.process_show.text = "Rimage完成 " + temp_filepath.name
}
}else {
process.executeWait(io._exedir + "\realesrgan_rimage\realesrgan-ncnn-vulkan.exe",argvs,,)
mainForm.process_show.text = "RealModel完成 " + temp_filepath.name
if(mainForm.auto_improve.checked){
argvs = ""
argvs = """" + mainForm.edit_o_d.text + "\" + temp_filepath.name + "_out.png"""
argvs = argvs + " -q " + mainForm.edit_o_q.text
argvs = argvs + " -f " + mainForm.out_format.selText
argvs = argvs + " -t 4 -s _updated --quantization 50"
argvs = argvs + " -o """ + mainForm.edit_o_d.text + """"
mainForm.process_show.text = "Rimage开始 " + temp_filepath.name
process.executeWait("""" + io._exedir + "\realesrgan_rimage\rimage.exe""",argvs,,)
mainForm.process_show.text = "Rimage完成 " + temp_filepath.name
var temp_filename = io.splitpath(mainForm.file_list.getItemText(1)).name
var argvs = "-i """ + mainForm.file_list.getItemText(1) + """ -o """ + out_dir + "\" + temp_filename + "_out.png"" -n realesrgan-x4plus-anime"
mainForm.process_show.text = "RealModel开始 " + mainForm.file_list.getItemText(1)
if(auto_hide){
process.executeWait(io._exedir + "realesrgan_rimage\realesrgan-ncnn-vulkan.exe",argvs,,0/*_SW_HIDE*/)
}else{
process.executeWait(io._exedir + "realesrgan_rimage\realesrgan-ncnn-vulkan.exe",argvs,,)
}
mainForm.process_show.text = "RealModel完成 " + temp_filename

if(auto_size){
argvs = """" + out_dir + "\" + temp_filename + "_out.png"""
argvs = argvs + " -q " + quality
argvs = argvs + " --quantization 100"
argvs = argvs + " -f " + format
argvs = argvs + " -s _updated"
argvs = argvs + " -o " + out_dir
mainForm.process_show.text = "Rimage开始 " + temp_filename
if(auto_hide){
process.executeWait("""" + io._exedir + "realesrgan_rimage\rimage.exe""",argvs,,0/*_SW_HIDE*/)
}else{
process.executeWait("""" + io._exedir + "realesrgan_rimage\rimage.exe""",argvs,,)
}

mainForm.process_show.text = "Rimage完成 "
}
if(mainForm.auto_delete.checked){
if(mainForm.auto_improve.checked){
io.remove("\\?\" + mainForm.edit_o_d.text + "\" + temp_filepath.name + "_out.png")
mainForm.process_show.text = "RealModel删除 " + temp_filepath.name

if(auto_del){
if(auto_size){
io.remove(out_dir + "\" + temp_filename + "_out.png")
mainForm.process_show.text = "RealModel删除 " + temp_filename
}
io.remove("\\?\" + mainForm.file_list.getItemText(1))
mainForm.process_show.text = "原始删除 " + temp_filepath.name
io.remove(mainForm.file_list.getItemText(1))
mainForm.process_show.text = "原始删除 " + temp_filename
}
mainForm.file_list.delete(1)
mainForm.process_show.text = "删除 " + temp_filepath.name
mainForm.process_show.text = "删除 " + temp_filename
}
win.msgbox("完毕!","成功",,mainForm.hwnd)
mainForm.process_show.text = "(双击清空)显示运行情况"
}
}

mainForm.onDropFiles = function(files){
if(count == null){
mainForm.file_list.clear()
count = 0
}
for(k,v in files){
mainForm.file_list.add(v)
}
}

mainForm.show()
return win.loopMessage()

0 comments on commit c43c5d0

Please sign in to comment.