您当前的位置: 首页 > 

宴西笔记

暂无认证

  • 3浏览

    0关注

    87博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Auto.js 显示GIF图片

宴西笔记 发布时间:2022-01-20 06:45:44 ,浏览量:3

来源于群文件

"ui";
//GIF图片路径
var path="/storage/emulated/0/Pictures/Browser/img.mp.itc.gif";
ui.layout(
    
        
    
);
var movie=new android.graphics.Movie.decodeFile(path);
log(movie)
var ji=0;
var duration=movie.duration();
log(duration);


var wad=new 绘布(ui.img);

wad.setDraw(function(canvas){
    var w = canvas.getWidth();
    var h = canvas.getHeight();
    movie.setTime(Math.floor(ji*20%duration));
    ji++;
    movie.draw(canvas,0,0);
});



function 绘布(view) {
    if (view.accessibilityClassName != "android.widget.ImageView") {
        throw "我报错";
    };
    this.width = view.getWidth();
    this.height = view.getHeight();
    this.matrix = new android.graphics.Matrix();
    this.bitmap = android.graphics.Bitmap.createBitmap(this.width || 1, this.height || 1, android.graphics.Bitmap.Config.ARGB_8888);
    this.canvas = new android.graphics.Canvas(this.bitmap);
    setInterval(() => {
        if (view.getWidth() != this.width || view.getHeight() != this.height) {
            this.width = view.getWidth();
            this.height = view.getHeight();
            this.bitmap = android.graphics.Bitmap.createBitmap(this.width || 1, this.height || 1, android.graphics.Bitmap.Config.ARGB_8888);
            this.canvas = new android.graphics.Canvas(this.bitmap);
        };
    }, 500);
    this.Draw = function() {};
    this.setDraw = function(fun) {
        if (typeof fun == "function") {
            this.Draw = fun;
        };
    };
    setInterval(() => {
        try {
            this.bitmap.eraseColor(0);
            this.canvas.setMatrix(this.matrix);
            this.Draw(this.canvas);
            ui.run(() => {
                view.setImageBitmap(this.bitmap);
            });
        } catch (e) {
            toastLog(e);
        };
    }, 50);
};
关注
打赏
1660715546
查看更多评论
立即登录/注册

微信扫码登录

0.1020s