2016-09-22 7 views

答えて

1

このそれが動作してみてください - この質問

private File saveBitmap(Bitmap bitmap, String path) { 
      File file = null; 
      if (bitmap != null) { 
       file = new File(path); 
       try { 
        FileOutputStream outputStream = null; 
        try { 
         outputStream = new FileOutputStream(path); //here is set your file path where you want to save or also here you can set file object directly 

         bitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream); // bitmap is your Bitmap instance, if you want to compress it you can compress reduce percentage 
         // PNG is a lossless format, the compression factor (100) is ignored 
        } catch (Exception e) { 
         e.printStackTrace(); 
        } finally { 
         try { 
          if (outputStream != null) { 
           outputStream.close(); 
          } 
         } catch (IOException e) { 
          e.printStackTrace(); 
         } 
        } 
       } catch (Exception e) { 
        e.printStackTrace(); 
       } 
      } 
      return file; 
     } 
+0

ありがとうございました。私はファイルを保存したくありません。私はちょうどファイルにビットマップを変換する必要があります。出来ますか? –

+0

ええ、上記の方法では、ビットマップを変換してファイルを返している可能性があります。 –

関連する問題