Android Question how to get img width,height,does it need bmp.clear?

xiaoyao

Active Member
Licensed User
Longtime User
how to get img width,height,does it need bmp.clear?
Dim wh() As Int
wh=GetImgSize(File.DirInternal,"test.jpg")
MsgboxAsync("pic size=" & wh(0) & "," & wh(1),"")

why it's error?

GETIMG width/height:
Sub GetImgSize(imagePath As String,FileName As String) As Int()
    If imagePath="" Then imagePath=File.DirInternal
    Dim wh(1) As Int
    If File.Exists(imagePath, FileName) Then
        Dim bmp As Bitmap
        bmp = LoadBitmap(imagePath, FileName)
        If bmp.IsInitialized Then
            wh(0)= bmp.Width
            wh(1) =bmp.Height
             ' 释放 Bitmap 对象占用的内存
        End If
    End If
    Return wh
End Sub
 

Cableguy

Expert
Licensed User
Longtime User
When DEFINING an array, you set how many values it will hold : Dim x(2) as int defines X to have 2 values.
When ACESSING the array values, first INDEX is 0, so you access them by : x(0) = 12 '0 is the first value position in the array
 
Upvote 0
Top