B4J Question B4XBitmap.Resize source code

peacemaker

Expert
Licensed User
Longtime User
Hi, All

I'm trying to make a sub for bitmap calculations for NON-UI apps, for WebApps.
If you know the source calculation algorithm of B4XBitmap.Resize method, could you share ?
Without dependencies.
 

peacemaker

Expert
Licensed User
Longtime User
Thanks. I see it again depends on FX :)

I'm trying to do something like:
B4X:
Public Sub Calc_Width(widthPercent As Float, widthPx As Float, KeepRatio As Boolean)
    CalcWidth = 0
    CalcHeight = 0   
    If widthPercent = 0 And widthPx = 0 Then Return
    
    If widthPercent > 0 Then
        CalcWidth = widthPercent / 100 * gWidth
    Else
        CalcWidth = widthPx
    End If
    If KeepRatio Then
        Dim Ratio As Float = gWidth / CalcWidth
    Else
        Dim Ratio As Float = 1
    End If
    CalcHeight = gHeight / Ratio
End Sub

Public Sub Calc_Height(heightPercent As Float, heightPx As Float, KeepRatio As Boolean)
    CalcWidth = 0
    CalcHeight = 0   
    If heightPercent = 0 And heightPx = 0 Then Return
    
    If heightPercent > 0 Then
        CalcHeight = heightPercent / 100 * gHeight
    Else
        CalcHeight = heightPx
    End If
    If KeepRatio Then
        Dim Ratio As Float = gHeight / CalcHeight
    Else
        Dim Ratio As Float = 1
    End If
    CalcWidth = gWidth / Ratio
End Sub
 
Upvote 0
Top