What do you mean to create a copy of a picture? Because the images we take directly from the bitmapfactory are readable and cannot be modified. If the user wants to modify this image, it is generally based on the original image in memory and the original picture of the same size, and then modify the above, the user feels as if it was modified on the original, it is not.
public class Mainactivity extends Activity {@Override protected void onCreate (Bundle savedinstancestate) {s Uper.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); 1: First need to get to the original picture. Note: The image we obtained is read-only, cannot be written, if you want to modify the image, you have to create a copy of the picture Bitmap bmsrc = Bitmapfactory.decoderesource (Getresources (), R.DRAWABLE.ABC ); 2: Create a copy of the picture, you can create an image in memory with the same size as the original Bitmap Bitmap bmcopy = Bitmap.createbitmap (Bmsrc.getwidth (), Bmsrc.getheight (), b Msrc.getconfig ()); 2.1 Create a brush paint paint = new paint (); 2.2 Creating artboard objects canvas canvas = new canvas (bmcopy); 2.3 Start drawing exactly as the original Canvas.drawbitmap (BMSRC, New Matrix (), paint); Draw a straight line on the picture, representing a copy of the picture that can be modified canvas.drawline (+, +, +, n, paint); ImageView iv_src = (ImageView) Findviewbyid (R.ID.LV1); ImageView iv_copy = (ImageView) Findviewbyid (R.ID.LV2); Show Iv_src.setimaGebitmap (BMSRC); Iv_copy.setimagebitmap (bmcopy); }}
Actually creating a copy of the picture is simple, just like the code description
As follows:
Can obviously see, the second picture can be modified.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android Multimedia Development Learn to create a copy of the image