图像缩放

来源:互联网 发布:手机淘宝链接怎么复制 编辑:程序博客网 时间:2024/06/06 06:49

使用Matrix类preScale或者postScale可以对图像进行缩放操作,它的两个参数分别为x和y坐标缩放比例,下面使用preScale对图像进行放大0.75倍,Java代码如下:

  public Bitmap getScaleBitmap() {    BitmapDrawable mBitmapDrawable = (BitmapDrawable) getResources().getDrawable(R.drawable.pet);    Bitmap mBitmap = mBitmapDrawable.getBitmap();    int width = mBitmap.getWidth();    int height = mBitmap.getHeight();    Matrix matrix = new Matrix();    matrix.preScale(0.75f, 0.75f);    Bitmap mScaleBitmap = Bitmap.createBitmap(mBitmap, 0, 0, width, height, matrix, true);    return mScaleBitmap;  }
0 0
原创粉丝点击