码迷,mamicode.com
首页 > 其他好文 > 详细

拼图效果

时间:2014-07-16 19:49:20      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:os   width   re   c   new   rgb   

public static Bitmap getComponseBitmap(Bitmap src, Bitmap src2){
if(src == null || src2 == null)
return null;

int width = src.getWidth();
int height = src.getHeight();
Bitmap newBitmap = Bitmap.createBitmap(width, height, Config.RGB_565);
Canvas canvas = new Canvas(newBitmap);
canvas.drawBitmap(src, 0, 0, null);

Bitmap zoomBitmap = zoomImage(src2, 640, 360);
canvas.drawBitmap(zoomBitmap, 200, 200, null);
canvas.save(Canvas.ALL_SAVE_FLAG );
canvas.restore();

return newBitmap;
}

//等比缩放图片
public static Bitmap zoomImage(Bitmap bitmap, int newWidth, int newHeight){
int width = bitmap.getWidth();
int height = bitmap.getHeight();
//计算缩放比例
float scaleW = (float)newWidth/width;
float sacleH = (float)newHeight/height;
//取得缩放Matrix参数
Matrix matrix = new Matrix();
matrix.postScale(scaleW, sacleH);
matrix.postRotate(30);
//得到新图片
Bitmap newBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
return newBitmap;
}

拼图效果,布布扣,bubuko.com

拼图效果

标签:os   width   re   c   new   rgb   

原文地址:http://www.cnblogs.com/clarence/p/3837417.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!