Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8480517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:18:56+00:00 2026-06-10T19:18:56+00:00

An image is scaled by a matrix: Matrix matrix = new Matrix(); matrix.postScale(…); matrix.postTranslate(…);

  • 0

An image is scaled by a matrix:

Matrix matrix = new Matrix();
matrix.postScale(...);
matrix.postTranslate(...);
matrix.postRotate(...);
...

I hope the zoomed image won’t be less than the half of original, so the total zoom should not less that 0.5.

But how to do that? I tried to get the first value of matrix to check:

float pendingZoom = 0.6f;

float[] values = new float[9];
Matrix.getValues(values);
float scalex = values[Matrix.MSCALE_X];

Then:

if(scalex<0.5) {
    pendingZoom = pendingZoom * (0.5f / scalex);
}

unfortunately, it doesn’t work sometimes. If the image has been rotated, the scalex may be negative, the pendingZoom will be negative too.

How to do this correctly?


UPDATE

I just found the values[Matrix.MSCALE_X] is not a realiable zoom value. I use it to calculate the new width of a rect, it’s not correct.

Instead, I tried to map two points by the matrix, and calculate the two distances:

PointF newP1 = mapPoint(matrix, new PointF(0, 0));
PointF newP2 = mapPoint(matrix, new PointF(width, 0));
float scale = calcDistance(newP1, newP2) / width;

I can get correct scale value now. But I’m not sure if it’s best solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T19:18:58+00:00Added an answer on June 10, 2026 at 7:18 pm
        float scalex = values[Matrix.MSCALE_X];
        float skewy = values[Matrix.MSKEW_Y];
        float scale = (float) Math.sqrt(scalex * scalex + skewy * skewy);
    

    This solution looks simpler but I think that your’s is much more clear and almost as fast as this one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have the original transform matrix of a rectangular UIImageView and this image
I am resizing image and rotating it using Matrix: Matrix mtx = new Matrix();
I am on MAC OSX. How to convert an gray scaled image to the
I've got an image that's allowed to be rotated and scaled by the user.
Is the UIImage method: + (UIImage *)imageWithCGImage:(CGImageRef)imageRef scale:(CGFloat)scale orientation:(UIImageOrientation)orientation cropping the original image or
I created an Image with this code OpenFileDialog dlg = new OpenFileDialog(); dlg.FileName =
iam dealing with multiscale images , 3 sizes : original , half & double
I have an imageview, which uses matrix to scale/drag an image. Now I want
I have a small flash file that just loads and shows one image scaled
I'm trying to rotate and then scale an image using android.graphics.Matrix. The code is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.