Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private Btn1 As B4XView
Private Btn2 As B4XView
Private Btn3 As B4XView
Private Img1 As B4XView
Private Img2 As B4XView
Dim bmCEf As BitmapCreatorEffects
Private xui As XUI
End Sub
Sub Activity_Create(FirstTime As Boolean)
bmCEf.Initialize
Activity.LoadLayout("Ly0")
Btn3.Visible=False
fillImg1(Img1)
End Sub
Private Sub fillImg1(Img As B4XView)
Dim bc As BitmapCreator
bc.Initialize(Img.Width / xui.Scale, Img.Height / xui.Scale) '<-- disable the scale factor. This will improve performance.
Dim gpx As BCPath
gpx.Initialize(0,0)
gpx.LineTo(bc.mWidth/2, bc.mHeight/3)
gpx.LineTo(bc.mWidth/2,bc.mHeight)
gpx.LineTo(0,bc.mHeight)
gpx.LineTo(0,0)
bc.DrawPath(gpx,Colors.Red,True,0)
Img1.SetBitmap(bc.Bitmap)
End Sub
Sub Btn2_Click
Dim iv As ImageView = Img1
Dim bmp As B4XBitmap = iv.Bitmap
bmp=bmCEf.FlipVertical(bmp)
Img1.SetBitmap(bmp)
End Sub
Sub Btn1_Click
Dim iv As ImageView = Img1
Dim bmp As B4XBitmap = iv.Bitmap
Img1.SetBitmap(bmCEf.FlipHorizontal(bmp))
End Sub
Private Sub fillLblPicKanten
Dim bmp As B4XBitmap
Dim cs As CSBuilder
'not flipped
bmp=draws.drawGrindEdge(LblPicKanten.Width/2,LblPicKanten.Height,gv.LastAngle,2,0,False,False,True,True,True,False)
'flipped v ^
'bmp=draws.drawGrindEdge(LblPicKanten.Width/2,LblPicKanten.Height,gv.LastAngle,2,0,True,False,True,True,True,False)
cs.Initialize.Image(bmp,LblPicKanten.Width/2,LblPicKanten.Height,False).Popall
LblPicKanten.Text=cs
End Sub
public Sub drawGrindEdge(picWidth As Float,picHeight As Float, grindAngle As Float, _
doAdjust As Int, rotAngle As Float, _
flipHoriz As Boolean, flipVertical As Boolean, highlightBevelUpper As Boolean, _
highlightBevelLower As Boolean,showHelpLines As Boolean, onebevel As Boolean) As B4XBitmap
Dim canv As B4XCanvas
Dim gpx As B4XPath
'...lots of code calculating the shape of path
Dim xview As B4XView = xui.CreatePanel("")
xview.SetLayoutAnimated(0, 0, 0, picWidth, picHeight)
'... lots of code, filling canvas
canv.Initialize(xview)
canv.DrawPath(gpx,Colors.Black,True,0)
canv.Invalidate
Dim bmp As B4XBitmap=canv.CreateBitmap
If flipHoriz Then
bmp=BmEf.FlipHorizontal(bmp) 'this flip changes quality of bmp
End If
Return bmp
End Sub
If flipHoriz Then
bmp=bmEF.FlipHorizontal(ScaleBitmap(bmp))
End If
Return bmp
End Sub
Sub ScaleBitmap(bmp As B4XBitmap) As B4XBitmap
#if B4A
Dim jo As JavaObject = bmp
jo.RunMethod("setDensity", Array(160))
#End If
Return bmp
End Sub