代码拉取完成,页面将自动刷新
"""
添加滤镜:提供多种滤镜供选择添加。
# lzy #
"""
from tkinter import *
from PIL import Image,ImageFilter
import UI
from VariableFrame import VariableFrame
#
class FilterFrame(VariableFrame):
def __init__(self, canv, master=None):
VariableFrame.__init__(self, canv, master)
self.placeWidget()
def placeWidget(self):
"""
放置控件
"""
bcolor = UI.bg
fcolor = UI.fg
w = UI.rightWidth-12
h = 25
f = UI.font
fy = 5
dy = h+8
fx = 0
sx = 130
i=0
btn1 = Button(self, text="高斯模糊",
bg=bcolor, fg=fcolor,
bitmap=UI.viewBmp, compound='left',
width=w, height=h,
font=f,
command=lambda:self.addFilter(ImageFilter.GaussianBlur))
btn1.place(x=fx, y=fy+i*dy)
i += 1
btn2 = Button(self, text="普通模糊",
bg=bcolor, fg=fcolor,
bitmap=UI.viewBmp, compound='left',
width=w, height=h,
font=f,
command=lambda:self.addFilter(ImageFilter.BLUR))
btn2.place(x=fx, y=fy+i*dy)
i += 1
btn3 = Button(self, text="边缘增强",
bg=bcolor, fg=fcolor,
bitmap=UI.viewBmp, compound='left',
width=w, height=h,
font=f,
command=lambda:self.addFilter(ImageFilter.EDGE_ENHANCE))
btn3.place(x=fx, y=fy+i*dy)
i += 1
btn3 = Button(self, text="找到边缘",
bg=bcolor, fg=fcolor,
bitmap=UI.viewBmp, compound='left',
width=w, height=h,
font=f,
command=lambda:self.addFilter(ImageFilter.FIND_EDGES))
btn3.place(x=fx, y=fy+i*dy)
i += 1
btn3 = Button(self, text="浮雕",
bg=bcolor, fg=fcolor,
bitmap=UI.viewBmp, compound='left',
width=w, height=h,
font=f,
command=lambda:self.addFilter(ImageFilter.EMBOSS))
btn3.place(x=fx, y=fy+i*dy)
i += 1
btn3 = Button(self, text="轮廓",
bg=bcolor, fg=fcolor,
bitmap=UI.viewBmp, compound='left',
width=w, height=h,
font=f,
command=lambda:self.addFilter(ImageFilter.CONTOUR))
btn3.place(x=fx, y=fy+i*dy)
i += 1
btn3 = Button(self, text="锐化",
bg=bcolor, fg=fcolor,
bitmap=UI.viewBmp, compound='left',
width=w, height=h,
font=f,
command=lambda:self.addFilter(ImageFilter.SHARPEN))
btn3.place(x=fx, y=fy+i*dy)
i += 1
btn3 = Button(self, text="平滑",
bg=bcolor, fg=fcolor,
bitmap=UI.viewBmp, compound='left',
width=w, height=h,
font=f,
command=lambda:self.addFilter(ImageFilter.SMOOTH))
btn3.place(x=fx, y=fy+i*dy)
i += 1
btn3 = Button(self, text="细节",
bg=bcolor, fg=fcolor,
bitmap=UI.viewBmp, compound='left',
width=w, height=h,
font=f,
command=lambda:self.addFilter(ImageFilter.DETAIL))
btn3.place(x=fx, y=fy+i*dy)
def addFilter(self, f):
"""
添加滤镜 f
"""
img = self.canv.img.filter(f)
self.canv.refresh(img)
#
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。