Private Sub TakePicture
Try
SetState(openstate, True, VideoMode)
Wait For(cam.FocusAndTakePicture(MyTaskIndex)) Complete (Data() As Byte)
SetState(openstate, False, VideoMode)
cam.DataToFile(Data, VideoFileDir, "1.jpg")
Dim bmp As Bitmap = cam.DataToBitmap(Data)
Log("test Picture taken: " & bmp)
Dim flippedBmp As Bitmap = FlipBitmapHorizontally(bmp) 'flip the image
If flippedBmp.IsInitialized Then
Log("test: Show the flipped image")
pnlBackground.SetVisibleAnimated(100, True)
B4XImageView1.Bitmap = flippedBmp
Log("test: Refresh the image view ")
Sleep(4000)
pnlBackground.SetVisibleAnimated(500, False)
Else
Log("Flipped image was not generated successfully")
End If
Catch
HandleError(LastException)
End Try
End Sub
Private Sub FlipBitmapHorizontally(bmp As Bitmap) As Bitmap
Dim bc As BitmapCreator
bc.Initialize(bmp.Width, bmp.Height)
For i = 0 To bmp.Height - 1
For j = 0 To bmp.Width - 1
Dim pixelColor As Int = bmp.GetPixel(j, i)
bc.SetColor(bmp.Width - j - 1, i, pixelColor) ' Flip horizontally
Next
Next
Return bc.Bitmap
End Sub