Create Image from Path Chosen by Touch Events in Android
<p>I am trying to create an image from whatever the user has created on screen using the Touch Events. I do not want to store the entire canvas as a bitmap. I want to store only the figure drawn by the user. I want the Path Stored as a bitmap. </p>

<p>Please Help.</p>

<pre><code>public class DoodleEngine extends View {
private Paint paint = new Paint();
private Path path = new Path();

public DoodleEngine(Context context, AttributeSet attrs) {
super(context, attrs);

paint.setAntiAlias(true);
paint.setStrokeWidth(6f);
paint.setColor(Color.GREEN);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeJoin(Paint.Join.ROUND);
}

@Override
protected void onDraw(Canvas canvas) {

  canvas.drawPath(path, paint);

}

@Override
public boolean onTouchEvent(MotionEvent event) {
float eventX = event.getX();
float eventY = event.getY();

switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:

  path.reset();
  invalidate();
  path.moveTo(eventX, eventY);
  return true;
case MotionEvent.ACTION_MOVE:
  path.lineTo(eventX, eventY);


  break;
case MotionEvent.ACTION_UP:
  // nothing to do
  break;
default:
  return false;
}

// Schedules a repaint.
invalidate();
return true;
}
} 
</code></pre>
