gpt4 book ai didi

java - 如何在不填充的情况下在位图上绘制圆圈?

转载 作者:行者123 更新时间:2023-11-29 19:45:24 25 4
gpt4 key购买 nike

我正在位图上绘制一个圆圈并将该位图设置为 ImageView。圆圈绘制正确,但我不希望它是实心圆圈,有什么办法可以使填充区域透明吗?我正在使用以下代码

Bitmap bmp = RasterImageConverter.convertToBitmap(_loadedImage, ConvertToImageOptions.NONE.getValue());
Canvas c = new Canvas(bmp);
c = new Canvas(bmp);
myimgview.draw(c);
Paint p = new Paint();
p.setColor(Color.RED);
float x=(float) circleX;
float y=(float) circleY;
float Tx=(float) textX;
float Ty=(float)textY;
// c.drawLine(x, y, xend, yend, p);
c.drawCircle(300, 300, 200, p);
c.drawText(myText, Tx, Ty, p);
myimgview.setImageBitmap(bmp);

最佳答案

您需要通知绘画您使用的不是填充样式,而是描边样式。

The default is FILL

The Style specifies if the primitive being drawn is filled, stroked, or both (in the same color). The default is FILL.

所以你的代码必须是:

Paint p = new Paint();
p.setStyle(Paint.Style.STROKE);

Here解释了不同风格之间的差异。

STROKE Geometry and text drawn with this style will be stroked, respecting the stroke-related fields on the paint.

FILL Geometry and text drawn with this style will be filled, ignoring all stroke-related settings in the paint.

FILL_AND_STROKE Geometry and text drawn with this style will be both filled and stroked at the same time, respecting the stroke-related fields on the paint.

关于java - 如何在不填充的情况下在位图上绘制圆圈?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37839536/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com