动态壁纸与图片 [英] live wallpaper with images

查看:142
本文介绍了动态壁纸与图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(对不起,我Englih也不是那么好......希望你能明白我的意思)

(sorry for my Englih is not so good... hope you will understand me)

我的朋友是一个很好的抽屉里。我想帮他要知道作为一个良好的抽屉,使他一个动态壁纸动画与他的画。

My friend is a really good drawer. I would like to help him to be know as a good drawer by making him a live wallpaper animated with his drawings.

我想他画几帧,并使用这些帧通过显示他们一个接一个,使一个动态壁纸。

I would like him to draw few frames and use these frames to make a live wallpaper by displaying them one after the other.

我挣扎了这么多,显示一张图片,然后稍等一下,并显示下一个。我敢肯定,我不能成功做到这一点,因为我不使用正确的方法...

I'm struggling so much to display one picture then wait a bit and display the next one. I'm quite sure that I can't succeed to do it because I don't use the right approach...

这是我做了什么至今:

public class Cercle extends WallpaperService
{
public void onCreate() 
{
    super.onCreate();
}

public void onDestroy() 
{
    super.onDestroy();
}

public Engine onCreateEngine() 
{
    return new CercleEngine();
}

class CercleEngine extends Engine 
{
    public Bitmap image1, image2, image3;

    CercleEngine() 
    {       
        image1 = BitmapFactory.decodeResource(getResources(), R.drawable.img1);
        image2 = BitmapFactory.decodeResource(getResources(), R.drawable.img2);
        image3 = BitmapFactory.decodeResource(getResources(), R.drawable.img3); 
    }

    public void onCreate(SurfaceHolder surfaceHolder) 
    {
        super.onCreate(surfaceHolder);
    }

    public void onOffsetsChanged(float xOffset, float yOffset, float xStep, float yStep, int xPixels, int yPixels) 
    {
        drawFrame();
    }

    void drawFrame() 
    {
        final SurfaceHolder holder = getSurfaceHolder();

        Canvas c = null;
        try 
        {
            c = holder.lockCanvas();
            if (c != null) 
            {              
                 c.drawBitmap(image1, 0, 0, null);
                 c.drawBitmap(image2, 0, 0, null);
                 c.drawBitmap(image3, 0, 0, null);                   
            }
        } finally 
        {
            if (c != null) holder.unlockCanvasAndPost(c);
        }
    }
}
}

这code只显示图片的速度太快,因为我不知道该怎么diplaying照片之间的等待...

This code just display the pictures too quickly because I don't know how to wait between diplaying pictures...

任何人都可以给我一些建议或者告诉我的另一种解决方案的一些例子吗?

Can anyone give me some tips or show me some example of another solution ?

太感谢了!

更新:

我得到了我的问题,通过增加解决一个Runnable:

I got my problem resolved by adding a Runnable :

private final Runnable drawRunner = new Runnable() 
    {
        @Override
        public void run() {
            drawFrame();
        }

    };

,然后通过添加:

and then by adding :

    handler.removeCallbacks(drawRunner);
        if (visible) 
        {
           handler.postDelayed(drawRunner, 1000); // delay 1 sec
        }

在并条机()的结束

at the end of drawFrame().

希望这会帮助别人。

推荐答案

使用这个开源项目,共创美好生活壁纸为你的朋友

use this open source project to create nice live wallpaper for your friend

该链接是从手机图库阅读,您可以编辑从阅读文件夹中的项目公关只是用,因为它是。

link it is read from phone gallery, you can edit it to read from folder in the project pr just use as it is.

或使用该链接其他活的壁纸项目

or use this link for other live wallpaper project

这篇关于动态壁纸与图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆