Please for help (it's quite urgent).
I have developed an application in B4A (for the phone) where a barcode (work order) is scanned, then we take photos of the products, which the system then uploads to that work order.
Everything works fine as long as the application is in portrait orientation (as defined in the source code itself). However, when I call the phone's camera routine for taking photos and the user switches the camera to landscape position, the system does not return the appropriate image.
I've searched the forum and found that users have the same issue, but I haven't found a suitable solution.
Could you please help? Thank you in advance...
If is code needed - here is code:
Br, DaT
I have developed an application in B4A (for the phone) where a barcode (work order) is scanned, then we take photos of the products, which the system then uploads to that work order.
Everything works fine as long as the application is in portrait orientation (as defined in the source code itself). However, when I call the phone's camera routine for taking photos and the user switches the camera to landscape position, the system does not return the appropriate image.
I've searched the forum and found that users have the same issue, but I haven't found a suitable solution.
Could you please help? Thank you in advance...
If is code needed - here is code:
Example code:
' label for taking photo
Private Sub lblTakePhoto_Click
' če ni vpisanega naloga
If lblDelNalog.Text = "" Then
Dim icon As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "stop.png", 60dip, 60dip, True)
Msgbox2Async("Wrong number of workorder!", "ChillyScanner", "Ok", "", "", icon, False)
Wait For Msgbox_Result (Echo As Int)
Return
End If
' FileName
Dim PicNum As Int = clvPhotos.Size
Dim PictureName As String = NumberFormat(PicNum + 1, 3, 0) & ".jpg"
ToastMessageShow(PictureName, True)
CurrentItem = PicNum
' Taking photo!!!
TakePicture (PictureName, 150dip, 150dip)
Wait For Image_Available(Success As Boolean, bmp As B4XBitmap)
If Success Then
' kreiramo CustomLIstView Item
clvPhotos.Add(CreateItemToClv(lblDelNalog.Text.Trim & "_" & PictureName, bmp), PictureName)
Wait For (Upload2FtpServer(PictureName)) Complete(Uspesno As Boolean)
' postavimo kurzur
clvPhotos.ScrollToItem(CurrentItem)
End If
End Sub
' Taking photo
Private Sub TakePicture (PictureName As String, TargetWidth As Int, TargetHeight As Int)
Dim i As Intent
i.Initialize("android.media.action.IMAGE_CAPTURE", "")
File.Delete(Provider.SharedFolder, PictureName)
Dim u As Object = Provider.GetFileUri(PictureName)
i.PutExtra("output", u) 'the image will be saved to this path
Try
Wait For (CallSub(KeepRunningService, "Start")) Complete (Unused As Boolean)
StartActivityForResult(i)
Wait For ion_Event (MethodName As String, Args() As Object)
CallSub(KeepRunningService, "Stop")
Dim bmp As B4XBitmap
If -1 = Args(0) Then
Try
Dim in As Intent = Args(1)
If File.Exists(Provider.SharedFolder, PictureName) Then
Dim Exif As ExifData
Exif.Initialize(Provider.SharedFolder, PictureName)
bmp = LoadBitmapSample(Provider.SharedFolder, PictureName, Max(TargetWidth, TargetHeight), Max(TargetWidth, TargetHeight))
Log("Orientation: " & Exif.getAttribute(Exif.TAG_ORIENTATION))
Select Exif.getAttribute(Exif.TAG_ORIENTATION)
Case Exif.ORIENTATION_ROTATE_180 '3
bmp = bmp.Rotate(180)
Case Exif.ORIENTATION_ROTATE_90 '6
bmp = bmp.Rotate(90)
Case Exif.ORIENTATION_ROTATE_270 '8
bmp = bmp.Rotate(270)
End Select
bmp = bmp.Resize(TargetWidth, TargetHeight, True)
Else If in.HasExtra("data") Then 'try to get thumbnail instead
Dim jo As JavaObject = in
bmp = jo.RunMethodJO("getExtras", Null).RunMethod("get", Array("data"))
End If
Catch
Log(LastException)
End Try
End If
CallSubDelayed3(Me, "Image_Available", bmp.IsInitialized, bmp)
Catch
ToastMessageShow("Camera is not available.", True)
Log(LastException)
CallSubDelayed3(Me, "Image_Available", False, Null)
End Try
End Sub
Br, DaT