zoukankan      html  css  js  c++  java
  • 013、ImageView

    1、BitmapFactory类,该类是Android API提供工具类,可以将将图片文件转换为bitmap对象
     
    2、图片的放大缩小,通过Martix对象的postScale()方法实现手机上缩放图片的功能。
     
                    // 产生放大后的Bitmap对象
                    Matrix matrix = new Matrix();
                    matrix.postScale(scaleWidth, scaleHeight);
                    Bitmap createBitmap = Bitmap.createBitmap(bitmap, 0, 0, width,
                            height, matrix, true);
                    iv.setImageBitmap(createBitmap);

     

    3、图片的旋转,通过Martix对象的setRotate()方法可实现图片的旋转
                    // 向左旋转
                    scaleAngle--;
                    if (scaleAngle < -10) {
                        scaleAngle = -10;
                    }
                    Matrix matrix = new Matrix();
                    matrix.postScale(width, height);
                    matrix.setRotate(5 * scaleAngle);
                    Bitmap createBitmap = Bitmap.createBitmap(bitmap, 0, 0, width,
                            height, matrix, true);
                    iv.setImageBitmap(createBitmap);
  • 相关阅读:
    《代码大全2》阅读笔记02
    《代码大全2》阅读笔记01
    第二阶段冲刺第六天
    学习进度5
    构建之法阅读笔记03
    地铁进度记录
    学习进度4
    个人数组
    学习进度3
    构建之法阅读笔记02
  • 原文地址:https://www.cnblogs.com/zyh-blog/p/3324530.html
Copyright © 2011-2022 走看看