Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private B4XImageView1 As B4XImageView
Private B4XImageView2 As B4XImageView
Private bce As BitmapCreatorEffects
End Sub
Public Sub Initialize
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
B4XImageView1.mBackgroundColor = xui.Color_Transparent
B4XImageView2.mBackgroundColor = xui.Color_Transparent
Dim bmp As B4XBitmap = xui.LoadBitmap(File.DirAssets, "10039.jpg")
B4XImageView1.Bitmap = bmp
bce.Initialize
B4XImageView2.Bitmap = Skew(bmp, 20)
End Sub
Private Sub Skew(bmp As B4XBitmap, Degrees As Float) As B4XBitmap
Dim orig As BitmapCreator = bce.CreateBC(bmp)
Dim modif As BitmapCreator = bce.CreateEmptyBC(bmp)
Dim shift As Float = SinD(Degrees)
Dim scale As Float = (orig.mHeight - orig.mWidth * shift) / orig.mHeight
Dim pm As PremultipliedColor
For x = 0 To orig.mWidth - 1
For y = 0 To orig.mHeight - 1
Dim yt As Float = (orig.mWidth - x) * shift + y * scale
orig.GetPremultipliedColor(x, y, pm)
modif.SetPremultipliedColor(x, yt, pm)
Next
Next
Return modif.Bitmap
End Sub