-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.aardio
168 lines (156 loc) · 6.53 KB
/
main.aardio
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
import fsys.dlg
import process
import process.popen
import sevenZip.decoder2
import win.ui
/*DSG{{*/
mainForm = win.form(cls="RIMG_GUI_FORM";text="RealesrganPicImprove";right=587;bottom=412;border="thin";max=false)
mainForm.add(
auto_del={cls="checkbox";text="删除原图";left=486;top=61;right=580;bottom=86;bgcolor=65535;color=255;font=LOGFONT(h=-16;name='微软雅黑');z=8};
edit_o_d={cls="edit";left=158;top=381;right=580;bottom=406;autovscroll=false;clip=1;edge=1;font=LOGFONT(h=-14;name='微软雅黑');readonly=1;z=12};
file_list={cls="listbox";left=8;top=35;right=479;bottom=329;edge=1;font=LOGFONT(h=-14;name='微软雅黑');hscroll=1;items={};vscroll=1;z=3};
out_format={cls="combobox";left=496;top=211;right=571;bottom=236;edge=1;font=LOGFONT(h=-16;name='微软雅黑');items={"png";"jpg"};mode="dropdown";z=7};
process_show={cls="edit";left=8;top=327;right=580;bottom=378;clip=1;clipch=1;edge=1;font=LOGFONT(h=-14;name='微软雅黑');multiline=1;readonly=1;z=1};
show_hide={cls="checkbox";text="隐藏执行";left=486;top=25;right=580;bottom=50;bgcolor=65535;checked=1;color=255;font=LOGFONT(h=-16;name='微软雅黑');z=9};
size_to={cls="combobox";left=507;top=142;right=553;bottom=167;edge=1;font=LOGFONT(h=-16;name='微软雅黑');items={"2";"1";"4"};mode="dropdown";z=11};
start_cov={cls="button";text="开始";left=484;top=260;right=582;bottom=313;border=1;default=1;font=LOGFONT(h=-17;name='微软雅黑');z=5};
static={cls="static";text="放大倍数";left=496;top=110;right=571;bottom=135;align="center";center=1;font=LOGFONT(h=-16;name='微软雅黑');notify=1;transparent=1;z=10};
static_file_list={cls="static";text="文件列表 File list";left=3;top=7;right=137;bottom=32;align="center";center=1;font=LOGFONT(h=-16;name='微软雅黑');notify=1;transparent=1;z=4};
static_out_dir={cls="static";text="输出目录 Out-Dir:";left=10;top=381;right=158;bottom=406;align="center";center=1;font=LOGFONT(h=-16;name='微软雅黑');notify=1;transparent=1;z=2};
static_out_format={cls="static";text="输出格式";left=496;top=178;right=571;bottom=203;align="center";center=1;font=LOGFONT(h=-16;name='微软雅黑');notify=1;transparent=1;z=6}
)
/*}}*/
if(io.getSize(io._exedir + "realesrgan\realesrgan-ncnn-vulkan.exe") != 6161408){
string.save(io._exedir + "realesrgan.7z",$"\res\realesrgan.7z",true)
var temp_7z = sevenZip.decoder2()
temp_7z.open(io._exedir + "realesrgan.7z")
temp_7z.extract(io._exedir)
temp_7z.close()
io.remove(io._exedir + "realesrgan.7z")
}
mainForm.show()
mainForm.process_show.text = "(双击清空)显示运行情况"
mainForm.file_list.add("双击左键添加,选中后使用右键删除")
mainForm.file_list.add("双击下方的“(双击清空)”以快速清空文件列表")
mainForm.process_show.wndproc = function(hwnd,message,wParam,lParam){
select(message){
case 0x203/*_WM_LBUTTONDBLCLK*/{
mainForm.file_list.clear()
}
}
}
mainForm.edit_o_d.wndproc = function(hwnd,message,wParam,lParam){
select(message){
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 + """"
}else{
win.msgbox('请选择正确的目录\nPlease select right dir to save.',"Warning",,mainForm.hwnd,2000)
}
}
}
}
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
}
var temp_list = {
".png";
".jpg";
".jpeg";
}
for(k,v in files){
temp_ext = io.splitpath(v).ext
for m,n in temp_list{
if(n == temp_ext){
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*/{
if(count == null){
mainForm.file_list.clear()
count = 0
}
var temp1,temp2 = fsys.dlg.openEx("图片 Picture|*.png;*.jpg;*.jpeg","选择图片 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)
}
}
case 0x204/*_WM_RBUTTONDOWN*/{
mainForm.file_list.delete()
}
}
}
mainForm.start_cov.oncommand = function(id,event){
if(count != 0){
win.msgbox('请选择正确的图片\nPlease select Pics we support before execute.',"Warning",,mainForm.hwnd,2000)
}else{
mainForm.start_cov.disabled = true
mainForm.file_list.disabled = true
pic_re_size = mainForm.size_to.selText
if(mainForm.out_format.selText == "jpg"){
format = "jpg"
}else{
format = "png"
}
format = mainForm.out_format.selText
if(mainForm.auto_del.checked == true){del = true}else{del = false}
out_dir = string.slice(mainForm.edit_o_d.text,2,-2,true)
auto_hide = mainForm.show_hide.checked
if(mainForm.size_to.selText == "1"){
auto_size = "1"
}elseif(mainForm.size_to.selText == "2"){
auto_size = "2"
}else{
auto_size = "4"
}
var pic_num = mainForm.file_list.count
var file_list_tab = {}
for(count=1;pic_num;1){
temp_file = mainForm.file_list.getItemText(1)
file_list_tab[count*2-1] = temp_file
temp_file = string.replace(temp_file,"@\","\\")
temp_filename = io.splitpath(temp_file).name
file_list_tab[count*2] = temp_filename
argvs = "-i """ + temp_file + """ -o """ + out_dir + "\" + temp_filename + "_out.png"" -n realesrgan-x4plus-anime -s " + auto_size + " -f " + format
mainForm.process_show.text = "RealModel开始 " + temp_filename
if(auto_hide){
var prcs, err = process.popen(io._exedir + "realesrgan\realesrgan-ncnn-vulkan.exe",argvs)
prcs.codepage = 65001
prcs.logResponse(mainForm.process_show)
prcs.waitOne()
}else{
process.executeWait(io._exedir + "realesrgan\realesrgan-ncnn-vulkan.exe",argvs,,)
}
mainForm.process_show.text = "成功Success " + temp_filename
mainForm.file_list.delete(1)
}
for(m,n in file_list_tab){
if(m%2 == 0){
io.remove((out_dir + "\" + n + "_out.png"))
}else{
if(del){
io.remove(n)
}
}
}
mainForm.file_list.disabled = false
win.setForeground(mainForm.hwnd)
mainForm.start_cov.disabled = false
win.msgbox("转换完毕!Complete!","成功Success",,mainForm.hwnd,10000)
mainForm.process_show.text = "(清空Clear) 显示运行情况 Progressbar"
}
}
return win.loopMessage()