Han*_*non 30
您可以使用inJustDecodeBounds设置BitmapFactory.Options以获取图像宽度和高度,而无需在内存中加载位图像素
BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();
bitmapOptions.inJustDecodeBounds = true;
BitmapFactory.decodeStream(inputStream, null, bitmapOptions);
int imageWidth = bitmapOptions.outWidth;
int imageHeight = bitmapOptions.outHeight;
inputStream.close();
Run Code Online (Sandbox Code Playgroud)
更多细节:
public boolean inJustDecodeBounds
从以下版本开始:API Level 1如果设置为true,解码器将返回null(无位图),但out ...字段仍将设置,允许调用者查询位图而无需为其像素分配内存.
| 归档时间: |
|
| 查看次数: |
14846 次 |
| 最近记录: |