本文介绍了并主张使用indooratlas机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想画一个圆获取并主张的东西的工作,但我没有任何运气,我使用的Andr​​oid帆布这是我的方法 -

I am trying to draw a circle for getting positing stuff work but I don't have any luck, I am using android canvas here is my method-

    public void onServiceUpdate(ServiceState state) {

    mSharedBuilder.setLength(0);
    mSharedBuilder.append("Location: ")
            .append("\n\troundtrip : ").append(state.getRoundtrip()).append("ms")
            .append("\n\tlat : ").append(state.getGeoPoint().getLatitude())
            .append("\n\tlon : ").append(state.getGeoPoint().getLongitude())
            .append("\n\tX [meter] : ").append(state.getMetricPoint().getX())
            .append("\n\tY [meter] : ").append(state.getMetricPoint().getY())
            .append("\n\tI [pixel] : ").append(state.getImagePoint().getI())
            .append("\n\tJ [pixel] : ").append(state.getImagePoint().getJ())
            .append("\n\theading : ").append(state.getHeadingDegrees())
            .append("\n\tuncertainty: ").append(state.getUncertainty());

    log(mSharedBuilder.toString());
    double x1 = state.getMetricPoint().getX();
    double y1 = state.getMetricPoint().getY();
    float x = (float) x1;
    float y = (float) y1;


    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setAntiAlias(true);
    paint.setColor(Color.BLUE);
    Bitmap image = null;
    Bitmap workingBitmap = Bitmap.createBitmap(image);
    Bitmap mutableBitmap = workingBitmap.copy(Bitmap.Config.ARGB_8888, true);

    Canvas canvas = new Canvas(mutableBitmap);
    canvas.drawCircle(x, y, 10, paint);

    imageView.setAdjustViewBounds(true);
    imageView.setImageBitmap(image);

}

感谢您的帮助

Thanks for the help

推荐答案

下面是我的完整code。它可能对你的作品了。只要编辑一点点必要的,你的宣言。

Here is my complete code. It might works for you too. Just edit a little necessary in your declaration.

public void onServiceUpdate(ServiceState state) {
    log("onServiceUpdate");
    mSharedBuilder.setLength(0);
    mSharedBuilder.append("Location: ")
            .append("\n\tPing : ").append(state.getRoundtrip()).append("ms")
            .append("\n\tLatitude : ").append(state.getGeoPoint().getLatitude())
            .append("\n\tLongitude : ").append(state.getGeoPoint().getLongitude())
            .append("\n\tX [meter] : ").append(state.getMetricPoint().getX())
            .append("\n\tY [meter] : ").append(state.getMetricPoint().getY())
            .append("\n\tI [pixel] : ").append(state.getImagePoint().getI())
            .append("\n\tJ [pixel] : ").append(state.getImagePoint().getJ())
            .append("\n\tHeading : ").append(state.getHeadingDegrees())
            .append("\n\tUncertainty: ").append(state.getUncertainty());

    log(mSharedBuilder.toString());
        final int i, j;
        i = state.getImagePoint().getI();
        j = state.getImagePoint().getJ();
        ImageView imageView = (ImageView) findViewById(R.id.imageView);
        imageView.buildDrawingCache();
        Bitmap bitmap = imageView.getDrawingCache();
        final ImageView imageFloor = (ImageView) findViewById(R.id.imageView);
        final Bitmap bitmapCircle = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());
        Canvas canvas = new Canvas(bitmapCircle);
        Paint paint = new Paint();
        paint.setAntiAlias(true);
        paint.setColor(Color.BLUE);
        paint.setStrokeWidth(10);
        canvas.drawBitmap(bitmap, new Matrix(), null);
        canvas.drawCircle(i, j, 10, paint);
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                imageFloor.setImageBitmap(bitmapCircle);
            }
        });

这篇关于并主张使用indooratlas机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 23:00