2013-10-18 54 views
0

我最近修改了我的相機以捕獲並顯示全尺寸圖像,Galaxy Nexus上的尺寸爲2592 X 1944.我嘗試在捕獲圖像並在其中顯示時使用LruCache預覽。如果圖像應該有空白空間。我的LogCat上的一個條目告訴我圖像已被保存。無法在ImagePreview中顯示完整尺寸的圖像

如何獲取全尺寸圖像以顯示?

private Size getDesiredPictureSize(Parameters params) 
{ 
    //Resolution is widthxheight 
    Size result=null; 
    //boolean isDesiredValue=false; 
    final int minArea=500*500; 
    final int maxArea=1000*1000; 
    List<Size> supportedSizeList=params.getSupportedPictureSizes(); 
    for(Size size:supportedSizeList) 
    { 
      if(result==null) 
       result=size; 
      else 
      { 
       int resultArea=result.width*result.height; 
       int sizeArea=size.width*size.height; 
       if(resultArea<sizeArea) 
       { 
        result=size; 
        Log.d("CameraPreview", "Result pictureSize has been set to "+result.width+"X"+result.height); 
       } 
      } 
     } 
    Log.d("CameraPreview", "Picture size has been set to "+result.width+"X"+result.height); 

    return result; 
} 

的logcat中顯示以下時,圖像必須顯示預覽::

使用所獲得的圖像尺寸

FATAL EXCEPTION: main 
     java.lang.OutOfMemoryError 
     at android.graphics.Bitmap.nativeCopy(Native Method) 
    at android.graphics.Bitmap.copy(Bitmap.java:450) 
    at com.example.newscancardapp.ImagePreviewActivity.onCreate(ImagePreviewActivity.java:58) 
    at android.app.Activity.performCreate(Activity.java:5133) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261) 
    at android.app.ActivityThread.access$600(ActivityThread.java:141) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 
    at android.os.Handler.dispatchMessage(Handler.java:99) 
    at android.os.Looper.loop(Looper.java:137) 
    at android.app.ActivityThread.main(ActivityThread.java:5103) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:525) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
    at dalvik.system.NativeStart.main(Native Method) 

回答

0

的這個問題的答案是不相關的執行在顯示相機之前,您應該將圖像縮小到小於2048x2048。