我正在显示CameraView
并TextureView
正在使用TextureView.getBitmap()
从TextureView
.
每次我调用TextureView.getBitmap()
它都会导致相机预览冻结一纳秒。我想在后台运行这个任务。
谢谢
这是我尝试过的代码:
findViewById(R.id.capture).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Bitmap bmp = mTextureView.getBitmap();
rev = new ArrayList<Bitmap>();
rev.add(bmp);
Toast.makeText(getApplicationContext(),""+ rev.size(), Toast.LENGTH_LONG).show();
}
});
这是我的 Logcat
08-22 03:59:57.867: E/AndroidRuntime(4859): FATAL EXCEPTION: main
08-22 03:59:57.867: E/AndroidRuntime(4859): java.lang.NullPointerException
08-22 03:59:57.867: E/AndroidRuntime(4859): at com.example.hangout_gif_camera.MainActivity$1.onClick(MainActivity.java:41)
08-22 03:59:57.867: E/AndroidRuntime(4859): at android.view.View.performClick(View.java:4211)
08-22 03:59:57.867: E/AndroidRuntime(4859): at android.view.View$PerformClick.run(View.java:17446)
08-22 03:59:57.867: E/AndroidRuntime(4859): at android.os.Handler.handleCallback(Handler.java:725)
08-22 03:59:57.867: E/AndroidRuntime(4859): at android.os.Handler.dispatchMessage(Handler.java:92)
08-22 03:59:57.867: E/AndroidRuntime(4859): at android.os.Looper.loop(Looper.java:153)
08-22 03:59:57.867: E/AndroidRuntime(4859): at android.app.ActivityThread.main(ActivityThread.java:5297)
08-22 03:59:57.867: E/AndroidRuntime(4859): at java.lang.reflect.Method.invokeNative(Native Method)
08-22 03:59:57.867: E/AndroidRuntime(4859): at java.lang.reflect.Method.invoke(Method.java:511)
08-22 03:59:57.867: E/AndroidRuntime(4859): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
08-22 03:59:57.867: E/AndroidRuntime(4859): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
08-22 03:59:57.867: E/AndroidRuntime(4859): at dalvik.system.NativeStart.main(Native Method)