引用:http://wiseideal.iteye.com/blog/1175160
- int w = 320,h = 240;
- String mstrTitle = “感受Android带给我们的新体验”;
- Bitmap mbmpTest = Bitmap.createBitmap(w,h, Config.ARGB_8888);
- Canvas canvasTemp = new Canvas(mbmpTest);
- canvasTemp.drawColor(Color.WHITE);
- Paint p = new Paint();
- String familyName = “宋体”;
- Typeface font = Typeface.create(familyName,Typeface.BOLD);
- p.setColor(Color.RED);
- p.setTypeface(font);
- p.setTextSize(22);
- canvasTemp.drawText(mstrTitle,0,100,p);
在canvas初始化的时候就传入了一个空的bitmap 最后canvas中绘画的内容都被绘制到了bitmap中,从而得到了我们需要的bitmap