http://www.devdaily.com/java/jwarehouse/android-examples/platforms/android-2/samples/ApiDemos/src/com/example/android/apis/graphics/CameraPreview.java.shtml
的 example 比 google 的
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/CameraPreview.html
簡單.
但是有點問題,所以改一下,source code 放在 github
https://github.com/checko/CameraPreview
大概就是
- try catch on setDisplaySize
- 加上 Camera.release( ) , 這樣 overlay 才會 call V4L_STREAM_OFF. -- 下次啟動才不會有 exception.
About Camera Preview :
簡單的說,就是原來 的, onCreate( ),設定 application Content View 的 code,改為把 CameraPreview 的 Surface 設為 Content View:
mPreview = new Preview(this);
setContentView(mPreview);
Preview 這個 class, 負責 包裝 camera,和 output.:class Preview extends SurfaceView implements SurfaceHolder.Callback {
繼承 SurfaceView, 所以可以被設為 application Context View.然後把 Camera 的控制加在 class 生成,與 View 的 eventHandler 中。
ref
- http://marakana.com/forums/android/examples/39.html
- http://stackoverflow.com/questions/6668120/how-can-i-get-a-camera-preview-on-a-surfaceholder-in-portrait-mode
- http://www.brighthub.com/mobile/google-android/articles/43414.aspx
- http://www.tomgibara.com/android/camera-source
- http://www.devx.com/wireless/Article/42482/1954
- http://www.41post.com/3470/programming/android-retrieving-the-camera-preview-as-a-pixel-array
沒有留言:
張貼留言