本文整理汇总了Python中kivy.core.image.Image.remove_from_cache方法的典型用法代码示例。如果您正苦于以下问题:Python Image.remove_from_cache方法的具体用法?Python Image.remove_from_cache怎么用?Python Image.remove_from_cache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.core.image.Image
的用法示例。
在下文中一共展示了Image.remove_from_cache方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Image
# 需要导入模块: from kivy.core.image import Image [as 别名]
# 或者: from kivy.core.image.Image import remove_from_cache [as 别名]
class Image(object):
EMPTY_IMAGE = Kivy_Image(Texture.create(size=(0, 0)))
width = 0
height = 0
filename = None
is_sequence_image = False
def __init__(self, image = None, sequence = False, width = None, height = None, mipmap = True):
if image is None:
self.image = self.EMPTY_IMAGE
self.width = 0
self.height = 0
return
if isinstance(image, str):
self.filename = image
try:
self.image = Kivy_Image(image, mipmap = mipmap)
except:
raise MyrmidonError("Couldn't load image from " + image)
else:
self.image = Kivy_Image(image)
self.width = self.image.width
self.height = self.image.height
def destroy(self):
"""
Explicitly removes this image from the video memory and
Kivy's cache.
This functionality requires the custom kivy version at
http://github.com/arcticshores/kivy
"""
if self.image is None or self.image is self.EMPTY_IMAGE:
return
from kivy.cache import Cache
from kivy.graphics.opengl import glBindTexture, glDeleteTextures
from kivy.logger import Logger
Logger.debug("MyrmidonGFX: Destroying {0}".format(self.filename if self.filename else self.image))
# Remove from cache
self.image.remove_from_cache()
# Convert the ID to the right byte format for the GL method
a1 = (self.image.texture.id >> 0) & 0xFF
a2 = (self.image.texture.id >> 8) & 0xFF
a3 = (self.image.texture.id >> 16) & 0xFF
a4 = (self.image.texture.id >> 24) & 0xFF
# Remove texture completely
glBindTexture(self.image.texture.target, 0)
glDeleteTextures(1, bytes(bytearray([a1, a2, a3, a4])))
# Since we've done a manual removal kivy shouldn't do it's own removal later
self.image.texture.nofree = 1
# Stop this image from being used as a texture now
self.image = None