我使用小精灵作为图像,放大后会变得模糊。我该如何解决这个问题?
import kivy
kivy.require("1.10.0")
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.lang.builder import Builder
class Container(BoxLayout):
pass
class TestName(App):
def build(self):
Builder.load_string("""
<Container>:
id: contain
Image:
source: "smile.png"
allow_stretch: True
""")
root = Container()
return root
if __name__ == '__main__':
TestName().run()
答案 0 :(得分:3)
您可以将mag_filter
图片的纹理设置为nearest
,如下所示:
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
class Container(BoxLayout):
pass
class TestName(App):
def build(self):
Builder.load_string("""
<Container>:
id: contain
image: image
Image:
source: "smile.png"
allow_stretch: True
id: image
""")
root = Container()
root.image.texture.mag_filter = 'nearest'
return root
if __name__ == '__main__':
TestName().run()