Save bitmap to location

前端 未结 19 2451
悲哀的现实
悲哀的现实 2020-11-22 00:20

I am working on a function to download an image from a web server, display it on the screen, and if the user wishes to keep the image, save it on the SD card in a certain fo

19条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 00:59

    // |==| Create a PNG File from Bitmap :

    void devImjFylFnc(String pthAndFylTtlVar, Bitmap iptBmjVar)
    {
        try
        {
            FileOutputStream fylBytWrtrVar = new FileOutputStream(pthAndFylTtlVar);
            iptBmjVar.compress(Bitmap.CompressFormat.PNG, 100, fylBytWrtrVar);
            fylBytWrtrVar.close();
        }
        catch (Exception errVar) { errVar.printStackTrace(); }
    }
    

    // |==| Get Bimap from File :

    Bitmap getBmjFrmFylFnc(String pthAndFylTtlVar)
    {
        return BitmapFactory.decodeFile(pthAndFylTtlVar);
    }
    

提交回复
热议问题