I am pleased to start a new thread. Reference: https://www.b4x.com/android/forum/threads/b4ximageview-extract-the-bitmap.141942/#post-899670
The B4XBitmap looks rotated 90 degrees at run time, but when I try to save it to storage, it is unchanged?
The B4XBitmap looks rotated 90 degrees at run time, but when I try to save it to storage, it is unchanged?
B4X:
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Private xPanel As Pane
Private B4XImageView1 As B4XImageView
Private xBitmap As B4XBitmap
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
xui.SetDataFolder("AllCases")
Dim FileDir As String = xui.DefaultFolder
Log("FileDir = " & FileDir)
Private xBitmap As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "hbavatar.jpg", B4XImageView1.mBase.Width,B4XImageView1.mBase.Height, False)
Log("bmp.IsInitialized = " & xBitmap.IsInitialized)
B4XImageView1.Bitmap = xBitmap
Log("B4XImageView1.mBase.NumberOfViews = " & B4XImageView1.mBase.NumberOfViews)
Dim xView As B4XView = B4XImageView1.mBase.GetView(0)
Log(xView)
xView = RotateViewShortestArc(xView, 0, 90)
''Sleep(500) ' nope
Dim xbmRotated As B4XBitmap = xView.GetBitmap
''Dim xbmRotated As B4XBitmap = B4XImageView1.Bitmap ' no difference
xbmRotated.WriteToStream(File.OpenOutput(FileDir, "xbmRotated.png", False), 100, "PNG")
Log("----- End AppStart")
End Sub
B4X:
Waiting for debugger to connect...
Program started.
FileDir = C:\Users\mmieher\AppData\Roaming\AllCases
bmp.IsInitialized = true
B4XImageView1.mBase.NumberOfViews = 1
(ImageView) ImageView@1793cca3[styleClass=image-view]
RotateViewShortestArc: Target = 90
----- End AppStart