Android Multimedia Development Learn to create a copy of the image

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.