1个回答
展开全部
直接调用这方法,会返回一张和屏幕大小相同的图片
public static Bitmap FitTheScreenSizeImage(Bitmap m,int ScreenWidth, int ScreenHeight)
{
float width = (float)ScreenWidth/m.getWidth();
float height = (float)ScreenHeight/m.getHeight();
Matrix matrix = new Matrix();
matrix.postScale(width,height);
return Bitmap.createBitmap(m, 0, 0, m.getWidth(), m.getHeight(), matrix, true);
}
public static Bitmap FitTheScreenSizeImage(Bitmap m,int ScreenWidth, int ScreenHeight)
{
float width = (float)ScreenWidth/m.getWidth();
float height = (float)ScreenHeight/m.getHeight();
Matrix matrix = new Matrix();
matrix.postScale(width,height);
return Bitmap.createBitmap(m, 0, 0, m.getWidth(), m.getHeight(), matrix, true);
}
更多追问追答
追问
具体怎么用能解释一下吗?
追答
float width = (float)ScreenWidth/m.getWidth(); 屏宽/图宽
float height = (float)ScreenHeight/m.getHeight(); 屏高/图高
Matrix matrix = new Matrix(); 矩阵对象
matrix.postScale(width,height); 把缩放系数传入该对象中
return Bitmap.createBitmap(m, 0, 0, m.getWidth(), m.getHeight(), matrix, true); 创建一张图片
参数分别是:
图片对象、x、y、w、h、矩阵对象、是否开启抗锯齿
还有不懂的吗?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询