代码拉取完成,页面将自动刷新
"""
视觉效果:改变图像亮度、对比度,增强锐化、灰色模式等等。
# lzy #
"""
from PIL import Image, ImageFilter, ImageEnhance
from tkinter import *
import UI
from VariableFrame import VariableFrame
#
class VisualFrame(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.bright())
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.dimming())
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.bw())
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.color1())
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.color2())
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.sharpness1())
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.sharpness2())
btn3.place(x=fx, y=fy+i*dy)
def bright(self):#调亮
img1 = ImageEnhance.Brightness(self.canv.img).enhance(1.2)
self.canv.refresh(img1)
def dimming(self):#调暗
img2 = ImageEnhance.Brightness(self.canv.img).enhance(0.83)
self.canv.refresh(img2)
def bw(self):#黑白模式
img3= ImageEnhance.Color(self.canv.img).enhance(0.0)
self.canv.refresh(img3)
def color1(self):#对比度减弱
img4= ImageEnhance.Color(self.canv.img).enhance(0.83)
self.canv.refresh(img4)
def color2(self):#对比度增强
img5 = ImageEnhance.Color(self.canv.img).enhance(1.2)
self.canv.refresh(img5)
def sharpness1(self):#模糊化
img6= ImageEnhance.Sharpness(self.canv.img).enhance(0.66)
self.canv.refresh(img6)
def sharpness2(self):#锐化
img7= ImageEnhance.Sharpness(self.canv.img).enhance(1.5)
self.canv.refresh(img7)
#
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。