Caroline
Caroline

Reputation: 3913

Retrieve the current scale value of a Matrix in Java

In an object of the Matrix, after make several calls to postScale() how can I retrieve the final scale value?

Upvotes: 2

Views: 1344

Answers (2)

Oderik
Oderik

Reputation: 2260

Extract the matrix values and use the ones you need, for example:

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

Upvotes: 4

emboss
emboss

Reputation: 39650

I assume it's possible for you to keep track of the individual scale factors?

The "final" scale value of an image that was rescaled a couple of times is the product of the individual scale factors. A simplified example using the same scale for x and y axis:

float[] scales = {0.2f, 0.5f, 1f, 2f, 5f};

If you apply these subsequently, then the final scale will be 0.2 * 0.5 * 1 * 2 * 5 = 1 again, that is the final image is again the same as the original one.

If you apply different factors for x and y axis, then you have to compute the product individually for both axis.

Upvotes: 1

Related Questions