当前位置: 首页>>代码示例>>Python>>正文


Python image.Image类代码示例

本文整理汇总了Python中kivy.core.image.Image的典型用法代码示例。如果您正苦于以下问题:Python Image类的具体用法?Python Image怎么用?Python Image使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Image类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getTexture

 def getTexture(self,name, size):
     filename = join('art', name+'.png')
     texture = Image(filename).texture
     texture.wrap = 'repeat'
     texture.uvsize = size
     self.logger.info(filename)
     return texture
开发者ID:Jvatinsa,项目名称:spylight,代码行数:7,代码来源:main.py

示例2: load_texture

 def load_texture(key, path, region=None, mipmap=False, wrap=None):
     texture_path = join(RESOURCES_DIR, path)
     texture = Image(texture_path, mipmap=mipmap).texture
     if region:
         texture = texture.get_region(*region)
 
     textures[key] = texture
开发者ID:nskrypnik,项目名称:moonrabbit,代码行数:7,代码来源:resources.py

示例3: __init__

 def __init__(self, *args, **kw):
     super(RootWidget, self).__init__(*args, **kw)
     texture = Image('wood.png').texture
     texture.wrap = 'repeat'
     texture.uvsize = (8, 8)
     with self.canvas:
         Rectangle(size=(2048, 2048), texture=texture)
开发者ID:letaiefbechir,项目名称:kivy.tips,代码行数:7,代码来源:main.py

示例4: Image

    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
开发者ID:arcticshores,项目名称:Myrmidon,代码行数:59,代码来源:engine.py

示例5: __init__

	def __init__(self, *args, **kwargs) :
		super(ScreenNexus, self).__init__(*args, **kwargs)
		texture = Image(os.path.join("res", "tile.png")).texture # Create background texture
		texture.wrap = "repeat"
		texture.uvsize = (12, 24)
		
		with self.canvas.before : # Draw background
			Color(1, 1, 1)
			Rectangle(texture = texture, size = (Window.width, Window.height), pos = self.pos)
开发者ID:redevined,项目名称:BrennerAssistentenApp,代码行数:9,代码来源:main.py

示例6: set_texture

 def set_texture(self,path):
     #from kivy.core.image import Image
     tex = Image(path).texture
     tex.wrap = 'repeat'
     self.texture_sidebar = tex
     #tex = Image('style/1.png').texture
     if tex is not None:
         tex.wrap = 'repeat'
         self.texture = tex
开发者ID:triselectif,项目名称:Rongo-Rongo,代码行数:9,代码来源:appview.py

示例7: grass_background

def grass_background(widget):
    bg_texture = Image('resources/grass/grass-texture.png', nocache=True).texture
    # get POT texture
    #bg_texture = bg_texture.get_region(0, 0, 64, 64)
    #bg_texture.uvpos = (0, 0)
    bg_texture.uvsize = (35, 35)
    bg_texture.wrap = 'repeat'
    # fill all the background
    with widget.canvas.before:
        Rectangle(pos=(0, 0), size=(2560, 2560), texture=bg_texture)
开发者ID:nskrypnik,项目名称:moonrabbit,代码行数:10,代码来源:ui.py

示例8: __init__

    def __init__(self, **kw):
        super(HelicopterGame, self).__init__(**kw)

        with self.canvas.before:
            texture = CoreImage('Images/background.png').texture
            texture.wrap = 'repeat'
            self.scroll_back = Rectangle(texture=texture, size=self.size, pos=self.pos)

            self.line=BezierLine()
            Clock.schedule_interval(self.update, 0)
开发者ID:foreverai,项目名称:Walls,代码行数:10,代码来源:walls.py

示例9: build

	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
开发者ID:emcrispim,项目名称:FlightSimRC,代码行数:11,代码来源:main.py

示例10: capture

    def capture(self, event):
        if (self.camera.play):
            self.camera.play = False
            img = Image(self.camera.texture)
            img.save("capture.png")
            self.captureButton.text="Take another"
            self.classifyButton.disabled=False

        else:
            self.camera.play = True
            self.captureButton.text="Capture"
            self.classifyButton.disabled = True
开发者ID:peter11235,项目名称:plants,代码行数:12,代码来源:opencamera3.py

示例11: print_png

    def print_png(self, filename, *args, **kwargs):
        '''Call the widget function to make a png of the widget.
        '''
        fig = FigureCanvasAgg(self.figure)
        FigureCanvasAgg.draw(fig)

        l, b, w, h = self.figure.bbox.bounds
        texture = Texture.create(size=(w, h))
        texture.blit_buffer(bytes(fig.get_renderer().buffer_rgba()),
                                colorfmt='rgba', bufferfmt='ubyte')
        texture.flip_vertical()
        img = Image(texture)
        img.save(filename)
开发者ID:kivy-garden,项目名称:garden.matplotlib,代码行数:13,代码来源:backend_kivy.py

示例12: _print_image

 def _print_image(self, filename, *args, **kwargs):
     """Write out format png. The image is saved with the filename given.
     """
     l, b, w, h = self.figure.bbox.bounds
     img = None
     if self.img_texture is None:
         texture = Texture.create(size=(w, h))
         texture.blit_buffer(bytes(self.get_renderer().buffer_rgba()), colorfmt="rgba", bufferfmt="ubyte")
         texture.flip_vertical()
         img = Image(texture)
     else:
         img = Image(self.img_texture)
     img.save(filename)
开发者ID:jonatanolofsson,项目名称:garden.matplotlib,代码行数:13,代码来源:backend_kivyagg.py

示例13: loadTileImages

    def loadTileImages(self, ts):
        """
        Loads the images in filename into Kivy Images.
        This is a port of the code here: https://github.com/bitcraft/PyTMX/blob/master/pytmx/tmxloader.py

        :type ts: pytmx.TiledTileset
        """
        tile_image_path = self.map_dir + '/' + ts.source
        Logger.debug('KivyTiledMap: loading tile image at {}'.format(tile_image_path))
        texture = CoreImage(tile_image_path).texture

        ts.width, ts.height = texture.size
        tilewidth = ts.tilewidth + ts.spacing
        tileheight = ts.tileheight + ts.spacing
        Logger.debug('KivyTiledMap: TiledTileSet: {}x{} with {}x{} tiles'.format(ts.width, ts.height, tilewidth, tileheight))

        # some tileset images may be slightly larger than the tile area
        # ie: may include a banner, copyright, ect.  this compensates for that
        width = int((((ts.width - ts.margin * 2 + ts.spacing) / tilewidth) * tilewidth) - ts.spacing)
        height = int((((ts.height - ts.margin * 2 + ts.spacing) / tileheight) * tileheight) - ts.spacing)
        Logger.debug('KivyTiledMap: TiledTileSet: true size: {}x{}'.format(width, height))

        # initialize the image array
        Logger.debug('KivyTiledMap: initializing image array')
        self.images = [0] * self.maxgid

        p = itertools.product(
            xrange(ts.margin, height + ts.margin, tileheight),
            xrange(ts.margin, width + ts.margin, tilewidth)
        )

        # trim off any pixels on the right side that isn't a tile
        # this happens if extra graphics are included on the left, but they are not actually part of the tileset
        width -= (ts.width - ts.margin) % tilewidth

        for real_gid, (y, x) in enumerate(p, ts.firstgid):
            if x + ts.tilewidth - ts.spacing > width:
                continue

            gids = self.map_gid(real_gid)

            if gids:
                # invert y for OpenGL coordinates
                y = ts.height - y - ts.tileheight

                tile = texture.get_region(x, y, ts.tilewidth, ts.tileheight)

                for gid, flags in gids:
                    self.images[gid] = tile
开发者ID:PhoenixWright,项目名称:kivy-tiled,代码行数:49,代码来源:tiled.py

示例14: __init__

    def __init__(self, **kwargs):
        super(CanvasWidget, self).__init__(**kwargs)
        self.size = (512, 512)
        self._keyboard = Window.request_keyboard(self._keyboard_closed, self)
        self._keyboard.bind(on_key_down=self._on_keyboard_down)


        self.img = Image.open('test.png')
        self.img = self.img =  self.img.transpose(Image.FLIP_TOP_BOTTOM)
        self.texture = Texture.create(size=(512,512))
        self.texture.mag_filter = 'nearest'
        size = 512*512*3
        buf = []
        for r,g,b,a in self.img.getdata():
            buf.extend([r,g,b,a])
        #buf = [int(x*255/size) for x in range(size)]
        #buf = self._flatten_list(self.pixels)
        self.arr = array('B', buf)
        self.texture.blit_buffer(self.arr, colorfmt='rgba', bufferfmt='ubyte')

        with self.canvas:
            self.test = InstructionGroup()
            #self.test.add(Color(1, 1, 0, mode='rgb'))
            self.test.add(Rectangle(texture=self.texture, pos=self.pos, size=self.size, group='heh'))

        #self.bind(texture=self.on_texture_update)
        self.bind(pos=self.on_texture_update)
        self.bind(size=self.on_texture_update)
开发者ID:chip2n,项目名称:sprite,代码行数:28,代码来源:app.py

示例15: populate_palette

	def populate_palette(self):
		if self.tileset != None:
			# Set image
			self.tilesetImage = Image(self.tileset).texture
			# Set background image:
			backgroundImagePath = join(globals.subDirectory['graphics'], "emptytile.png")
			backgroundImage = Image(backgroundImagePath).texture
			# Find the resolution of this image:
			yDiv = (self.res[1] / self.res[0]) / 4
			self.imageRes = [self.tilesetImage.width / 4 , self.tilesetImage.width * yDiv]
			# Set new dimensions
			self.width = self.res[0] * 4 + self.offset * 2
			self.height = self.res[1] * (self.tilesetImage.height / (self.tilesetImage.width * yDiv)) + self.offset * 2
			# Draw the background:
			with self.canvas.before:
				Color(1, 1, 1, 0.5)
				Rectangle(size = self.size, pos = (self.offset, self.offset))
			for x in range(4):
				for y in range(int(self.tilesetImage.height / (self.tilesetImage.width * yDiv))):
					with self.canvas.before:
						Color(1, 1, 1, 0.1)
						Rectangle(texture = backgroundImage, 
									size = self.res, 
									pos = (x * self.res[0] + self.offset, y * self.res[1] + self.offset ))
			# Draw the tileset in the palette
			for x in range(4):
				for y in range(int(self.tilesetImage.height / (self.tilesetImage.width * yDiv))):
					with self.canvas:
						Color(1, 1, 1, 1)
						Rectangle(texture = self.tilesetImage.get_region(x * self.imageRes[0], y * self.imageRes[1], self.imageRes[0], self.imageRes[1]), 
									size = self.res, 
									pos = (x * self.res[0] + self.offset, y * self.res[1] + self.offset ))		
开发者ID:Gimdal,项目名称:IsoMapMaker,代码行数:32,代码来源:palettes.py


注:本文中的kivy.core.image.Image类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。