I receive samples(float array) from network and draw them as a curve in a SurfaceView. The samples are updated periodically so the curve is dynamic. In my program, I create a Bitmap which the curve will be drawn into, like this:
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);
...
}
}
I wanna support the curve can be zoom in and out. As to draw curve effectively, The drawCurve method just update the new samples, that is to say, erase a old area, and draw the new sample in that area. how can I do? Thanks!