iOS Question SetBitmapDensity iOS

MarcoRome

Expert
Licensed User
Longtime User
Hi all, i have this code in B4A:

B4X:
Sub SetBitmapDensity(b As Bitmap) As Bitmap
    Dim jo As JavaObject = b
    Dim den As Int = Density * 160
    jo.RunMethod("setDensity", Array(den))
    Return b
End Sub

Is it possibile in B4i ?

Thank you
Marco
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
It is set when the bitmap is loaded.

You can use this sub:
B4X:
Sub LoadBitmapWithScale(Dir As String, FileName As String, Scale As Float) As Bitmap
   Dim bytes() As Byte = Bit.InputStreamToBytes(File.OpenInput(Dir, FileName))
   Dim no As NativeObject
   Return no.Initialize("UIImage").RunMethod("imageWithData:scale:", Array(no.ArrayToNSData(bytes), Scale))
End Sub
 
Upvote 0
Top