Public Sub getWidgetThumbnail ( b As Bitmap) As Bitmap
Try
Dim bx As BitmapExtended
Dim screenratio As Float = 80/125
bx.Initialize("bx")
Dim w As Int=b.Width
Dim h As Int=b.Height
Dim x As Int=0
Dim y As Int=0
Dim imgratio As Float = w/h
' Dim cutlength As Int
Log ("check " & w & "x" & h)
If h>w Then
If screenratio<imgratio Then ' bild schmäler, oben + unten schneiden
y= (h-h/imgratio*screenratio )/2
h=h/imgratio*screenratio
' Log ("1: cropped to " & x & "/" & y & "/" & w &"/" & h)
Return bx.createBitmap3(b,x,y,w,h)
Else
x= (w-w/imgratio*screenratio )/2
w=w/imgratio*screenratio
' Log ("2: cropped to " & x & "/" & y & "/" & w &"/" & h)
Return bx.createBitmap3(b,x,y,w,h)
End If
Else
If screenratio>imgratio Then ' bild schmäler, oben + unten schneiden
y= (h-h/imgratio*screenratio )/2
h=h/imgratio*screenratio
' Log ("3: cropped to " & x & "/" & y & "/" & w &"/" & h)
Return bx.createBitmap3(b,x,y,w,h)
Else
x= (w-w/imgratio*screenratio )/2
w=w/imgratio*screenratio
' Log ("4: cropped to " & x & "/" & y & "/" & w &"/" & h)
Return bx.createBitmap3(b,x,y,w,h)
End If
End If
'Return b
Catch
Log("issue in getWidgetThumbnail " & LastException)
Return b
End Try
End Sub