的ArrayList顏色重疊
ArrayList<Pair<Path, Float>> foregroundPaths = new ArrayList<Pair<Path, Float>>();
油漆動初始化
mPaint = new Paint();
mPaint.setAntiAlias(false);
mPaint.setDither(true);
mPaint.setColor(0x0FFF0000);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeJoin(Paint.Join.BEVEL);
mPaint.setStrokeCap(Paint.Cap.ROUND);
mPaint.setStrokeWidth(Math.abs(ImageViewTouch.brushSize
/getScale()));
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
mPaint.setAlpha(0x80);
的OnDraw
canvas.save();
displayRectF = new RectF();
canvas.concat(getDisplayMatrix());
rect = canvas.getClipBounds();
displayRectF.set(rect);
for (Pair<Path, Float> p : foregroundPaths) {
mPaint.setStrokeWidth(p.second);
canvas.drawPath(p.first, mPaint);
}
canvas.restore();
以上代碼可以使用手指在畫布上繪製。但問題是當多條路徑交叉重疊時。我附上了我的應用快照的鏈接。 重疊在綠色矩形內。我設置Xfermode來繪製,但沒有按照我的預期工作。
請幫我,建議我,我該怎麼做才能解決這個問題。 任何建議將不勝感激。 感謝
試過以下?對你起作用嗎? – Raghunandan 2013-05-13 13:48:52
爲什麼即使使用這個mBitmap = Bitmap.createBitmap(w,h,Bitmap.Config.ARGB_8888),突然間也不接受 – Raghunandan 2013-05-16 13:11:51
; mCanvas = new Canvas(mBitmap);它的故事同樣如此。 doe snot解決。所以我想我在這方面的答案是正確的。 – Raghunandan 2013-05-16 13:16:29