i am working on an wallpaper app in which i am receiving images from Picasa Web Album in GridView
and Full Screen ImageView
.
i want to save ImageView
loaded image using image bytes size, to prevent duplicate save, but i don't know
how to get image bytes size from ImageView.`
this is my code:
int intHeight = fullImageView.getHeight();
int intWidth = fullImageView.getWidth();
String dirname2 = "/Amazing Wallpapers HD/";
File myDir2 = new File(Environment.getExternalStorageDirectory()
.getPath() + dirname2);
myDir2.mkdirs();
String fname2 = "image" + intHeight+ intWidth +".jpeg";
File file2 = new File(myDir2, fname2);
if (file2.exists())
file2.delete();
try {
FileOutputStream out = new FileOutputStream(file2);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
out.flush();
out.close();
} catch (Exception e) {
Toast.makeText(_context, "failed", Toast.LENGTH_SHORT).show();
}
Note: i am asking about size of image in bytes or kilobytes.
You can use BitmapFactory.Options for that. It'll only extract the meta data of the image not the image as a whole.You should be able to get enough data from there to ensure you wont have a duplicate. For further reading: Android Developers