引用 13 楼 youngc527 的回复:Quote: 引用 12 楼 xiaobeiweng 的回复:
Quote: 引用 2 楼 youngc527 的回复:
创建一个800×480的 Bitmap
Bitmap bitmap = Bitmap.createBitmap ...
public class MyView extends View {
...
}
是不是这个,但是测试时没有显示
引用 10 楼 u010749756 的回复:Quote: 引用 2 楼 youngc527 的回复:
创建一个800×480的 Bitmap
Bitmap bitmap = Bitmap.createBitmap ...
Bitmap bitmap = Bitmap.createBitmap(800, 480, Config.ARGB_8888);//创建一个800*480的背景!
Canvas canvas = new Canvas(bitmap);//创建一个Canvas
canvas.drawBitmap(bitmap , matrix, paint); //好像没有一个方法能将原图绘制上去
private Bitmap scale(Bitmap origin) {
Bitmap bitmap = Bitmap.createBitmap(800, 480, Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Rect target = null;
int orgWidth = origin.getWidth(), orgHeight = origin.getHeight();
int bgHeight = bitmap.getHeight(), bgWidth = bitmap.getWidth();
if (orgWidth * bgHeight > orgHeight * bgWidth) {
int newWidth = bgWidth, newHeight = newWidth * orgHeight / orgWidth;
target = new Rect(0, (bgHeight - newHeight) / 2, newWidth, (bgHeight + newHeight) / 2);
} else {
int newHeight = bgHeight, newWidth = newHeight * orgWidth / orgHeight;
target = new Rect((bgWidth - newWidth) / 2, 0, (bgWidth + newWidth) / 2, newHeight);
}
canvas.drawBitmap(origin, null, target, new Paint(Paint.DITHER_FLAG | Paint.FILTER_BITMAP_FLAG));
return bitmap;
}
真的可以了,真是太感谢了!如果加入对原图进行拖动,背景静止,怎么实现 ?
2013-10-30 17:36:27 u010749756 14楼
感谢也不给分,谁还愿意管你啊!
2013-10-31 16:19:42 pengguohua1988 15楼
2013-11-01 10:30:00 u010749756 16楼