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


Python image.is_single_color_image函数代码示例

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


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

示例1: test_solid_paletted_image

 def test_solid_paletted_image(self):
     img = Image.new('P', (100, 100), color=20)
     palette = []
     for i in range(256):
         palette.extend((i, i//2, i%3))
     img.putpalette(palette)
     eq_(is_single_color_image(img), (20, 10, 2))
开发者ID:atrawog,项目名称:mapproxy,代码行数:7,代码来源:test_image.py

示例2: test_one_point

 def test_one_point(self):
     img = Image.new('RGB', (100, 100), color='#ff0000')
     draw = ImageDraw.Draw(img)
     draw.point((99, 99))
     del draw
     
     assert not is_single_color_image(img)
开发者ID:atrawog,项目名称:mapproxy,代码行数:7,代码来源:test_image.py

示例3: set_tile

    def set_tile(self, tile):
        x, y, z = tile.coord
        assert self.grid[0] <= x < self.grid[2]
        assert self.grid[1] <= y < self.grid[3]


        color = is_single_color_image(tile.source.as_image())

        with tile_buffer(tile) as buf:
            _data = buffer(buf.read())

        if color:
            data = None
            _color = ''.join('%02x' % v for v in color)
            self.unique_tiles.set_data(_data, _color)
        else:
            #get value of cStringIO-Object and store it to a buffer
            data = _data
            _color = None

        timestamp = int(time.time())
        cursor = self.db.cursor()
        stmt = "INSERT INTO %s (x, y, data, date_added, unique_tile) VALUES (?,?,?,?,?)" % (self.table_name)
        try:
            cursor.execute(stmt, (x, y, data, timestamp, _color))
        except (sqlite3.IntegrityError, sqlite3.OperationalError) as e:
            #tile is already present, updating data
            stmt = "UPDATE %s SET data = ?, date_added = ?, unique_tile = ? WHERE x = ? AND y = ?" % (self.table_name)
            try:
                cursor.execute(stmt, (data, timestamp, _color, x, y))
            except sqlite3.OperationalError as e:
                #database is locked
                print(e)
                return False
        return True
开发者ID:GeoDodo,项目名称:mapproxy,代码行数:35,代码来源:sqlite.py

示例4: store_tile

 def store_tile(self, tile):
     """
     Add the given `tile` to the file cache. Stores the `Tile.source` to
     `FileCache.tile_location`.
     """
     if tile.stored:
         return
     
     tile_loc = self.tile_location(tile, create_dir=True)
     
     if self.link_single_color_images:
         color = is_single_color_image(tile.source.as_image())
         if color:
             self._store_single_color_tile(tile, tile_loc, color)
         else:
             self._store(tile, tile_loc)
     else:
         self._store(tile, tile_loc)
开发者ID:ChrisRenton,项目名称:mapproxy,代码行数:18,代码来源:file.py

示例5: test_solid_w_alpha

 def test_solid_w_alpha(self):
     img = Image.new('RGBA', (100, 100), color='#ff0102')
     eq_(is_single_color_image(img), (255, 1, 2, 255))
开发者ID:atrawog,项目名称:mapproxy,代码行数:3,代码来源:test_image.py

示例6: test_solid

 def test_solid(self):
     img = Image.new('RGB', (100, 100), color='#ff0102')
     eq_(is_single_color_image(img), (255, 1, 2))
开发者ID:atrawog,项目名称:mapproxy,代码行数:3,代码来源:test_image.py


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