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:

    Code:
    @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];
    
            y+values[Matrix.MTRANS_Y], xC, yC);
    
    
            paint.setColor(0xFF007F00);
            canvas.drawCircle(x, y, 15, paint);
    
        }
        catch(NullPointerException e) {
            // Just being lazy here...
        }
    }

Similar Threads

  1. The Moto X will be legendary
    By shoii in forum Moto X (2013)
    Replies: 68
    Last Post: 02-17-2014, 08:34 PM
  2. 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
  3. 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
  4. 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
  5. Boxing Day Android Game
    By irshad khan in forum Games
    Replies: 0
    Last Post: 02-13-2014, 01:11 AM

Posting Permissions