Android 手机应用的开发经验—QR生成器
2010-08-21 03:25:00 来源:WEB开发网这两行代码的意思是canvasBmp是一个刚好canvas大小的空Bitmap ,Canvas画完该会自动保存到canvasBmp中。
Java代码
public void onDraw(Canvas mCanvas01) {
super.onDraw(mCanvas01);
Log.i("wwj", "onDraw");
int intPadding = 50;
// 设置画图绘图颜色
mCanvas01.drawColor(getResources().getColor(R.drawable.white));
// 创建画笔
Paint mPaint01 = new Paint();
// 设置画笔颜色和模式
mPaint01.setStyle(Paint.Style.FILL);
mPaint01.setColor(getResources().getColor(R.drawable.black));
mPaint01.setStrokeWidth(1.0F);
// 逐一加载boolean数组
for (int i = 0; i < bEncoding.length; i++) {
for (int j = 0; j < bEncoding.length; j++) {
if (bEncoding[j][i]) {
// 绘出条形码方块
mCanvas01.drawRect(new Rect(intPadding + j * 3 + 2,// 左上边x
intPadding + i * 3 + 2,// 左上边y
intPadding + j * 3 + 2 + 3,// 右下边x
intPadding + i * 3 + 2 + 3// 右下边y
), mPaint01);
}
}
}
}
public void onDraw(Canvas mCanvas01) {
super.onDraw(mCanvas01);
Log.i("wwj", "onDraw");
int intPadding = 50;
// 设置画图绘图颜色
mCanvas01.drawColor(getResources().getColor(R.drawable.white));
// 创建画笔
Paint mPaint01 = new Paint();
// 设置画笔颜色和模式
mPaint01.setStyle(Paint.Style.FILL);
mPaint01.setColor(getResources().getColor(R.drawable.black));
mPaint01.setStrokeWidth(1.0F);
// 逐一加载boolean数组
for (int i = 0; i < bEncoding.length; i++) {
for (int j = 0; j < bEncoding.length; j++) {
if (bEncoding[j][i]) {
// 绘出条形码方块
mCanvas01.drawRect(new Rect(intPadding + j * 3 + 2,// 左上边x
更多精彩
赞助商链接