我從網絡接收樣本(浮點陣列)並將它們繪製爲SurfaceView中的曲線。樣本會定期更新,因此曲線是動態的。 在我的計劃,我創造出的曲線將被抽入,這樣的位圖:Android位圖/畫布放大或縮小
Bitmap bmp = Bitmap.createBitmap(width, height, Config.ARGB_4444);
Canvas canvas = new Canvas(bmp);
drawCurve(canvas);
void drawCurve(Canvas canvas, float[] buffer) {
...
canvas.drawLine(x1, buffer[i], x2, buffer[i+1], paint);
...
}
...
private class RenderThread extends Thread {
public void run() {
c = mHolder.lockCanvas(null);
c.drawBitmap(bmp, 0, 0, null);
mHolder.unlockCanvasAndPost(c);
...
}
}
我想支持的曲線可以放大和縮小。爲了有效地繪製曲線,繪製曲線方法只是更新新樣本,也就是說,擦除舊區域,並在該區域繪製新樣本。我能怎麼做?謝謝!
http://stackoverflow.com/questions/7704086/how -do -i-modify-touchimageview-with-two-tap-to-zoom-in-and-out/7816495#7816495這將包含一個庫,將解決問題 – ingsaurabh