- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我可以显示位图,但我正在绘制的圆圈不显示。我不确定我错过了什么。
private void loadImage() {
File f = new File(imagesPath, currImageName);
Bitmap bitmap = BitmapFactory.decodeFile(f.getAbsolutePath());
BitmapDrawable bitmapDrawable = new BitmapDrawable(bitmap);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(Color.BLUE);
canvas = new Canvas();
canvas.drawCircle(60, 50, 25, paint);
bitmapDrawable.draw(canvas);
ImageView imageView = (ImageView)findViewById(R.id.imageview);
imageView.setAdjustViewBounds(true);
imageView.setImageDrawable(bitmapDrawable);
}
最佳答案
您的代码不是在位图上绘制,而是将您的位图绘制到 Canvas 中,然后在该 Canvas 的位图上画一个圆。然后将结果丢弃。然后将原始位图(未更改)设置到 ImageView 中。
您需要使用位图创建 Canvas 。然后 draw 方法将在您的位图上绘制。
Bitmap bitmap = BitmapFactory.decodeFile(f.getAbsolutePath());
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(Color.BLUE);
// create canvas to draw on the bitmap
Canvas canvas = new Canvas(bitmap);
canvas.drawCircle(60, 50, 25, paint);
ImageView imageView = (ImageView)findViewById(R.id.imageview);
imageView.setAdjustViewBounds(true);
imageView.setImageBitmap(bitmap);
关于android - 无法在位图上画圆?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6088723/
我想以 headless 模式(屏幕上根本没有 GUI)将 JPanel 绘制到 BufferedImage 中。 final JPanel panel = createPanel(); panel.
我是 Canvas 的新手,正在尝试创建看起来逼真的 float 粒子动画。 目前,我正在创建 400 个随机散布在 400x400 Canvas 上的粒子。 然后,在每个 requestAnimat
有没有办法在悬停时停止悬 float 画? :hover 这是一个显示动画的链接: https://codepen.io/youbiteme/pen/RprPrN 最佳答案 只需为您的 svg 悬停添
我想在谷歌地图上绘制覆盖图,其中除了特定点周围 1.5 公里半径以外的所有内容都被遮蔽了。为此,我尝试使用带有大量边框的圆圈,所以我会在边框中放置透明中心和覆盖颜色来实现这一点,但它无法渲染。
我正在尝试通过扩展类 UIView 来创建自定义 View ,该类可以在自定义 View 的中心显示一个圆圈。为了添加自定义绘图,我重写了 draw(_ rect: CGRect) 方法,如下所示。
我是一名优秀的程序员,十分优秀!