@@ -14,74 +14,99 @@ def __init__(self, display):
1414 self .image_path = resource_path (sample_image_path )
1515 self .cv_image = cv2 .imread (self .image_path )
1616
17- self .root .title ('pixel art styler ' )
18- self .root .geometry ('300x300 ' )
17+ self .root .title ('pixel art styler像素風格濾鏡工具 ' )
18+ self .root .geometry ('500x300 ' )
1919
2020 self .load_file_name = StringVar ()
21- self .load_file_name .set ('no file ' )
21+ self .load_file_name .set ('no file無檔案 ' )
2222 self .now_file_name = Label (self .root ,textvariable = self .load_file_name )
2323 self .now_file_name .grid (column = 0 , row = 0 , sticky = N + W )
2424
25- self .import_img_btn = Button (self .root , text = 'import img ' , command = self .import_img )
25+ self .import_img_btn = Button (self .root , text = 'import img導入圖片 ' , command = self .import_img )
2626 self .import_img_btn .grid (column = 4 , row = 0 , sticky = E + N )
2727
2828 # color num
29- self .color_num_name = Label (self .root ,text = 'Color nums ' )
29+ self .color_num_name = Label (self .root ,text = 'Color nums色數 ' )
3030 self .color_num_name .grid (column = 0 , row = 1 , sticky = N + W )
3131 self .color_num_select_box = Combobox (self .root , width = 5 )
3232 self .color_num_select_box .grid (column = 0 , row = 2 , sticky = N + W )
3333 self .color_num_select_box ['values' ] = ['2' , '4' , '8' , '16' ]
3434 self .color_num_select_box .current (0 )
3535 # pixel size
36- self .pixel_size_name = Label (self .root ,text = 'Pixel size ' )
37- self .pixel_size_name .grid (column = 4 , row = 1 , sticky = N + W )
36+ self .pixel_size_name = Label (self .root ,text = 'Pixel size像素尺寸 ' )
37+ self .pixel_size_name .grid (column = 4 , row = 1 , sticky = N + E )
3838 self .pixel_size_select_box = Combobox (self .root , width = 5 )
39- self .pixel_size_select_box .grid (column = 4 , row = 2 , sticky = N + W )
39+ self .pixel_size_select_box .grid (column = 4 , row = 2 , sticky = N + E )
4040 self .pixel_size_select_box ['values' ] = ['1' , '2' , '3' , '4' ]
4141 self .pixel_size_select_box .current (0 )
4242 # smoothing
43- self .smoothing_name = Label (self .root ,text = 'Smoothing ' )
43+ self .smoothing_name = Label (self .root ,text = 'Smoothing光滑 ' )
4444 self .smoothing_name .grid (column = 0 , row = 3 , sticky = N + W )
4545 self .smoothing_select_box = Combobox (self .root , width = 5 )
4646 self .smoothing_select_box .grid (column = 0 , row = 4 , sticky = N + W )
4747 self .smoothing_select_box ['values' ] = ['None' , 'Less' , 'Great' ]
4848 self .smoothing_select_box .current (0 )
4949 # outlines
50- self .outline_name = Label (self .root ,text = 'Outline inflate ' )
51- self .outline_name .grid (column = 4 , row = 3 , sticky = N + W )
50+ self .outline_name = Label (self .root ,text = 'Outline輪廓 ' )
51+ self .outline_name .grid (column = 4 , row = 3 , sticky = N + E )
5252 self .outline_select_box = Combobox (self .root , width = 5 )
53- self .outline_select_box .grid (column = 4 , row = 4 , sticky = N + W )
53+ self .outline_select_box .grid (column = 4 , row = 4 , sticky = N + E )
5454 self .outline_select_box ['values' ] = ['None' , 'Less' , 'Great' ]
5555 self .outline_select_box .current (0 )
56+ # saturation
57+ self .saturation_name = Label (self .root ,text = 'Saturation飽和' )
58+ self .saturation_name .grid (column = 0 , row = 5 , sticky = N + W )
59+ self .saturation_select_box = Combobox (self .root , width = 5 )
60+ self .saturation_select_box .grid (column = 0 , row = 6 , sticky = N + W )
61+ self .saturation_select_box ['values' ] = ['-200' , '-100' , '0' , '100' , '200' ]
62+ self .saturation_select_box .current (2 )
63+ # contrast
64+ self .contrast_name = Label (self .root ,text = 'Contrast對比' )
65+ self .contrast_name .grid (column = 4 , row = 5 , sticky = N + E )
66+ self .contrast_select_box = Combobox (self .root , width = 5 )
67+ self .contrast_select_box .grid (column = 4 , row = 6 , sticky = N + E )
68+ self .contrast_select_box ['values' ] = ['-200' , '-100' , '0' , '100' , '200' ]
69+ self .contrast_select_box .current (2 )
5670
5771 # dithering
5872 self .dithering_bool = BooleanVar ()
59- self .dithering_check = Checkbutton (self .root , text = 'Dithering ' , variable = self .dithering_bool )
73+ self .dithering_check = Checkbutton (self .root , text = 'Dithering顆粒抖動 ' , variable = self .dithering_bool )
6074 self .dithering_check .grid (column = 0 , row = 7 , sticky = N + W )
6175
6276 # transform button
63- self .transform_img_btn = Button (self .root , text = 'transform ' , command = self .transform_img )
77+ self .transform_img_btn = Button (self .root , text = 'transform變換 ' , command = self .transform_img )
6478 self .transform_img_btn .grid (column = 0 , row = 8 , sticky = W + N )
6579 # save_img button
66- self .save_img_btn = Button (self .root , text = 'save ' , command = self .save_img )
80+ self .save_img_btn = Button (self .root , text = 'save保存 ' , command = self .save_img )
6781 self .save_img_btn .grid (column = 0 , row = 9 , sticky = W + N )
6882
6983 def import_img (self ):
7084 image_path = filedialog .askopenfilename ()
7185 if image_path :
7286 file_name = re .split ('/|\.' , image_path )[- 2 ]
73- print (image_path )
87+ # print(image_path)
7488 self .load_file_name .set (file_name )
7589 self .display .image_load (image_path )
7690 self .image_path = image_path
91+ self .cv_image = cv2 .imread (self .image_path )
7792
7893 def transform_img (self ):
7994 k = int (self .color_num_select_box .get ())
8095 scale = int (self .pixel_size_select_box .get ())
8196 blur = self .get_textbox_value (self .smoothing_select_box .get ())
8297 erode = self .get_textbox_value (self .outline_select_box .get ())
8398 dither = self .dithering_bool .get ()
84- self .cv_image = convert (self .image_path , k = k , scale = scale , blur = blur , erode = erode , dither = dither )
99+ saturation = int (self .saturation_select_box .get ())
100+ contrast = int (self .contrast_select_box .get ())
101+
102+ self .cv_image = convert (self .image_path ,
103+ k = k ,
104+ scale = scale ,
105+ blur = blur ,
106+ erode = erode ,
107+ dither = dither ,
108+ saturation = saturation ,
109+ contrast = contrast )
85110 self .display .cv_to_pygame (self .cv_image )
86111
87112 def get_textbox_value (self , text ):
0 commit comments