SubName: ScaleImage
Description:
Scales the view V to the correct aspect ratio to view on the devices screen size based on the dimentions of the drawable Bmd.
With modifications, this routine can be used for about any app. If you don't want it to use the size of the device screen, modify the code to take the view size instead of the activity.
Tags: Scale,Image
--- Jem
Description:
Scales the view V to the correct aspect ratio to view on the devices screen size based on the dimentions of the drawable Bmd.
B4X:
Public Sub ScaleImage(Bmd As BitmapDrawable, V As View)
Dim bmp As Bitmap
Dim hgt, wid As Int
Dim scale As Float
Dim ls As Boolean
Dim cw, ch As Int
wid = Activity.width
hgt = Activity.height
ls = wid > hgt
bmp = Bmd.Bitmap
scale = bmp.width / bmp.height
If ls Then
cw = hgt * scale
ch = hgt
Else
cw = wid
ch = wid * scale
End If
V.width = cw
V.height = ch
End Sub
With modifications, this routine can be used for about any app. If you don't want it to use the size of the device screen, modify the code to take the view size instead of the activity.
Tags: Scale,Image
--- Jem