zoukankan      html  css  js  c++  java
  • 图片简易处理

    package com.example.copy;
    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.os.Bundle;
    import android.widget.ImageView;
    public class MainActivity extends Activity {
    
       /**
          1. 加载原图
          2. 笔
          3. 纸
          4. 板
          5. 作画
        */
    
       @Override
       protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          ImageView iv = (ImageView) findViewById(R.id.iv_copy);     
          Bitmap srcBmp = BitmapFactory.decodeResource(getResources(), R.drawable.last_year);
          Paint paint = new Paint();
          Bitmap copyBmp = Bitmap.createBitmap(srcBmp.getWidth(), srcBmp.getHeight(), srcBmp.getConfig());
          //把白纸铺在画板上
          Canvas canvas = new Canvas(copyBmp);
          Matrix matrix = new Matrix();
         // 平移
          // matrix.setTranslate(-copyBmp.getWidth()/2, 0);
          // 缩放
    //    matrix.setScale(0.5f,0.5f);
    //    matrix.setScale(0.5f,0.5f, copyBmp.getWidth()/2, copyBmp.getHeight()/2);
          // 旋转
    //    matrix.setRotate(45);
    //    matrix.setRotate(90,copyBmp.getWidth()/2, copyBmp.getHeight()/2);
          // 镜面
    //    matrix.setScale(-1, 1);
    //    matrix.setTranslate(copyBmp.getWidth(), 0);
          //叠加显示效果
    //    matrix.postTranslate(copyBmp.getWidth(), 0);
          // 倒影
          matrix.setScale(1, -1);
          matrix.postTranslate(0, copyBmp.getHeight());
          canvas.drawBitmap(srcBmp, matrix, paint);
          iv.setImageBitmap(copyBmp);
       }
    }
    
  • 相关阅读:
    Design Tutorial: Inverse the Problem
    The Number Off of FFF
    "Money, Money, Money"
    No Pain No Game
    Group
    Vases and Flowers
    Codeforces Round #466 (Div. 2)
    ST表
    Wildcard Matching
    HDOJ 3549 Dinitz
  • 原文地址:https://www.cnblogs.com/loaderman/p/6421415.html
Copyright © 2011-2022 走看看