Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Android中显示连续图像_Android_Video_Bitmap - Fatal编程技术网

在Android中显示连续图像

在Android中显示连续图像,android,video,bitmap,Android,Video,Bitmap,我想在一秒钟内显示大约30张照片,这样它们就会像视频一样显示 我在while(TRUE)循环中使用了Android ImageView,但ImageView并没有像我预期的那样改变 ImageView每秒更改图片约一次,因此想知道是否有其他方法可以更改图片 展示我的照片 这些照片是使用Udp从相机传输的,我首先需要将其存储在缓冲区中,然后 而不是展示 上述部分会导致ImageView延迟 部分代码如下所示 public void receiveVideoRawData() throws IO

我想在一秒钟内显示大约30张照片,这样它们就会像视频一样显示

我在while(TRUE)循环中使用了Android ImageView,但ImageView并没有像我预期的那样改变

ImageView每秒更改图片约一次,因此想知道是否有其他方法可以更改图片

展示我的照片

这些照片是使用Udp从相机传输的,我首先需要将其存储在缓冲区中,然后

而不是展示

上述部分会导致ImageView延迟

部分代码如下所示

  public void receiveVideoRawData() throws IOException{
        socket_video = new DatagramSocket();
        byte[] buf_rcv = new byte[153600];
        DatagramPacket rawData = new DatagramPacket(buf_rcv, buf_rcv.length);
        Bitmap  image = null;
        socket_video.receive(rawData);//receive a raw data
        image = readMyRawData.readUINT_RGBImage(buf_rcv);//decode the raw data
        ByteArrayOutputStream blob = new ByteArrayOutputStream();
        Bitmap pBitmap = image ;
        pBitmap.compress(Bitmap.CompressFormat.JPEG, 1, blob);
        byte[] bitmapdata = blob.toByteArray();
        ardrone_Frame = BitmapFactory.decodeByteArray(bitmapdata , 0, bitmapdata.length);
      }
显示部件

  Thread thread=new Thread  (new Runnable() {
     Message message;
    String obj="run";
    int i;
    long start;
    @Override
    public void run() {   
        // TODO Auto-generated method stub
         Log.e("///enter thread ","THREAD");
    while(true){     
        try { 
            Log.e("enter_video_thread","enter_video_thread");
            receiveVideoRawData();
            Log.e("///receiveVideoRawData ","receiveVideoRawData");
            message = handler.obtainMessage(1,obj);
                    handler.sendMessage(message);
            }

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }   
    }
}

});
public Handler handler = new Handler(){ 
    @Override
    public void handleMessage(Message msg) {
            super.handleMessage(msg);
            String MsgString = (String)msg.obj;
            if (MsgString.equals("run"))
            {         Log.e("///enter handler ","HANDLER");                                           
                          Toast.makeText(ArDroneMain.this,"save image ",Toast.LENGTH_SHORT).show();
                          //Bitmap bitmap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory()+ "/ArdroneVideo.jpg");
                          myImageView.setImageBitmap(ardrone_Frame);    ///Show the image    
                          Toast.makeText(ArDroneMain.this,"show image",Toast.LENGTH_SHORT).show();
             }

    }
};

您可以始终使用ffmpeg创建图像的视频,也可以使用timertask

delay=1000/totalImages;

myTimer = new Timer();
        myTimer.schedule(new TimerTask() {          
            @Override
            public void run() {

                            if(count==imgArr.length)
                              cancel();

                            imageView.setImageResource(imgArr[count]);
                            count++;    

            }

        }, 0, delay);

您可以始终使用ffmpeg创建图像的视频,也可以使用timertask

delay=1000/totalImages;

myTimer = new Timer();
        myTimer.schedule(new TimerTask() {          
            @Override
            public void run() {

                            if(count==imgArr.length)
                              cancel();

                            imageView.setImageResource(imgArr[count]);
                            count++;    

            }

        }, 0, delay);

你可以这样做,我把它制作成动画。 为动画制作图像并以png格式保存在文件夹中。 使用下面的代码设置这些图像的动画

<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true">
 <item android:drawable="@drawable/rocket_thrust1" android:duration="200" />
 <item android:drawable="@drawable/rocket_thrust2" android:duration="200" />
 <item android:drawable="@drawable/rocket_thrust3" android:duration="200" />
 </animation-list>

你可以这样做,我把它制作成动画。 为动画制作图像并以png格式保存在文件夹中。 使用下面的代码设置这些图像的动画

<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true">
 <item android:drawable="@drawable/rocket_thrust1" android:duration="200" />
 <item android:drawable="@drawable/rocket_thrust2" android:duration="200" />
 <item android:drawable="@drawable/rocket_thrust3" android:duration="200" />
 </animation-list>

是否要动态加载图像?还是存储在res中?设置每个图像后,需要重新绘制
ImageView
。您能显示当前使用的代码吗?是否要动态加载图像?还是存储在res中?设置每个图像后,需要重新绘制
ImageView
。您可以显示当前使用的代码吗?如果出现错误,则只有创建视图层次结构的原始线程才能触摸其视图设置错误,则只有创建视图层次结构的原始线程才能触摸其视图