本文整理汇总了Python中kivy.core.image.Image.load方法的典型用法代码示例。如果您正苦于以下问题:Python Image.load方法的具体用法?Python Image.load怎么用?Python Image.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.core.image.Image
的用法示例。
在下文中一共展示了Image.load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build
# 需要导入模块: from kivy.core.image import Image [as 别名]
# 或者: from kivy.core.image.Image import load [as 别名]
def build(self):
Window.bind(on_draw=self.ondraw)
self.ui = MainUI()
glb.root = self.ui
glb.app = self
self.texture_ruddertrim_wheel = CoreImage.load('img/ruddertrimwheel.png').texture
self.texture_ruddertrim_wheel.wrap = 'repeat'
self.texture_elevatortrim_wheel = CoreImage.load('img/elevatortrimwheel.png').texture
self.texture_elevatortrim_wheel.wrap = 'repeat'
return self.ui #show it
示例2: on_source
# 需要导入模块: from kivy.core.image import Image [as 别名]
# 或者: from kivy.core.image.Image import load [as 别名]
def on_source(self, *args):
v = self.source.split(".")
source_down = ''.join(v[:-1])+"_down"+v[-1]
self._fname_normal = resource_find(self.source)
self._fname_down = resource_find(source_down) or self._fname_normal
self.image_size = CoreImage.load(self._fname_normal).size
self.background_normal = self._fname_normal
self.background_down = self._fname_down
示例3: test_save_into_bytesio
# 需要导入模块: from kivy.core.image import Image [as 别名]
# 或者: from kivy.core.image.Image import load [as 别名]
def test_save_into_bytesio(self):
Image = self.cls
if setupconfig.PLATFORM == "darwin":
# XXX on OSX CI Builder, img_sdl2 is not used
# therefore the test below wont work yet with imageio only.
return
# load kivy logo
img = Image.load("data/logo/kivy-icon-512.png")
self.assertIsNotNone(img)
# try to save without any format
with self.assertRaises(Exception) as context:
bio = io.BytesIO()
img.save(bio)
# save it in png
bio = io.BytesIO()
# if False, then there is no provider
self.assertTrue(img.save(bio, fmt="png"))
pngdata = bio.read()
self.assertTrue(len(pngdata) > 0)
# try to save in a filename
try:
_, filename = tempfile.mkstemp(suffix=".png")
self.assertTrue(img.save(filename, fmt="png"))
finally:
os.unlink(filename)
# XXX Test wrote but temporary commented
# XXX because of the issue #6123 on OSX
# XXX https://github.com/kivy/kivy/issues/6123
# with open(filename, "rb") as fd2:
# pngdatafile = fd2.read()
# # check the png file data is the same as bytesio
# self.assertTrue(pngdata == pngdatafile)
# save it in jpeg
bio = io.BytesIO()
# if False, then there is no provider
self.assertTrue(img.save(bio, fmt="jpg"))
self.assertTrue(len(bio.read()) > 0)
with tempfile.NamedTemporaryFile(suffix=".jpg") as fd:
self.assertTrue(img.save(fd.name))
示例4: on_paths
# 需要导入模块: from kivy.core.image import Image [as 别名]
# 或者: from kivy.core.image.Image import load [as 别名]
def on_paths(self, *args):
"""Make textures from the images in ``paths``, and assign them at the
same index in my ``texs`` as in my ``paths``.
"""
for i, path in enumerate(self.paths):
if path in self.pathtexs:
if (
self.pathtexs[path] in self.texs and
self.texs.index(self.pathtexs[path])== i
):
continue
else:
self.pathimgs[path] = img = Image.load(
resource_find(path), keep_data=True
)
self.pathtexs[path] = img.texture
if i == len(self.texs):
self.texs.append(self.pathtexs[path])
else:
self.texs[i] = self.pathtexs[path]
示例5: loadBackground
# 需要导入模块: from kivy.core.image import Image [as 别名]
# 或者: from kivy.core.image.Image import load [as 别名]
def loadBackground(self):
print 'loading bg', self.bg
tex = CImage.load(self.bg, keep_data=True).texture
self.buildBackground(tex)
示例6: Mazy
# 需要导入模块: from kivy.core.image import Image [as 别名]
# 或者: from kivy.core.image.Image import load [as 别名]
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.image import Image
from kivy.core.image import Image as ImageForTest
from kivy.properties import NumericProperty, ReferenceListProperty, ObjectProperty
from kivy.vector import Vector
from kivy.factory import Factory
from kivy.clock import Clock
from kivy.core.window import Window
from kivy.lang import Builder
from kivy.graphics import Color
import math
m = ImageForTest.load('testme.png',keep_data=True)
Builder.load_string("""
<PongBall>:
size: 50, 50
""")
class Mazy(Image):
def on_touch_down(self,touch):
print "Testing...",touch.x,touch.y
print m.read_pixel(touch.x,touch.y)
class PongBall(Image):
r = NumericProperty(.5)
g = NumericProperty(.5)
b = NumericProperty(.5)
示例7: on_source
# 需要导入模块: from kivy.core.image import Image [as 别名]
# 或者: from kivy.core.image.Image import load [as 别名]
def on_source(self, *largs):
if os.path.exists(self.source):
self.texture = Image.load(self.source).texture
self.texture.wrap = 'repeat'
self._calc_tex_coords()
示例8: __init__
# 需要导入模块: from kivy.core.image import Image [as 别名]
# 或者: from kivy.core.image.Image import load [as 别名]
def __init__(self):
self.mapSize = 32
self.wallGrid = [] #VariableListProperty(self.mapSize * self.mapSize)
self.skybox = Image.load('./deathvalley_panorama.jpg')
self.wallTexture = Image.load('./wall_texture.jpg')
self.light = 0
示例9: build
# 需要导入模块: from kivy.core.image import Image [as 别名]
# 或者: from kivy.core.image.Image import load [as 别名]
def build(self):
self.root = Builder.load_string(kv)
self.texture = CoreImage.load(
'GrassGreenTexture0002.jpg').texture
self.texture.wrap = 'repeat'
return self.root
示例10: __load_icon
# 需要导入模块: from kivy.core.image import Image [as 别名]
# 或者: from kivy.core.image.Image import load [as 别名]
def __load_icon(self, app_dir: str) -> Image:
iconPath = app_dir + "/Icon.png"
icon = Image.load(iconPath)
return icon
示例11: loadBackground
# 需要导入模块: from kivy.core.image import Image [as 别名]
# 或者: from kivy.core.image.Image import load [as 别名]
def loadBackground(self):
print 'loading bg', self.bg
bg = CImage.load(self.bg, keep_data=True).texture
with self.field.canvas.before:
Rectangle(texture = bg, pos=(0,0), size=(1068,450))
示例12: __init__
# 需要导入模块: from kivy.core.image import Image [as 别名]
# 或者: from kivy.core.image.Image import load [as 别名]
def __init__(self, source_file):
self.source_file = source_file
self.texture = CoreImage.load(source_file).texture
# Angle to pixels converters
self.spherical_ratio_x = self.texture.width / 360.0
self.spherical_ratio_y = self.texture.height / 180.0
示例13: Mazy
# 需要导入模块: from kivy.core.image import Image [as 别名]
# 或者: from kivy.core.image.Image import load [as 别名]
from kivy.uix.widget import Widget
from kivy.core.image import Image as ImageForTest
from kivy.uix.image import Image
from kivy.uix.scatter import Scatter
from kivy.properties import NumericProperty, ReferenceListProperty, ObjectProperty
from kivy.vector import Vector
from kivy.factory import Factory
from kivy.clock import Clock
from kivy.core.window import Window
from kivy.lang import Builder
from kivy.graphics import Color
import math
m = ImageForTest.load('maze_2.png',keep_data=True)
Builder.load_string("""
<PongBall>:
size: 50, 50
""")
class Mazy(Image):
def on_touch_down(self,touch):
print "Testing...",touch.x,touch.y
tx = touch.x
ty = 600-touch.y
print m.read_pixel(tx,ty)
class PongBall(Image):
r = NumericProperty(.5)
示例14: BytesIO
# 需要导入模块: from kivy.core.image import Image [as 别名]
# 或者: from kivy.core.image.Image import load [as 别名]
# save an image into bytesio
from kivy.core.image import Image
from io import BytesIO
img = Image.load("data/logo/kivy-icon-512.png")
bio = BytesIO()
ret = img.save(bio, fmt="png")
print("len=", len(bio.read()))
bio = BytesIO()
ret = img.save(bio, fmt="jpg")
print("len=", len(bio.read()))
示例15: build
# 需要导入模块: from kivy.core.image import Image [as 别名]
# 或者: from kivy.core.image.Image import load [as 别名]
def build(self):
parent = Widget()
painter = PointoutWidget()
settingButton = Button(background_normal='data/task.png')
sliderSize = Slider(min=1.0, max=100, value=30)
parent.add_widget(painter)
parent.add_widget(settingButton)
#TODO: create a hover animation
#load the welcome image
welcomeTexture = Image.load('data/welcome.png', keep_data=True).texture
welcomeImg = Rectangle(size=(500,200), pos=((Window.width/2)-250, (Window.height/2)-100), texture= welcomeTexture)
#set on startup
painter.canvas.add(welcomeImg)
layout = GridLayout(cols=2)
layout_row1 = GridLayout(cols=2)
layout_row2 = GridLayout(cols=2)
layout_row3 = GridLayout(cols=2)
layout_row4 = GridLayout(cols=2)
layout_row5 = GridLayout(cols=2)
layout_row6 = GridLayout(cols=2)
layout_row7 = GridLayout(cols=2)
layout.add_widget(layout_row1)
layout_row1.add_widget(Label(text=u'Понедельник:', font_size=15))
layout_row1.add_widget(buttonMonday)
##########################
layout.add_widget(layout_row2)
layout_row2.add_widget(Label(text=u'Вторник:', font_size=15))
layout_row2.add_widget(buttonTuesday)
##########################
layout.add_widget(layout_row3)
layout_row3.add_widget(Label(text=u'Среда:', font_size=15))
layout_row3.add_widget(buttonWednesday)
##########################
layout.add_widget(layout_row4)
layout_row4.add_widget(Label(text=u'Четверг:', font_size=15))
layout_row4.add_widget(buttonThursday)
##########################
layout.add_widget(layout_row5)
layout_row5.add_widget(Label(text=u'Пятница:', font_size=15))
layout_row5.add_widget(buttonFriday)
##########################
layout.add_widget(layout_row6)
layout_row6.add_widget(Label(text=u'Суббота:', font_size=15))
layout_row6.add_widget(buttonSaturday)
##########################
popup = Popup(title=u'Расписание П-92', content=layout, size_hint=(None, None), size=(500, 500))
def setting_popup(obj):
popup.open()
settingButton.bind(on_release=setting_popup)
def setting_popup_Monday(obj):
content_Monday = Label(text=u'08.00 ауд.202 Мифология(л)\n\n09.50 ауд.425 Функ.прог.(п)\n\n11.40 ауд.211 ТРПО(л)\n\n13.45 ауд.211 ТРПО(л)(ВЕРХ)', font_size=20)
popup_Monday = Popup(title=u'Понедельник', content=content_Monday, size_hint=(None, None), size=(500, 500))
popup_Monday.open()
buttonMonday.bind(on_release=setting_popup_Monday)
def setting_popup_Tuesday(obj):
content_Tuesday = Label(text=u'08.00 ауд.407 ТЯПиМТ(л)\n\n09.50 ауд.419 ТЯПиМТ(п)\n\n11.40 ауд.218 Комп. графика(л)\n\n13.45 ауд.219 или 432а МСЗКИ(п)', font_size=20)
popup_Tuesday = Popup(title=u'Вторник', content=content_Tuesday, size_hint=(None, None), size=(500, 500))
popup_Tuesday.open()
buttonTuesday.bind(on_release=setting_popup_Tuesday)
def setting_popup_Wednesday(obj):
content_Wednesday = Label(text=u'08.00 ауд.402 ТРПО(п)\n\n09.50 ауд.302 Комп. графика(п)\n\n11.40 ауд.210 МСЗКИ(л)', font_size=20)
popup_Wednesday = Popup(title=u'Среда', content=content_Wednesday, size_hint=(None, None), size=(500, 500))
popup_Wednesday.open()
buttonWednesday.bind(on_release=setting_popup_Wednesday)
def setting_popup_Thursday(obj):
content_Thursday = Label(text=u'ВОЕНКА!!!', font_size=20)
popup_Thursday = Popup(title=u'Четверг', content=content_Thursday, size_hint=(None, None), size=(500, 500))
popup_Thursday.open()
buttonThursday.bind(on_release=setting_popup_Thursday)
def setting_popup_Friday(obj):
content_Friday = Label(text=u'08.00 ауд.418 Функ.прог.(л)\n\n09.50 ауд.409 Мифология(п)\n\n11.40 ОКНО(НИЗ)\n\n13.45 ауд.418 ТЯПиМТ(л)(НИЗ)', font_size=20)
popup_Friday = Popup(title=u'Пятница', content=content_Friday, size_hint=(None, None), size=(500, 500))
popup_Friday.open()
buttonFriday.bind(on_release=setting_popup_Friday)
def setting_popup_Saturday(obj):
content_Saturday = Label(text=u'СВОБОДА!!!', font_size=20)
popup_Saturday = Popup(title=u'Суббота', content=content_Saturday, size_hint=(None, None), size=(500, 500))
popup_Saturday.open()
buttonSaturday.bind(on_release=setting_popup_Saturday)
return parent