1

我的程序是解码位图并显示它。

原始解码代码和显示代码在我的电脑上完美运行。

当我在我的 android 设备中使用代码时,代码也可以解码流。

问题是 ImageView 中的图像显示效率不高。

下面是我的代码的一部分

我使用一个线程来调用解码函数,而不是在 ImageView 上显示它

class ProcessData extends Thread{
    Message message;
        String obj="run";
        ReadRawFileImage readMyRawData=new ReadRawFileImage();


    public void run() { 

           Log.e("///enter ProcessData thread ","ProcessData thread");   
        while(true){
        Bitmap image=Bitmap.createBitmap (320, 240, Bitmap.Config.RGB_565);
                    image.setPixels(pixelData,0,320 ,0 ,0,320,240);
        message = handler.obtainMessage(1,obj);
        handler.sendMessage(message);
            }  

public Handler handler = new Handler(){ 


    @SuppressLint("NewApi")
    @Override
    public void handleMessage(Message msg) {
            super.handleMessage(msg);           
            String MsgString = (String)msg.obj;

            if (MsgString.equals("run"))
            {             Log.e("///enter handler ","setImageBitmap");                                                                                                   
                          myImageView.setImageBitmap(image);

            }


    }
};

日志猫

   05-21 20:11:44.845: E/1(7267): 1
   05-21 20:11:44.845: E/ProcessData thread(7267): ProcessData thread
   05-21 20:11:44.845: E////enter handler(7267): setImageBitmap
   05-21 20:11:44.855: D/dalvikvm(7267): GC_CONCURRENT freed 1K, 22% free 10613K/13575K, paused 12ms+2ms, total 34ms
   05-21 20:11:44.855: D/dalvikvm(7267): WAIT_FOR_CONCURRENT_GC blocked 8ms
   05-21 20:11:44.915: D/dalvikvm(7267): GC_CONCURRENT freed 895K, 25% free 10225K/13575K, paused 13ms+6ms, total 39ms
   05-21 20:11:44.980: D/dalvikvm(7267): GC_CONCURRENT freed 439K, 25% free 10298K/13575K, paused 2ms+4ms, total 35ms
   05-21 20:11:44.980: D/dalvikvm(7267): WAIT_FOR_CONCURRENT_GC blocked 22ms
   05-21 20:11:45.030: D/dalvikvm(7267): GC_CONCURRENT freed 473K, 24% free 10337K/13575K, paused 1ms+4ms, total 26ms
   05-21 20:11:45.030: D/dalvikvm(7267): WAIT_FOR_CONCURRENT_GC blocked 18ms
   05-21 20:11:45.095: D/dalvikvm(7267): GC_CONCURRENT freed 467K, 24% free 10382K/13575K, paused 2ms+2ms, total 46ms
   05-21 20:11:45.100: D/dalvikvm(7267): WAIT_FOR_CONCURRENT_GC blocked 41ms
   05-21 20:11:45.185: D/dalvikvm(7267): GC_CONCURRENT freed 450K, 24% free 10443K/13575K, paused 12ms+5ms, total 55ms
   05-21 20:11:45.185: D/dalvikvm(7267): WAIT_FOR_CONCURRENT_GC blocked 29ms
   05-21 20:11:45.255: D/dalvikvm(7267): GC_CONCURRENT freed 469K, 23% free 10486K/13575K, paused 12ms+5ms, total 48ms
   05-21 20:11:45.255: D/dalvikvm(7267): WAIT_FOR_CONCURRENT_GC blocked 27ms
   05-21 20:11:45.320: D/dalvikvm(7267): GC_CONCURRENT freed 455K, 23% free 10542K/13575K, paused 12ms+5ms, total 48ms
   05-21 20:11:45.320: D/dalvikvm(7267): WAIT_FOR_CONCURRENT_GC blocked 22ms
   05-21 20:11:45.395: D/dalvikvm(7267): GC_CONCURRENT freed 448K, 22% free 10605K/13575K, paused 11ms+5ms, total 50ms
   05-21 20:11:45.395: D/dalvikvm(7267): WAIT_FOR_CONCURRENT_GC blocked 25ms

.....................

然后再次设置我的位图!

然后显示10605K/13575K的那种,停顿11ms+5ms,总共50ms再来一次~~

4

1 回答 1

1

ImageView不是为视频预览而构建的。而且您也不会Bitmap在实时应用程序中动态创建 's。

使用SurfaceView,TextureViewSurfaceTexture渲染相机帧。

于 2013-05-21T12:58:42.830 回答