Hi everyone, I am new to android dev.
I have an app that will erase part of the bitmap. I am using matrix to scale rotate the image. Without scaling, the transparent eraser is same size with the circle, but when i scale the bitmap the eraser transparent is bigger than the circle size which is fixed. Can someone help me out?.. I am struggling this for 1 week now.
Here's the code I am using:
RectF r = new RectF();
matrix.mapRect(r);
// sol1
float scaledX = (lastX - r.left) + 48; // adjust to the tip of eraser
float scaledY = (lastY - r.top) - 137; // adjust to the tip of eraser
float[] values = new float[9];
matrix.getValues(values);
float scalex = values[Matrix.MSCALE_X];
float skewy = values[Matrix.MSKEW_Y];
float scale = (float) Math.sqrt(scalex * scalex + skewy * skewy);
scaledX /= scale;
scaledY /= scale;
Bitmap bmOverlay = Bitmap.createBitmap(bitmap.getWidth(),
bitmap.getHeight(),
Bitmap.Config.ARGB_8888);
System.out.println("bitmap.getWidth() " + bitmap.getWidth() +
" bitmap.getHeight() " + bitmap.getHeight());
Canvas c = new Canvas(bmOverlay);
c.drawColor(Color.TRANSPARENT, Mode.CLEAR);
c.drawBitmap(bitmap, 0, 0, null);
c.drawCircle(scaledX, scaledY, 13.0f, mPaint); // punch a hole
bitmap = bmOverlay; // update the main bitmap