【问题标题】:Bitmap myBitmap = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length); gives dimension 0位图 myBitmap = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);给出维度 0
【发布时间】:2014-03-25 05:41:17
【问题描述】:

我正在尝试使用 BitmapFactory 解码位图,但它给我的输出位图的高度和宽度等于 0。可以帮帮我。我的代码如下。

 Bitmap myBitmap = BitmapFactory.decodeByteArray(bFile, 0, bFile.length);
 System.out.println("heigth => "myBitmap.getHeight() + "  width  => " + myBitmap.getWidth());

其中 bFile 是从 .ico 文件生成的字节数组。

提前致谢!!!

【问题讨论】:

标签: java android android-layout bitmap android-bitmap


【解决方案1】:

尝试如下操作

BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile("/sdcard/image.png", options);
int width = options.outWidth;
int height = options.outHeight;

【讨论】:

  • 不走运 Jitesh 。仍然它给一角钱为 0。我要读取的图像文件是 .ico 文件。我更新了问题。
猜你喜欢
  • 2016-03-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-09
相关资源
最近更新 更多