Android 实现画图并保存图片
2010-08-21 06:25:00 来源:WEB开发网核心提示:float scaleWidth = ( ( float ) destWidth ) / w;//宽度缩小比例float scaleHeight = ( ( float ) destHeigth ) / h;//高度缩小比例Log.d( tag, "bitmap width is :" + w );
float scaleWidth = ( ( float ) destWidth ) / w;//宽度缩小比例
float scaleHeight = ( ( float ) destHeigth ) / h;//高度缩小比例
Log.d( tag, "bitmap width is :" + w );
Log.d( tag, "bitmap height is :" + h );
Log.d( tag, "new width is :" + destWidth );
Log.d( tag, "new height is :" + destHeigth );
Log.d( tag, "scale width is :" + scaleWidth );
Log.d( tag, "scale height is :" + scaleHeight );
Matrix m = new Matrix();//矩阵
m.postScale( scaleWidth, scaleHeight );//设置矩阵比例
Bitmap resizedBitmap = Bitmap.createBitmap( src, 0, 0, w, h, m, true );//直接按照矩阵的比例把源文件画入进行
return resizedBitmap;
}
更多精彩
赞助商链接