获取图片所有像素点颜色!!!!!!!!!! cocos creator

https://zhuanlan.zhihu.com/p/30938992

2赞

哥.这个方式是通过jsbinding?

你试试通过断点一个spriteFrame去看看最底层数据表现

因为现在想通过jsb的方式去做的,但是现在jsb绑定过程中出了点问题
Fatal error in parsing headers

哥,可以说的详细点么

jsb 方式也可通过 glReadPixels 而且引擎有做绑定,CCImage 引擎有做部分绑定的,貌似没有处理getData,要看下源码

2.0.2测试通过:

const {ccclass, property} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
    @property({type: cc.Texture2D})
    texture: cc.Texture2D = null;
    start () {
        let rt = new cc.RenderTexture();
        rt.initWithSize(this.texture.width, this.texture.height);
        rt.drawTextureAt(this.texture, 0, 0);
        // data就是这个texture的rgba值数组
        let data = rt.readPixels();
        console.log(data);
    }
}

6赞

mark

mark

mark

你这个是通过截图的方式实现的吗~大佬

mark是什么意思

mark

mark

微信中不能使用drawTextureAt,有什么替代的好方法吗

mark

兄弟,我这2.4.3在web平台读不到数据

感谢!!!

1赞

原生平台并不能用 drawTextureAt