Welcome to the Android Central Forums Create Your Account or Ask a Question Answers in 5 minutes - no registration required!
Results 1 to 1 of 1
  1. Thread Author  Thread Author    #1  

    Default 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:

    protected void onDraw(Canvas canvas) {
        if (!isInitialized) {
            int w = getWidth();
            int h = getHeight();
            position.set(w / 2, h / 2);
            isInitialized = true;
        Paint paint = new Paint();
        matrix.postTranslate(-width / 2.0f, -height / 2.0f);
        matrix.postScale(scale, scale);
        matrix.postTranslate(position.getX(), position.getY());
        canvas.drawBitmap(bitmap, matrix, paint);
            float x=250;
            float y=200;
            float[] values = new float[9];
            x =values[Matrix.MSCALE_X]*x+values[Matrix.MTRANS_X];
            y =values[Matrix.MSCALE_Y]*y+values[Matrix.MTRANS_Y];
            y+values[Matrix.MTRANS_Y], xC, yC);
            canvas.drawCircle(x, y, 15, paint);
        catch(NullPointerException e) {
            // Just being lazy here...

Similar Threads

  1. Boxing Day Android Game
    By irshad khan in forum Android Games
    Replies: 1
    Last Post: 04-08-2015, 09:50 PM
  2. The Moto X will be legendary
    By shoii in forum Moto X (2013)
    Replies: 68
    Last Post: 02-17-2014, 08:34 PM
  3. Should I buy the Samsung Galaxy S3 in 2014?
    By Ron1697 in forum Samsung Galaxy S3
    Replies: 7
    Last Post: 02-14-2014, 08:04 AM
  4. Frustration Setting In...
    By jbomb11 in forum Samsung Galaxy Note 2 Rooting, ROMs, and Hacks
    Replies: 2
    Last Post: 02-14-2014, 02:38 AM
  5. Question on restoring apps from a backup
    By ShaggyKids in forum General Help and How To
    Replies: 2
    Last Post: 02-13-2014, 08:42 PM

Posting Permissions