简体   繁体   English

用另一种方法在位图内绘制圆

[英]Draw Circle inside bitmap with another method

Is there any posibilities to draw circle in different method. 是否有可能用不同的方法画圆。 Here is the step : 这是步骤:

  1. In onCreate method i call method loadFloorPlanImage(); 在onCreate方法中,我调用方法loadFloorPlanImage(); <--- it is using bitmap to draw floor plan that get from IndoorAtlas. <---它使用位图绘制从IndoorAtlas获取的平面图。
  2. Next i want to draw circle inside loadFloorPlanImage method in different method. 接下来,我想以不同的方法在loadFloorPlanImage方法内部绘制圆圈。

So this is the code : 所以这是代码:

public onCreate(Bundle savedInstanceState)
{
initIndoorAtlas(); <-- cobtain connection with IndoorAtlas.
}

Inside initIndoorAtlas(); 内部initIndoorAtlas(); There is call loadFloorPlan(); 有调用loadFloorPlan(); method. 方法。

public void loadFloorPlanImage(FloorPlan floorPlan) {
    BitmapFactory.Options options = createBitmapOptions(floorPlan);
    FutureResult<Bitmap> result = mIndoorAtlas.fetchFloorPlanImage(floorPlan,options);
    result.setCallback(new ResultCallback<Bitmap>() {
        @Override
        public void onResult(final Bitmap result) {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    ImageView imageView = (ImageView) findViewById(R.id.imageView);
                    imageView.setImageBitmap(result);
                    log("oNResult LoadFloorPlanImage");
                }
            });
        }
        @Override
        public void onSystemError(IOException e) {

        }

        @Override
        public void onApplicationError(IndoorAtlasException e) {

        }
    });
}

Until this i was succed to draw floor plan in UI thread using bitmap. 在此之前,我一直在使用位图在UI线程中绘制平面图。 Next i want to draw blue circle to get current location in different method. 接下来,我想画一个蓝色圆圈,以不同的方法获取当前位置。 It's : 它的 :

 public void onServiceUpdate(ServiceState state){
    final double x,y;
    int i,j;
    x = state.getMetricPoint().getX();
    y = state.getMetricPoint().getY();
    i = state.getImagePoint().getI();
    j = state.getImagePoint().getJ();

//here is to draw circle based on i,j pixel.
}

Notice that onServiceUpdate(ServiceState state) is giving respons when the Phone is moving. 请注意,当手机移动时,onServiceUpdate(ServiceState state)会做出响应。

Is there anyone can help ? 有没有人可以帮忙?

See the basic math for calculating correct position in your other question: Draw Circle in ImageView when getting current location IndoorAtlas SDK . 请参见基本数学,以计算其他问题中的正确位置: 获取当前位置IndoorAtlas SDK时,在ImageView中绘制圆

The to draw the position, store last location returned from server, call invalidate to the ImageView that you've used to display the floor plan bitmap, override it's onDraw(Canvas), call super.onDraw(canvas) first, then draw the blue dot (using the math as referenced above) with https://developer.android.com/reference/android/graphics/Canvas.html#drawCircle(float , float, float, android.graphics.Paint). 绘制位置,存储从服务器返回的最后一个位置,调用使您用来显示平面图位图的ImageView无效,覆盖它的onDraw(Canvas),首先调用super.onDraw(canvas),然后绘制蓝色点(使用上面引用的数学方法)与https://developer.android.com/reference/android/graphics/Canvas.html#drawCircle(float,float,float,android.graphics.Paint )。 You can draw one semi-transparent circle for the accuracy (larger radius) and one circle for the actual blue dot. 您可以绘制一个半透明的圆以获得精度(较大的半径),而绘制一个圆用于实际的蓝点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM