Conversion between Android images, bitmap, drawable, res resource images

① res resource picture is the resource picture placed under the project res file

② for Bitmap bitmap, the suffix of general file is BMP, and encoder coding is required, such as rgb565, rgb8888, etc. A pixel by pixel display object has high execution efficiency, but obvious disadvantages and low storage efficiency.

③ drawable, a general graphic object, can load commonly used images, GIF, PNG, JPG, also supports BMP, and provides some advanced visual objects, such as gradient, graphics, etc.

① put the pictures into the RES / drawable folder. The pictures in this folder belong to res resource pictures

② define image processing as a tool class, which is convenient to use or not.

③ click the button to obtain the picture and display it.

[tip] canvas is required to draw when converting drawable to bitmap. Set the size of the drawing and the boundary of the drawing.

[prompt] you can see that there is no picture set in ImageView

[prompt] for convenience, I have written a button here. Four methods cooperate with each other, and the three forms are transformed into each other

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
分享
二维码
< <上一篇
下一篇>>