电影在画布上绘制时

电影在画布上绘制时

本文介绍了电影在画布上绘制时,Android错误信号11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Android应用程序,试图在其中显示GIF图像。
为此,我正在使用Movie类,并创建了一个GIFView类来扩展View。我从Movie.decodeFile方法获取一个Movie实例。

I'm developing an Android application in which I'm trying to display a GIF image.For that I am using the Movie class and created a class GIFView that extends View. I getting a Movie instance from Movie.decodeFile method.

调用Movie.draw(canvas)时出现错误。

I am getting an error when Movie.draw(canvas) is called.

04-28 13:44:18.001: A/libc(24883): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 24883 (mple.channel002)

有相关代码:

    public void setGif(File gif)
    {
        movie = Movie.decodeFile(gif.getAbsolutePath());
    }

    @Override
    public void draw(Canvas canvas) {
        // TODO Auto-generated method stub
        super.draw(canvas);
        canvas.drawColor(0xFFCC3C6C);

        if(movie != null)
        {
            if(movieStart == 0)
                movieStart = android.os.SystemClock.uptimeMillis();
            int duration = Math.max(movie.duration(), 1000);
            movie.setTime((int)(duration - ((android.os.SystemClock.uptimeMillis() - movieStart)%duration)));

            movie.draw(canvas, 10, 10);//TODO CRASH

            invalidate();
        }
    }

我在主方法中创建了一个GIFView,调用setGIF方法上面提供路径,并使用FillParent参数将其添加到布局中。
当我在ImageView中打印此图像时,它可以工作。
也可以在画布上绘制可绘制对象而不是GIF。
所以问题似乎与Movie实例有关。

I create a GIFView in the main, call setGIF method above to give it the path and add it to the layout with FillParent parameter.It works when I print this image in an ImageView.Drawing a drawable in the canvas instead of the GIF works too.So the problem seems to deals with the Movie instance.

我使用了这些链接来制作GIFView

I used these links to make the GIFViewhttp://weavora.com/blog/2012/02/07/android-and-how-to-use-animated-gifs/

我也尝试过这种方法,但是movie.draw $ b $出现了相同的错误b

I also tried it this way but same error on movie.drawInfo about the Movie class for Android

编辑1:
我在Android 4.4.2 / snapdragon 801 / 2GB上的Oppo Find 7a上进行测试更改movie.draw(canvas,10,10)为movie.draw(canvas,10f,10f)不变。

I do my tests on an Oppo Find 7a on Android 4.4.2 / snapdragon 801 / 2GBChanging movie.draw(canvas, 10, 10) to movie.draw(canvas, 10f, 10f) doesn't change anything.

EDIT2:
我刚刚在装有Android的旧ZTE设备上进行了测试2.3.5并有效。.
在Find7a设备上启动时出了点问题,但我不知道是什么:(

推荐答案

最后,我发现了
答案似乎是在某些Android版本或设备上需要禁用硬件加速。

我刚刚将此添加到清单中:

FINALLY!I found the answer, it appears that on some Android version or devices hardware acceleration needs to be disabled.
I just added this this to my manifest:

<application android:hardwareAccelerated="true" ...>

有关使用启用/禁用硬件加速的更多信息,请参见。

More information on using enabling/disabling hardware acceleration can be found here.

这篇关于电影在画布上绘制时,Android错误信号11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 13:21