コード例 #1
0
 public void changeCooridnateSystem(int newWidth, int newHeight, int rotation) {
   float animationScaleX =
       (float) Math.min(newWidth, newHeight) / Math.min(mPreviewWidth, mPreviewHeight);
   float animationScaleY =
       (float) Math.max(newWidth, newHeight) / Math.max(mPreviewWidth, mPreviewHeight);
   // keep original centerX and centerY
   float centerX = centerX();
   float centerY = centerY();
   float tempValue;
   switch (rotation) {
     case 0:
       break;
     case 90:
       tempValue = centerX;
       centerX = centerY;
       centerY = mPreviewWidth - tempValue;
       break;
     case 180:
       if (FeatureSwitcher.isTablet()) {
         centerX = mPreviewWidth - centerX;
         centerY = mPreviewHeight - centerY;
       }
       break;
     case 270:
       tempValue = centerX;
       centerX = mPreviewHeight - centerY;
       centerY = tempValue;
       break;
   }
   // translate to new coordinate system
   translate(centerX - centerX(), centerY - centerY(), false);
   // translate from old renderer coordinate system to new renderer coordinate system
   translate(centerX * animationScaleX - centerX, centerY * animationScaleY - centerY, false);
   // scale by animationScaleX
   scale(animationScaleX, false);
   // scale to translate by animationScaleY / animationScaleX to match correct top distance
   scaleToTranslateY(animationScaleY / animationScaleX);
   // compute rotation
   //        rotate(-rotation);
   float rotationRotate = formatRotationValue(360 - rotation);
   //        rotationRotate = AnimationRect.checkRotationLimit(rotationRotate,
   // mCurrentRotationValue);
   // rotate by current orienation
   rotate(mCurrentRotationValue + rotationRotate);
   //        rotate(rotationRotate);
 }
コード例 #2
0
 public void rotate(float degrees) {
   rotate(degrees, mRectF.centerX(), mRectF.centerY());
 }