Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving as a png image in android

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 didn't check it with a real phone but on the emulator. Is that problem with emulator. I think it has very small processing ability. Am i right? Thank you.

like image 894
chAmi Avatar asked Jan 01 '11 09:01

chAmi


1 Answers

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();
like image 123
Phyrum Tea Avatar answered Nov 15 '22 08:11

Phyrum Tea