• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Rotate ellipse on image when rotate the image in Android

I'm having Android code to move, zooming and rotation image. And it working perfect. Now I want to set ellipse on the image and changing it place upon image changes. The ellipse is drawing perfect in moving and zooming cases, but I don't know how to set new points for the ellipse if I rotate the image.
this is the code I'm using:



@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);

if (!isInitialized) {
int w = getWidth();
int h = getHeight();
position.set(w / 2, h / 2);
isInitialized = true;
}

Paint paint = new Paint();

matrix.reset();
matrix.postTranslate(-width / 2.0f, -height / 2.0f);
matrix.postRotate(getDegreesFromRadians(angle));
matrix.postScale(scale, scale);
matrix.postTranslate(position.getX(), position.getY());

canvas.drawBitmap(bitmap, matrix, paint);

try
{
float x=250;
float y=200;

float[] values = new float[9];
matrix.getValues(values);

x =values[Matrix.MSCALE_X]*x+values[Matrix.MTRANS_X];
y =values[Matrix.MSCALE_Y]*y+values[Matrix.MTRANS_Y];

paint.setColor(0xFF007F00);
canvas.drawCircle(x, y, 15, paint);

}
catch(NullPointerException e) {
// Just being lazy here...
}
}
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones