bitmap - Android, help rotating image on touch -


I am trying to rotate a transparent PNG on this image. I want to rotate the number of numbers I am able to do this, but it is not what I am trying to achieve.

I will rotate the numbers like a real combination lock. The user will touch and move their finger in a circle. I saw less accurate image rotation on touch / move events, and they were not enough.

This is currently my code

  Public Boolean ON Touch (View v, MotionEvent Event) {Double R = Math.tar 2 (event.getX) - LockNews .jetwidth (), locknogense.gatehite () - event.getY ()); Int Rotation = (Int) Math Toadagridge (R); Switch (event.getAction ()) {Case MotionEvent.ACTION_DOWN: break; In case MotionEvent.ACTION_MOVE: x = event.getX (); Y = event.getY (); UpdateRotation (rotation); break; Case Motion Event Action_up: break; } // return switch true; } // On-Touch Private Zero Update Rotation (Double Rot) {Float Neuro = New Float (Rot); Bitmap bitmap = bitmapfirenet Decode processing (getResources (), R.drawable.numbers); Matrix matrix = new matrix (); Matrix.postRotate (newRot, bitmap.getWidth (), bitmap.getHeight ()); If (y> 250) {bitmap radrine bitmap = bitmap.creditbetaMap (bitmap, 0,0, bitmap .getWidth (), bitmap.gatehit (), matrix, true); LockNumbers.setImageBitmap (reDrawnBitmap); } Else {bitmap radrine bitmap = bitmap.creditbetaMap (bitmap, 0,0, bitmap .getWidth (), bitmapgatehit (), matrix, true); LockNumbers.setImageBitmap (reDrawnBitmap); }}   

Due to the matrix parameter when you touch it, bitmap size changes, this is not the desired effect.

The user will need to move to the circle with his finger.

Write down the code in your touch event.

  switch (event.getAction ()) {Case MotionEvent.ACTION_DOWN: // (reset for hidden quadrants) I = 0; I & lt; QuadrantTouched.length; I ++) {Quadrant connected [i] = false; } AllowRotating = false; StartAngle = getAngle (event.getX (), Event .getY ()); break; Case MotionEvent.ACTION_MOVE: Dual Current Angle = Meet (event.getX (), event.getY ()); Rotate Dealer (float) (startAngle - currentAngle); StartAngle = Current angle; break; Case MotionEvent.ACTION_UP: allowRotating = true; break; } // has crossed the quadrangle to the quadrangle [hosquadrant (event .getX) - (dialerwidth / 2), dialer height - event .getY () - (dialerhit / 2))] = true; Detector.onTouchEvent (event); Back true;   

Use the links below for more context.



Comments