Method for saving bitmap objects in internal storage in PNG format in Android

When performing image processing tasks in Android, sometimes we want to save the processed results in the internal storage space in the format of image file. For this purpose, this paper introduces the method of saving the data of bitmap object in PNG format.

1. Add permissions

Since it is necessary to operate SD card, it is necessary to add read-write permission to your program. The contents to be added are as follows:

These two permissions are briefly explained as follows:

2. Save the relevant code of the picture

The code is relatively simple. Here, the storage location is the absolute path written. You can obtain different location paths by using environment.

Tips: when using this function, remember to bring the file extension.

PS: let's take a look at how to save bitmap objects in android as files

The bitmap class has a compress member that can save the bitmap to a stream.

For example:

summary

The above is what Xiaobian introduced to you. Android saves bitmap objects in PNG format in internal storage. I hope it will be helpful to you. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>