0
我最近開始使用ImageViewZoom (https://github.com/sephiroth74/ImageViewZoom) 並且我要做的是在此視圖中使用的位圖上不時繪製一些行。如何在ImageViewZoom中使用的位圖上繪製線條?
我試圖以下面的方式做到這一點,但結果是視圖不再能夠縮放。
protected void onDraw(Canvas canvas)
{
// TODO Auto-generated method stub
super.onDraw(canvas);
Canvas bmp_canvas = new Canvas(bmp);//bmp is the original bitmap
Paint paint = new Paint();
//Draw map
paint. setColor(Color.BLUE);
paint. setStrokeWidth(10);
int i;
for(i=0; i<toDraw.size();i++)
{
Segment now = toDraw.get(i); //toDraw is a List and stores the lines
PointType tmp_start = now.s;
PointType tmp_end = now.e;
bmp_canvas.drawLine((float)tmp_start.x, (float)tmp_start.y,
(float)tmp_end.x, (float)tmp_end.y, paint);
}
Matrix matrix = getImageViewMatrix();
setImageBitmap(bmp, matrix, ZOOM_INVALID, ZOOM_INVALID);
return;
}
那麼這樣做的正確方法是什麼?非常感謝你!