'flips an image
'Orientation 0 = horizontally 1 = vertically 2 = both
Public Sub Flip(Image As B4XBitmap, Orientation As Int) As B4XBitmap
Private xf, yf, x, y As Int
Private col0 As ARGBColor
Private bmcImage, bmcResult As BitmapCreator
bmcImage.Initialize(Image.Width, Image.Height)
bmcImage.CopyPixelsFromBitmap(Image)
bmcResult.Initialize(Image.Width, Image.Height)
Select Orientation
Case 0
For y = 0 To Image.Height - 1
For x = 0 To Image.Width - 1
bmcImage.GetARGB(x, y, col0)
bmcResult.SetARGB(x, y, col0)
Next
Next
Case 1
For y = 0 To Image.Height - 1
For x = 0 To Image.Width - 1
xf = Image.Width - 1 - x
bmcImage.GetARGB(x, y, col0)
bmcResult.SetARGB(xf, y, col0)
Next
Next
Case 2
For y = 0 To Image.Height - 1
For x = 0 To Image.Width - 1
yf = Image.Height - 1 - y
bmcImage.GetARGB(x, y, col0)
bmcResult.SetARGB(x, yf, col0)
Next
Next
Case 3
For y = 0 To Image.Height - 1
For x = 0 To Image.Width - 1
xf = Image.Width - 1 - x
yf = Image.Height - 1 - y
bmcImage.GetARGB(x, y, col0)
bmcResult.SetARGB(xf, yf, col0)
Next
Next
End Select
Return bmcResult.Bitmap
End Sub