question

6666666 avatar image
0 Votes"
6666666 asked 6666666 commented

How to Save bitmap to `Pictures`?

in xamarin.android I have an Android.Graphics.Bitmap and how to save it to the Pictures?

dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JarvanZhang-MSFT avatar image
0 Votes"
JarvanZhang-MSFT answered 6666666 commented

Hello,​

Welcome to our Microsoft Q&A platform!

I have an Android.Graphics.Bitmap and how to save it to the Pictures

To save the bitmap to Android storage, you could create a FileStream object with the path and then call the Bitmap.Compress method to generate the picture.

Check the code:

var folder = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;
var filePath = System.IO.Path.Combine(folder, "test.png");
var stream = new FileStream(filePath, FileMode.Create);

//get the bitmap

bitmap.Compress(Bitmap.CompressFormat.Png, 100, stream);
stream.Close();

Best Regards,

Jarvan Zhang


If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

can the bitmap compress muti times?

0 Votes 0 ·

Do you mean storing the bitmap as multi pictures? It's supported to do that.

0 Votes 0 ·

But As I know If I compress for muti-times there will be an error.

0 Votes 0 ·
Show more comments