Android Question How can I get the aspect ratio of an image file?

Levisvv

Member
Licensed User
Longtime User
I have an app that loads a background image (floor plan) that I use as a canvas to draw on.
I am using the following to load the image:
B4X:
If MAPfound = True Then   
        'dimension Imageview3 to the correct scale:
        ImageView3.Bitmap = LoadBitmapSample(MAPfolder,MAPfile,ImageView3.width,ImageView3.height)
    Else
        ImageView3.SetBackgroundImage(Null)
    End If

but I need to get the aspect ration of the image so that I can reside Imageview3 to keep the same aspect ration based on the Imageview3 being the entire width of the screen.

How can I get the aspect ratio of the image before loading it?
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
image.height / image.width (or the other way around)

EDIT: Oh, before? no idea... Load the image into a variable, do the math, then move the image from the variable to the imageview
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
set it right after the loading, you won't see it changing anyway.

if you see it then hide it before the load and display it after the resize. (or move it outside the canvas and place it back at the end)
 
Upvote 0
Top