你介意帮我解决这个问题。
我想在位图上绘制一个圆,然后将位图绘制到mapView。 但是仍然没有创建位图。 这是我的代码:
public class CustomOverlay extends Overlay {
public HeatPoint pt;
Context mContext;
Bitmap bmp;
public CustomOverlay(HeatPoint pt,Context context){
this.pt=pt;
this.mContext = context;
bmp = Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888);
Paint gp = new Paint();
gp.setColor(0xFF0000);
gp.setStyle(Style.FILL);
Canvas myCanvas = new Canvas(bmp);
myCanvas.drawRect(10,10,40,40,gp);
}
@Override
public boolean draw(Canvas canvas, MapView mapView,
boolean shadow, long when)
{
super.draw(canvas, mapView, shadow);
Point screenPts = new Point();
mapView.getProjection().toPixels(pt.getGeo(), screenPts);
canvas.drawBitmap(bmp, screenPts.x-16, screenPts.y-2, null);
return true;
}
}
在这段代码中,我想在屏幕上绘制一个圆圈,但是当我运行它时,什么都没发生。 谢谢你的帮助。
答案 0 :(得分:0)
您可以看到以下代码
int w = WIDTH_PX, h = HEIGHT_PX;
BitmapConfig conf = Bitmap.Config.ARGB_8888; // see other conf types
Bitmap bmp = Bitmap.createBitmap(w, h, conf); // this creates a MUTABLE bitmap
Canvas canvas = new Canvas(bmp);
本教程可能会对您有所帮助
http://www.tutorialforandroid.com/2010/11/drawing-with-canvas-in-android-renewed.html