android中图像在画布上放大缩小时,图像的边框大小没有改变!
原图如下:
放大后:原来图片的边框没有改变,位置依旧!
所以如果要放置图片的位置的话,就需要做相应的位置移动才可以!
采用如下代码(全屏放置图片):
matrix matrix = new matrix();
matrix.postscale(canvas.getwidth()*1.01f/bmpbg.getwidth(), canvas.getheight()*1.01f/bmpbg.getheight(), bmpbg.getwidth() / 2, bmpbg.getheight() / 2);
matrix.posttranslate( (canvas.getwidth()-bmpbg.getwidth()) / 2, (canvas.getheight()-bmpbg.getheight()) / 2);
canvas.drawbitmap(bmpbg, matrix, paint);