我从API获取Image作为BLOB类型.而且,我保存如下,
public static void setOptimalImage(Context ctx, File file, ImageView iv,
Point size) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(file.getPath(), options);
if (options.outHeight > 0 && options.outWidth > 0) {
if (size == null) {
size = new Point();
WindowManager wm = (WindowManager) ctx
.getSystemService(Context.WINDOW_SERVICE);
wm.getDefaultDisplay().getSize(size);
}
options.inSampleSize = Utils.calculateInSampleSize(options, size.x,
size.y);
options.inJustDecodeBounds = false;
try {
iv.setImageBitmap(BitmapFactory.decodeFile(file.getPath(),
options));
} catch (OutOfMemoryError oome) {
Log.e(Utils.class.getName(),
oome.getMessage() == null ? "OutOfMemory error: "
+ file.getName() : oome.getMessage());
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我面临的问题是,
当我保存它时,有时图像只能保存一半.现在,我的问题是,
编辑:
任何帮助将非常感激.
谢谢.
附加图片供参考:

我认为您正在研究检测损坏图像的错误方向。使用 API 和请求来管理加载(或半加载)的位图会很容易。您还可以拥有一个文件(甚至更好是一个数据库),其中包含有关下载图像的信息。
我看到多个检查,“图像是否已下载?” :
在显示期间,您可以检测哪些图像已完全加载。
| 归档时间: |
|
| 查看次数: |
526 次 |
| 最近记录: |