我正在處理壁紙應用程序,其中我從獲取圖像Picasa網絡相冊在GridView
和Full Screen ImageView
中。如何從imageview(android)獲取圖像大小字節
我想用image bytes size, to prevent duplicate save, but i don't know
如何從ImageView.`
獲得的圖像字節大小,這是我的代碼保存ImageView
加載圖像:
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();
}
注:我問有關圖像的大小以字節或千字節爲單位。