Android Question AutoScale - Get the rate?

lip

Active Member
Licensed User
Longtime User
Can I find out what Autoscale factor has been applied in code? I need it to correct a scale factor which relates the x/y coordinates of devices.

I have items in a database with X/Y co-ordinates stored in MM from an origin. They are positioned by dragging them around a bitmap, and I maintain a scale factor for each bitmap: MMPerPixel.

The App, database and bitmaps are loaded on different tablets with different sizes, scales, resolution etc.

The MMPerPixel factor is adjusted on each tablet by a factor of 100 / 100dip which works well.

If AutoScale is not used then all is well. But it it complicates the overall page layout so I want to use it.

If Autoscale is used then the position of the devices on the bitmaps is out by a factor of the Autoscale factor. I can prove this by enabling and disabling Autoscale, but I can't correct it (other than for a specific tablet type) unless I can find our the factor that is being applied by Autoscale.
 

klaus

Expert
Licensed User
Longtime User
I do not understand exactly your problem.
You have the MMPerPixel Scale factor.
In this factor, are the pixels those of the bitmap or those of the view showing the bitmap ?

Do you want to have the dimensions of the item in mm on the screen ?
I mean, if the width of in item is 10mm and you measure it on the screen it should be 10mm.
In that case you can use the code HERE, where you get the real pixel size in inches.

Can you post a small project showing the problem.

The MMPerPixel factor is adjusted on each tablet by a factor of 100 / 100dip which works well.
Instead of 100 / 100dip you could use xui.Scale
 
Upvote 0

lip

Active Member
Licensed User
Longtime User
I do not understand exactly your problem.
You have the MMPerPixel Scale factor.
In this factor, are the pixels those of the bitmap or those of the view showing the bitmap ?

Do you want to have the dimensions of the item in mm on the screen ?
I mean, if the width of in item is 10mm and you measure it on the screen it should be 10mm.
In that case you can use the code HERE, where you get the real pixel size in inches.

Can you post a small project showing the problem.


Instead of 100 / 100dip you could use xui.Scale

Thanks for the help Klaus. I've just found a solution to the AutoScale question:

- Take any view on the screen with known size. in my case a Panel with Width set to 840 in the Designer.
- At run time pnl.Width would typically by 840 * 100dip / 100 - ie DipToCurrent(840)
- With AutoScale enabled pnl.Width will be a slightly different value
- The runtime AutoScaleRate is the factor between the two = DipToCurrent(840) / pnl.Width
 
Upvote 0
Top