繁体   English   中英

Android,线宽,像素大小

[英]Android, line width, pixel size

使用Android画布绘制命令:

如果我设置stroke = 0或stroke = 1并绘制水平线,则线像素高两个像素。 如果我设置stroke = 2,则像素也是两个像素高但更亮。

如果我绘制单个像素,则像素为2x2矩阵,用于stroke = 0或stroke = 1.如果stroke = 2,我还得到2x2矩阵,但像素更亮。

我该怎么做才能获得只有一个像素高的线条? 我必须做些什么来获得像素的唯一像素?

注意:使用的设备的屏幕尺寸为480 x 800或更高。

Paint thePaint = new Paint();                   
thePaint.setARGB(a, r, g, b);                           
thePaint.setAntiAlias(true);
thePaint.setStyle(Paint.Style.FILL );
thePaint.setStrokeWidth(0);
canvas.drawLine(x1,y1,x2,y2, thePaint);

我与The Roman Guy @Google就此问题进行了沟通。 他说除了设定中风= 0之外,需要关闭AntiAlias。我的测试表明他是对的。 Google文档目前不反映此要求。 这段代码有效。

Paint thePaint = new Paint();                   
thePaint.setARGB(a, r, g, b);                           
thePaint.setAntiAlias(false);
thePaint.setStyle(Paint.Style.STROKE );
thePaint.setStrokeWidth(0);
canvas.drawLine(x1,y1,x2,y2, thePaint);

看起来你需要更换线路

thePaint.setStyle(Paint.Style.FILL);

改为:

thePaint.setStyle(Paint.Style.STROKE);

暂无
暂无

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

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