2011-08-28 69 views
1

我开发一个应用程序,显示大图像..有大量的图像大小在700x8100左右..我可以创建一个EncodedImage类型的对象,而不会抛出异常,但是当我尝试执行getBitmap我收到一个OutOfMemory错误。 这是发生异常的行:Blackberry - OutOfMemory当处理大图像

Bitmap imgBtm = encodedImagePng.getBitmap(); 

有什么样的分辨率大小的限制?

有没有人已经不得不处理大图片?

任何帮助将是非常有用的..

韩国社交协会

回答

1

您必须在使用getBitmap()函数之前调整编码图像的大小。首先构建你的EncodedImage,然后使用重新调整了下列文件:

private static EncodedImage rescaleEncodedImage (EncodedImage image, int width, int height) { 
     EncodedImage result = null; 
     try { 
      int currentWidthFixed32 = Fixed32.toFP(image.getWidth()); 
      int currentHeightFixed32 = Fixed32.toFP(image.getHeight()); 
      int requiredWidthFixed32 = Fixed32.toFP(width); 
      int requiredHeightFixed32 = Fixed32.toFP(height); 
      int scaleXFixed32 = Fixed32.div(currentWidthFixed32, requiredWidthFixed32); 
      int scaleYFixed32 = Fixed32.div(currentHeightFixed32, requiredHeightFixed32); 
      result = image.scaleImage32(scaleXFixed32, scaleYFixed32); 
     } 
     catch (Exception ex) { 

     } 
     return result; 
    } 

然后调整从它

得到位图后
0

您无法读取如此大到设备内存中的图像。有一些内置的方法可以在缩小图像的同时解码图像,从而避免将原始图像加载到内存中。在获取位图之前,尝试使用EncodedImage.scaleImage32来设置更合理的维度。