簡體   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