0
我有拍照的相機應用程序。我的問題是,當我拍攝240 * 320的照片時,我的相機可以拍攝高清照片。我怎樣才能拍攝高質量的照片?我試試這個代碼:在Android中支持高支持的圖片尺寸
public void GetHighResolutionForCamera(){
int Max = 0;
Camera.Size MR = null ;
Parameters params = mCamera.getParameters();
List<Camera.Size> resolution ;
resolution = params.getSupportedPictureSizes();
for (Camera.Size size : resolution) {
if(Max < size.height){
MR = size ;
Max = size.height;
}
}
params.setPictureSize(MR.width, MR.height);
mCamera.setParameters(params);
}
但我試圖設置參數時出錯。這與表面視圖有關嗎?當我可以設置參數到我的相機?
這是logcat的:
08-21 22:21:27.442: D/AndroidRuntime(27812): Shutting down VM
08-21 22:21:27.442: W/dalvikvm(27812): threadid=1: thread exiting with uncaught exception (group=0x41a5e700)
08-21 22:21:27.458: E/AndroidRuntime(27812): FATAL EXCEPTION: main
08-21 22:21:27.458: E/AndroidRuntime(27812): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mytackpicture/com.example.mytackpicture.MainActivity}: java.lang.NullPointerException
08-21 22:21:27.458: E/AndroidRuntime(27812): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
08-21 22:21:27.458: E/AndroidRuntime(27812): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
08-21 22:21:27.458: E/AndroidRuntime(27812): at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-21 22:21:27.458: E/AndroidRuntime(27812): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
08-21 22:21:27.458: E/AndroidRuntime(27812): at android.os.Handler.dispatchMessage(Handler.java:99)
08-21 22:21:27.458: E/AndroidRuntime(27812): at android.os.Looper.loop(Looper.java:137)
08-21 22:21:27.458: E/AndroidRuntime(27812): at android.app.ActivityThread.main(ActivityThread.java:5103)
08-21 22:21:27.458: E/AndroidRuntime(27812): at java.lang.reflect.Method.invokeNative(Native Method)
08-21 22:21:27.458: E/AndroidRuntime(27812): at java.lang.reflect.Method.invoke(Method.java:525)
08-21 22:21:27.458: E/AndroidRuntime(27812): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-21 22:21:27.458: E/AndroidRuntime(27812): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-21 22:21:27.458: E/AndroidRuntime(27812): at dalvik.system.NativeStart.main(Native Method)
08-21 22:21:27.458: E/AndroidRuntime(27812): Caused by: java.lang.NullPointerException
08-21 22:21:27.458: E/AndroidRuntime(27812): at com.example.mytackpicture.MainActivity.GetHighResolutionForCamera(MainActivity.java:63)
08-21 22:21:27.458: E/AndroidRuntime(27812): at com.example.mytackpicture.MainActivity.onCreate(MainActivity.java:57)
08-21 22:21:27.458: E/AndroidRuntime(27812): at android.app.Activity.performCreate(Activity.java:5133)
08-21 22:21:27.458: E/AndroidRuntime(27812): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-21 22:21:27.458: E/AndroidRuntime(27812): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
08-21 22:21:27.458: E/AndroidRuntime(27812): ... 11 more
你什麼錯誤? Logcat輸出將非常有用。 – Geobits
感謝您的回覆。已更新 –
什麼是第63行? 'mCamera'爲空嗎? – Geobits