コード例 #1
0
ファイル: engine.py プロジェクト: arcticshores/Myrmidon
    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
コード例 #2
0
ファイル: main.py プロジェクト: schretzilla/Pip-Boy
	def DeleteSavedFace(self):
		self.ids.displayImage.source = ''
		imToRemove = CoreImage('faceImg/grayImg.png')
		imToRemove.remove_from_cache()

		os.rename("faceImg/grayImg.png", "faceImg/grayImgTemp.png")

		Cache.remove("kv.image")
		Cache.remove("kv.textur")

		self.remove_widget(self.ids.displayImage)
		os.rename("faceImg/grayImgTemp.png", "faceImg/grayImg.png")

		self.ids.displayImage.source = 'faceImg/grayImg.png'
コード例 #3
0
ファイル: engine.py プロジェクト: arcticshores/Myrmidon
    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