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


Python PNMImage.copyChannel方法代码示例

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


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

示例1: __init__

# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import copyChannel [as 别名]
    def __init__(self, pipeline):
        DebugObject.__init__(self, "BugReporter")
        self.debug("Creating bug report")

        reportDir = "BugReports/" + str(int(time.time())) + "/"
        reportFname = "BugReports/" + str(int(time.time())) + ""
        if not isdir(reportDir):
            os.makedirs(reportDir)

        # Generate general log
        DebugLog = "Pipeline Bug-Report\n"
        DebugLog += "Created: " + datetime.datetime.now().isoformat() + "\n"
        DebugLog += "System: " + sys.platform + " / " + os.name + " (" + str(8 * struct.calcsize("P")) + " Bit)\n"

        with open(join(reportDir, "general.log"), "w") as handle:
            handle.write(DebugLog)

        # Write stdout and stderr
        with open(join(reportDir, "stdout.log"), "w") as handle:
            handle.write(sys.stdout.getLog())

        with open(join(reportDir, "stderr.log"), "w") as handle:
            handle.write(sys.stderr.getLog())

        # Write the scene graph
        handle = OFileStream(join(reportDir, "scene_graph.log"))
        Globals.render.ls(handle)
        handle.close()

        # Write the pipeline settings
        SettingLog = "# Pipeline Settings Diff File:\n\n"

        for key, val in pipeline.settings.settings.iteritems():
            if val.value != val.default:
                SettingLog += key + " = " + str(val.value) + " (Default " + str(val.default) + ")\n"

        with open(join(reportDir, "pipeline.ini"), "w") as handle:
            handle.write(SettingLog)

        # Write the panda settings
        handle = OFileStream(join(reportDir, "pandacfg.log"))
        ConfigVariableManager.getGlobalPtr().writePrcVariables(handle)
        handle.close()

        # Write lights and shadow sources
        with open(join(reportDir, "lights.log"), "w") as handle:
            pp = pprint.PrettyPrinter(indent=4, stream=handle)
            handle.write("\nLights:\n")
            pp.pprint(pipeline.lightManager.lightSlots)
            handle.write("\n\nShadowSources:\n")
            pp.pprint(pipeline.lightManager.shadowSourceSlots)

        # Extract buffers
        bufferDir = join(reportDir, "buffers")

        if not isdir(bufferDir):
            os.makedirs(bufferDir)

        for name, (size, entry) in MemoryMonitor.memoryEntries.iteritems():
            if type(entry) == Texture:
                w, h = entry.getXSize(), entry.getYSize()
                # Ignore buffers
                if h < 2:
                    continue
                pipeline.showbase.graphicsEngine.extractTextureData(entry, pipeline.showbase.win.getGsg())

                if not entry.hasRamImage():
                    print "Ignoring", name
                    continue
                pnmSrc = PNMImage(w, h, 4, 2 ** 16 - 1)
                entry.store(pnmSrc)

                pnmColor = PNMImage(w, h, 3, 2 ** 16 - 1)
                pnmColor.copySubImage(pnmSrc, 0, 0, 0, 0, w, h)
                pnmColor.write(join(bufferDir, name + "-color.png"))

                pnmAlpha = PNMImage(w, h, 3, 2 ** 16 - 1)
                pnmAlpha.copyChannel(pnmSrc, 3, 0)
                pnmAlpha.write(join(bufferDir, name + "-alpha.png"))

        shutil.make_archive(reportFname, "zip", reportDir)
        shutil.rmtree(reportDir)
        self.debug("Bug report saved: ", reportFname + ".zip")
开发者ID:cesarmarinhorj,项目名称:RenderPipeline,代码行数:85,代码来源:BugReporter.py


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