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


Python Image.blit_buffer方法代码示例

本文整理汇总了Python中kivy.uix.image.Image.blit_buffer方法的典型用法代码示例。如果您正苦于以下问题:Python Image.blit_buffer方法的具体用法?Python Image.blit_buffer怎么用?Python Image.blit_buffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kivy.uix.image.Image的用法示例。


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

示例1: mainApp

# 需要导入模块: from kivy.uix.image import Image [as 别名]
# 或者: from kivy.uix.image.Image import blit_buffer [as 别名]
class mainApp(App):
    source = StringProperty(None)
    processName = StringProperty(None)
    result = ObjectProperty(None)
    threadProcess = ObjectProperty(None)
    popup = ObjectProperty(None)
    def build(self):
        self.source = "./backgroundDefault.jpg"
        self.pictureList = []
        self.texture = Texture.create()
        self.texture.wrap="clamp_to_edge"
        self.customDropDown = CustomDropDown()
        root = RootWindow()
        return root

    def update_list_data(self, path, filename):
        exist = False
        if filename:
            print "Path : " + str(path) + " | Filename " + str(filename[0])
            for i in self.root.ids["ViewPreProcess"].ids["SelectionList"].list_adapter.data:
                if filename is i.name:
                    print "Filename "+str(Filename)+" already exist\n"
                    exist = True
            if not exist:
                self.root.ids["ViewPreProcess"].ids["SelectionList"].update_list_data(path,filename)
                defPath = os.path.join(path, filename[0])
                if re.search('.CR2',defPath):
                    image = ImageRaw.ImageRaw(defPath).getndarray()
                    #print "Append \n"
                    self.pictureList.append(DataImage(path=filename[0],image=image))
                    h,l,r = image.shape
                    self.texture = Texture.create(size=(l,h))
                    self.texture.blit_buffer(pbuffer = image.tostring(),bufferfmt="ushort",colorfmt='rgb')
                elif re.search('[.jpg|.png|.gif|.tiff]',defPath):
                    image = io.imread(defPath)
                    self.pictureList.append(DataImage(path=filename[0],image=image))
                    h,l,r = image.shape
                    self.texture = Texture.create(size=(l,h))
                    self.texture.blit_buffer(pbuffer = image.tostring(),bufferfmt="ubyte",colorfmt='rgb')
                    self.texture.flip_vertical()


                self.root.ids["ViewPreProcess"].ids["Image"].ids["currentImage"].texture = self.texture
                self.root.ids["ViewPreProcess"].ids["Image"].ids["currentImage"].size = self.texture.size
                self.root.ids["ViewPreProcess"].ids["Image"].ids["currentImage"].reload()


    def clear(self):
        self.root.ids["ViewPreProcess"].ids["Image"].ids["currentImage"].texture = Texture.create()
        self.root.ids["ViewPreProcess"].ids["Image"].ids["currentImage"].reload()
        self.pictureList = []
        self.root.ids["ViewWindow"].ids["Image"].ids["currentImage"].texture = Texture.create()
        self.root.ids["ViewWindow"].ids["Image"].ids["currentImage"].reload()

    def preview(self):
        #self.root.ids["ViewPreProcess"].ids["SelectionList"].list_adapter.on_selection_change()
        select = self.root.ids["ViewPreProcess"].ids["SelectionList"].list_adapter.selection
        if select:
            print "Selection change to "+str(select[0].text)
            if re.search('.CR2',select[0].text):
                for i in self.pictureList:
                    if i.path is select[0].text:
                        print "Find Image\n"
                        h,l,r = i.image.shape
                        self.texture = Texture.create(size=(l,h))
                        self.texture.blit_buffer(pbuffer = i.image.tostring(),bufferfmt="ushort",colorfmt='rgb')
            else:
                if self.root.ids["ViewPreProcess"].ids["Explorer"].ids["icon_view_tab"].show_hidden:
                    path = self.root.ids["ViewPreProcess"].ids["Explorer"].ids["list_view_tab"].path
                else:
                    path = self.root.ids["ViewPreProcess"].ids["Explorer"].ids["icon_view_tab"].path
                self.texture = Image(source=os.path.join(path, select[0].text)).texture

            self.root.ids["ViewPreProcess"].ids["Image"].ids["currentImage"].texture = self.texture
            self.root.ids["ViewPreProcess"].ids["Image"].ids["currentImage"].reload()
        else:
            self.root.ids["ViewPreProcess"].ids["Image"].ids["currentImage"].texture = Texture.create()
            self.root.ids["ViewPreProcess"].ids["Image"].ids["currentImage"].reload()

    def remove(self):
        select = self.root.ids["ViewPreProcess"].ids["SelectionList"].list_adapter.selection
        if select:
            if re.search('.CR2',select[0].text):
                for i in self.pictureList:
                    if i.path is select[0].text:
                        print "Remove "+str(i.path)
                        self.pictureList.remove(i)
            self.root.ids["ViewPreProcess"].ids["SelectionList"].remove(select[0].text)

    def startProcess(self):
        self.threadProcess = threading.Thread(target=self.process, args=())
        self.threadProcess.start()
        self.popup = Popup(title='Render State', content=Label(text='Render in progress. It may take more than a minute'),
              auto_dismiss=False)
        self.popup.open()
        self.count = 0
        Clock.schedule_interval(self.updatePopup, 0.5)

    def updatePopup(self,dt):
        if self.threadProcess.isAlive():
#.........这里部分代码省略.........
开发者ID:nicolas-blanc,项目名称:AstroImage---NightFall,代码行数:103,代码来源:mainView.py


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