Skip to content

Commit

Permalink
update GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
sorphwer committed Dec 23, 2019
1 parent 2fe1bd2 commit c796fad
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 0 deletions.
Binary file added DSC0030.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def main():
args = parser.parse_args()

dc, ac, tables, blocks_count = read_image_file(args.input)
#dc, ac, tables, blocks_count = read_image_file(FILE_PATH)

# assuming that the block is a 8x8 square
block_side = 8
Expand Down
Binary file added test1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions test2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def load_quantization_table(component):
[4, 4, 5, 7, 10, 12, 12, 12],
[5, 5, 7, 9, 12, 12, 12, 12],
[6, 6, 9, 12, 12, 12, 12, 12]])

elif component == 'chrom':
q = np.array([[3, 3, 5, 9, 13, 15, 15, 15],
[3, 4, 6, 11, 14, 12, 12, 12],
Expand All @@ -22,6 +23,20 @@ def load_quantization_table(component):
[15, 12, 12, 12, 12, 12, 12, 12],
[15, 12, 12, 12, 12, 12, 12, 12],
[15, 12, 12, 12, 12, 12, 12, 12]])

q = np.array([[1, 1, 1, 1, 13, 15, 15, 15],
[1, 1, 1, 11, 14, 12, 12, 12],
[1, 1, 1, 14, 12, 12, 12, 12],
[1, 11, 14, 12, 12, 12, 12, 12],
[13, 14, 12, 12, 12, 12, 12, 12],
[15, 12, 12, 12, 12, 12, 12, 12],
[15, 12, 12, 12, 12, 12, 12, 12],
[15, 12, 12, 12, 12, 12, 12, 12]])





else:
raise ValueError((
"component should be either 'lum' or 'chrom', "
Expand Down
56 changes: 56 additions & 0 deletions window.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import tkinter as tk
from PIL import Image,ImageTk
import encoder
import decoder
# 建立主視窗和 Frame(把元件變成群組的容器)
window = tk.Tk()
window.geometry('600x800')
top_frame = tk.Frame(window)
windowWidth=600
windowHeight=800
screenWidth,screenHeight = window.maxsize()
geometryParam = '%dx%d+%d+%d'%(windowWidth, windowHeight, (screenWidth-windowWidth)/2, (screenHeight - windowHeight)/2)

window.geometry(geometryParam)
window.wm_attributes('-topmost',1)

#img=Image.open('DSC0030.jpg')
#image_file=ImageTk.PhotoImage(img)
image_file=None
img=None
label_img = tk.Label(window,image=image_file)
label_img.pack()

# 將元件分為 top/bottom 兩群並加入主視窗
top_frame.pack()
bottom_frame = tk.Frame(window)
bottom_frame.pack(side=tk.BOTTOM)

# 建立事件處理函式(event handler),透過元件 command 參數存取
def echo_hello():
print('hello world :)')

def fresh():
global img
global image_file
url1="test1.jpg"
img = Image.open(url1)
image_file= ImageTk.PhotoImage(img)
label_img.configure(image = image_file)
#image=canvas.create_image(0,0,anchor="nw",image=image_file)
window.update_idletasks()
print("fresh?")

# 以下為 top 群組

# 以下為 bottom 群組
# bottom_button 綁定 echo_hello 事件處理,點擊該按鈕會印出 hello world :)
bottom_button = tk.Button(bottom_frame ,text='fresh', fg='black', command=fresh)
bottom_button1 = tk.Button(bottom_frame ,text='fresh1', fg='black', command=fresh)
bottom_button2 = tk.Button(bottom_frame ,text='fresh2', fg='black', command=fresh)
# 讓系統自動擺放元件(靠下方)
bottom_button.pack(side=tk.LEFT)
bottom_button1.pack(side=tk.LEFT)
bottom_button2.pack(side=tk.LEFT)
# 運行主程式
window.mainloop()

0 comments on commit c796fad

Please sign in to comment.