I get the image as a blob type from the API. And I save the following:
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()); } } }
Now the problem I am facing is
When I save it, sometimes the image saves only half. Now my question is:
- Is there a way to check the image from the file path half loaded (which means damage)?
Edit:
- I am downloading an image from the server. At the same time, I lost my network connection. In this case, my image is half loaded. Can I get these damaged images programmatically? Or any idea how to handle in this case?
Any help would be really appreciated.
Thanks.
Attaching an image for reference:

source share