2014-11-24 77 views
-1

我正在處理壁紙應用程序,其中我從獲取圖像Picasa網絡相冊GridViewFull 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(); 
      } 

注:我問有關圖像的大小以字節或千字節爲單位。

回答

0

如果您正在使用的Picasa工作,就可以簡單地得到照片描述它會爲您提供了很多獨特的功能,才能在工作中使用它:

photo.getDescription().getPlainText() 

你會發現更多的細節here

-1

您可以使用BitmapFactory.Options。它只會提取圖像的元數據而不是整個圖像。您應該能夠從那裏獲取足夠的數據,以確保您不會有重複的數據。 進一步閱讀:Android Developers

相關問題