Saving as a png image in android

前端 未结 1 1225
遥遥无期
遥遥无期 2021-01-05 11:51

I am developing paint app and i save my drawing as png image. For drawing i used canvas that created with a bitmap. it works but image was corrupted. Can any one help me. I

相关标签:
1条回答
  • 2021-01-05 12:03

    The emulator works fine. What piece of code did you use to store the bitmap as png?

    The following works fine in the emulator:

    Bitmap bitmap = createYourBitmap();
    OutputStream stream = new FileOutputStream("/sdcard/test.png");
    /* Write bitmap to file using JPEG or PNG and 80% quality hint for JPEG. */
    bitmap.compress(CompressFormat.PNG, 80, stream);
    stream.close();
    
    0 讨论(0)
提交回复
热议问题