【问题标题】:Cannot display full size image in ImagePreview无法在 ImagePreview 中显示全尺寸图像
【发布时间】:2013-10-18 12:47:39
【问题描述】:

我最近修改了我的相机以捕获和显示全尺寸图像,Galaxy Nexus 上的尺寸为 2592 X 1944。我在捕获图像并在预览中显示时尝试使用 LruCache。图像应该放在哪里一直有空白。我的 LogCat 上的先前条目告诉我图像已保存。

如何才能显示完整尺寸的图像?

图片大小通过以下方式获得:

    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)

【问题讨论】:

    标签: bitmap android-camera android-lru-cache


    【解决方案1】:

    这个问题的答案与相机的实现无关,你应该将图像缩小到小于2048x2048再显示。

    【讨论】:

      猜你喜欢
      • 2014-11-19
      • 1970-01-01
      • 1970-01-01
      • 2010-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多