读取大图片内存溢出的问题。

summersrest 2014-07-22 11:41:07
服务器端给出的图片大小不确定,有可能非常大。我要想缩小至屏幕大小来显示,这样能节省内存的开销,但是缩放的比例却不好确定,有什么办法呢?
...全文
223 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
lionfresh 2014-07-22
  • 打赏
  • 举报
回复
引用 2 楼 Trent1985 的回复:
[quote=引用 1 楼 summersrest 的回复:] 比如,不读入内存如何获取到该图片的长度及宽度呢?
BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; Bitmap bitmap = BitmapFactory.decodeFile("/sdcard/test.jpg", options); Log.e("Test", "Bitmap Height == " + options.outHeight); [/quote] right
Trent1985 2014-07-22
  • 打赏
  • 举报
回复
引用 1 楼 summersrest 的回复:
比如,不读入内存如何获取到该图片的长度及宽度呢?
BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; Bitmap bitmap = BitmapFactory.decodeFile("/sdcard/test.jpg", options); Log.e("Test", "Bitmap Height == " + options.outHeight);
summersrest 2014-07-22
  • 打赏
  • 举报
回复
比如,不读入内存如何获取到该图片的长度及宽度呢?
summersrest 2014-07-22
  • 打赏
  • 举报
回复
引用 5 楼 Trent1985 的回复:
[quote=引用 4 楼 summersrest 的回复:] [quote=引用 2 楼 Trent1985 的回复:] [quote=引用 1 楼 summersrest 的回复:] 比如,不读入内存如何获取到该图片的长度及宽度呢?
BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; Bitmap bitmap = BitmapFactory.decodeFile("/sdcard/test.jpg", options); Log.e("Test", "Bitmap Height == " + options.outHeight); [/quote] 这样是不是相当于已经将bitmap读入内存了?下面我想获取bitmap的宽高的时候是不是这样写? int width = bitmap.getwidth();[/quote]当然不行,bitmap现在是null,必须使用options.outWidth等[/quote] 卧槽,我结贴的时候好像点错了, 对不起啊。
summersrest 2014-07-22
  • 打赏
  • 举报
回复
引用 5 楼 Trent1985 的回复:
[quote=引用 4 楼 summersrest 的回复:] [quote=引用 2 楼 Trent1985 的回复:] [quote=引用 1 楼 summersrest 的回复:] 比如,不读入内存如何获取到该图片的长度及宽度呢?
BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; Bitmap bitmap = BitmapFactory.decodeFile("/sdcard/test.jpg", options); Log.e("Test", "Bitmap Height == " + options.outHeight); [/quote] 这样是不是相当于已经将bitmap读入内存了?下面我想获取bitmap的宽高的时候是不是这样写? int width = bitmap.getwidth();[/quote]当然不行,bitmap现在是null,必须使用options.outWidth等[/quote] OK,结贴
Trent1985 2014-07-22
  • 打赏
  • 举报
回复
引用 4 楼 summersrest 的回复:
[quote=引用 2 楼 Trent1985 的回复:] [quote=引用 1 楼 summersrest 的回复:] 比如,不读入内存如何获取到该图片的长度及宽度呢?
BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; Bitmap bitmap = BitmapFactory.decodeFile("/sdcard/test.jpg", options); Log.e("Test", "Bitmap Height == " + options.outHeight); [/quote] 这样是不是相当于已经将bitmap读入内存了?下面我想获取bitmap的宽高的时候是不是这样写? int width = bitmap.getwidth();[/quote]当然不行,bitmap现在是null,必须使用options.outWidth等
summersrest 2014-07-22
  • 打赏
  • 举报
回复
引用 2 楼 Trent1985 的回复:
[quote=引用 1 楼 summersrest 的回复:] 比如,不读入内存如何获取到该图片的长度及宽度呢?
BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; Bitmap bitmap = BitmapFactory.decodeFile("/sdcard/test.jpg", options); Log.e("Test", "Bitmap Height == " + options.outHeight); [/quote] 这样是不是相当于已经将bitmap读入内存了?下面我想获取bitmap的宽高的时候是不是这样写? int width = bitmap.getwidth();

80,352

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧