图片旋转缩放--Matrix

protected Bitmap RoateToFit(Bitmap bmp2, float f) {
        // TODO Auto-generated method stub
        int width=bmp2.getWidth();
        int height=bmp2.getHeight();
        Matrix matrix=new Matrix();//定义了一个画布
        matrix.postRotate(f);
        Bitmap bmResult=Bitmap.createBitmap(bmp2, 0, 0, width, height,matrix,true);
//从源位图bmp2的指定坐标点(0,0)开始,从中挖取宽高widthheight的一块出来创建新的bitmap对象 并且按照matrix制定的规则进行变换
//把bmp2投影到matrix矩阵 重新创建一个bitmap return bmResult; } protected Bitmap scaleToFit(Bitmap bmp2, float f) { // TODO Auto-generated method stub int width=bmp2.getWidth(); int height=bmp2.getHeight(); Matrix matrix=new Matrix();//定义了一个画布 matrix.postScale(f,f); Bitmap bmResult=Bitmap.createBitmap(bmp2, 0, 0, width, height,matrix,true); //把bmp2投影到matrix矩阵 重新创建一个bitmap return bmResult; }

讲义335和351有相关知识点

下面是百度到的:

 

posted @ 2017-09-12 14:53  喂鲨鱼  阅读(237)  评论(0编辑  收藏  举报