【问题标题】:outWidth and outHeight are 0 in BitmapFactory.Options for image files from FTP server来自 FTP 服务器的图像文件的 BitmapFactory.Options 中的 outWidth 和 outHeight 为 0
【发布时间】:2013-09-28 13:23:57
【问题描述】:
String imageFilePath = "ftp://hostname/dir/imagefilename.jpg";
BitmapFactory.Options options = new BitmapFactory.Options;
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(imageFilePath, options);
int height = options.outHeight;
int width = options.outWidth;

heightwidth 始终是0

我也尝试设置inJustDecodeBounds = false,但decodeFile 方法仍然返回null

当我将 imageFilePath 设置为本地图像文件时,它对来自普通 http 网站的文件再次不起作用

对于那些想知道如何连接到 FTP 服务器的人,它已成功连接和验证,甚至我也正确地使用 FTPClient.listFiles()FTPClient.listNames() 获取所有图像文件及其名称。

【问题讨论】:

    标签: android ftp decode ftp-client bitmapfactory


    【解决方案1】:

    文件路径是一个语言环境文件,而不是托管在外部文件服务器上的文件。您需要自己下载文件,或者使用 Universal Image Loader 或 Picasso 等库。虽然我不知道他们与 ftp 的工作情况如何(如果)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-05
      • 1970-01-01
      相关资源
      最近更新 更多