3 Star 0 Fork 0

lzq1357 / Modifying pictures

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
FilterFrame.py 3.87 KB
一键复制 编辑 原始数据 按行查看 历史
lzq1357 提交于 2021-07-26 23:15 . UI优化补充
"""
添加滤镜:提供多种滤镜供选择添加。
# 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)
#
Python
1
https://gitee.com/lzq1357/Modifying-pictures.git
git@gitee.com:lzq1357/Modifying-pictures.git
lzq1357
Modifying-pictures
Modifying pictures
master

搜索帮助