zoukankan      html  css  js  c++  java
  • android多媒体编程--复制图片

    因为加载到手机中的图片都是只读的不能修改。我们想要修改它可以复制出来一个,在复制的图片上进行修改,原图就不要了。

    package com.example.copyimage;
    
    import android.os.Bundle;
    import android.app.Activity;
    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    import android.graphics.Canvas;
    import android.graphics.Matrix;
    import android.graphics.Paint;
    import android.view.Menu;
    import android.widget.ImageView;
    
    public class MainActivity extends Activity {
        private ImageView src;
        private ImageView copy;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            Bitmap bitmapsrc = BitmapFactory.decodeFile("sdcard/IMG_1392.JPG");
            //这是一张只有宽高和配置的白纸
            Bitmap bitmapcopy = Bitmap.createBitmap(bitmapsrc.getWidth(), bitmapsrc.getHeight(), bitmapsrc.getConfig());
            //画笔
            Paint paint = new Paint();
            //画板,并且把纸铺在画板上
            Canvas canvas = new Canvas(bitmapcopy);
            //开始作画,按照原图绘画
            canvas.drawBitmap(bitmapsrc, new Matrix(), paint);
            src = (ImageView) findViewById(R.id.src);
            copy = (ImageView) findViewById(R.id.copy);
            src.setImageBitmap(bitmapsrc);
            copy.setImageBitmap(bitmapcopy);
            
        }
    
    
    }
  • 相关阅读:
    poj 3669 Meteor Shower
    poj 3232 Accelerator
    poj 2155 Matrix
    poj 3628 Bookshelf 2
    cf C. Maze
    cf B. Fox Dividing Cheese
    hdu Children’s Queue
    cf D. Broken Monitor
    cf C. Mittens
    cf B. Berland Bingo
  • 原文地址:https://www.cnblogs.com/84126858jmz/p/4973551.html
Copyright © 2011-2022 走看看