textrender.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:pcbre 作者: pcbre 项目源码 文件源码
def loadCached():
    try:
        # TODO, rework to use app cache directory
        img = QtGui.QImage()
        if img.load("/tmp/shader.png"):
            newimg = img.convertToFormat(QtGui.QImage.Format.Format_ARGB32)

            shape = newimg.height(), newimg.width()
            ptr = newimg.constBits()

            # Extract the first channel
            data = numpy.array(ptr, dtype=numpy.uint8).reshape(newimg.height(), newimg.width(), 4)[:,:,0].copy()

            st = json.load(open("/tmp/shader.json","r"))

            atlas = {}
            for k, v in list(st.items()):
                atlas[k] = AtlasEntry(v['w'], v['h'], v['sx'], v['sy'], v['tx'], v['ty'], v['l'], v['t'], v['hb'])

            return atlas, data

    except IOError:
        pass

    return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号