由网友(騎尐豬〥撞牆)分享简介:我想画一个圆获取并主张的东西的工作,但我没有任何运气,我使用的Android帆布这是我的方法 - I am trying to draw a circle for getting positing stuff work but I don't have any luck, I am using android...
我想画一个圆获取并主张的东西的工作,但我没有任何运气,我使用的Android帆布这是我的方法 -
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("ntroundtrip : ").append(state.getRoundtrip()).append("ms")
.append("ntlat : ").append(state.getGeoPoint().getLatitude())
.append("ntlon : ").append(state.getGeoPoint().getLongitude())
.append("ntX [meter] : ").append(state.getMetricPoint().getX())
.append("ntY [meter] : ").append(state.getMetricPoint().getY())
.append("ntI [pixel] : ").append(state.getImagePoint().getI())
.append("ntJ [pixel] : ").append(state.getImagePoint().getJ())
.append("ntheading : ").append(state.getHeadingDegrees())
.append("ntuncertainty: ").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("ntPing : ").append(state.getRoundtrip()).append("ms")
.append("ntLatitude : ").append(state.getGeoPoint().getLatitude())
.append("ntLongitude : ").append(state.getGeoPoint().getLongitude())
.append("ntX [meter] : ").append(state.getMetricPoint().getX())
.append("ntY [meter] : ").append(state.getMetricPoint().getY())
.append("ntI [pixel] : ").append(state.getImagePoint().getI())
.append("ntJ [pixel] : ").append(state.getImagePoint().getJ())
.append("ntHeading : ").append(state.getHeadingDegrees())
.append("ntUncertainty: ").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);
}
});
相关推荐
最新文章