Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid : Not able to do canvas painting on image uploaded from sd card
    text
    copied!<p>I am trying to build a paint application. The application is divided into 3 parts:</p> <ol> <li>Initially the application is having a white background and user can paint on the canvas using different brush sizes and different colors</li> <li>User can save the canvas image to sd card</li> <li>User can upload the image from sd card and again paint on the image</li> </ol> <p>Point 1 and 2 are working fine and I am able to paint on a white background. But point 3, when I upload any image from Gallery and try to paint on the image, then the previous path painted is getting disappeared and only new path is displayed.</p> <p>code :</p> <pre><code>onDraw(Canvas canvas){ mBitmap = Bitmap.createBitmap(320, 480, Bitmap.Config.ARGB_8888); mCanvas = new Canvas(mBitmap); mPath = new Path(); mBitmapPaint = new Paint(Paint.DITHER_FLAG); canvas.drawColor(Color.WHITE); canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint); canvas.drawPath(mPath, mPaint); } onTouch - &gt; case MotionEvent.ACTION_DOWN: mPath.reset(); mPath.moveTo(x, y); mX = x; mY = y; invalidate(); break; case MotionEvent.ACTION_MOVE: float dx = Math.abs(x - mX); float dy = Math.abs(y - mY); if (dx &gt;= TOUCH_TOLERANCE || dy &gt;= TOUCH_TOLERANCE) { mPath.quadTo(mX, mY, (x + mX) / 2, (y + mY) / 2); mX = x; mY = y; } invalidate(); break; case MotionEvent.ACTION_UP: mPath.lineTo(mX, mY); mCanvas.drawPath(mPath, mPaint); mPath.reset(); break; mBitmap = BitmapFactory.decodeFile(filePath); -----this is from sd card </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload