This is the situation, I'm working on a routine to take pictures (camera) and I'm using the "CameraPortrait 1.10" library since it allows the camera to "work" in portrait mode, however, when you take a picture the image is rotated 90 degrees, so, I'm attemping to write a routine that will rotate it 90 degrees and save it.
The code below is the one to snap the picture, it works without a problem (this code is the sample code posted on the tutorial)
This following code is my attempt to rotate it and save it, but, it works sometimes, when it fails the phone force closes the app.
I know I'm doing something wrong but I can't figure out what since I'm still green on B4A.
Thanks
The code below is the one to snap the picture, it works without a problem (this code is the sample code posted on the tutorial)
B4X:
Sub Camera1_PictureTaken (Data() As Byte)
Dim Out As OutputStream
Out = File.OpenOutput(File.DirRootExternal, "/media/Snapshot.jpg", False)
Out.WriteBytes(Data, 0, Data.Length)
Out.Close
End Sub
This following code is my attempt to rotate it and save it, but, it works sometimes, when it fails the phone force closes the app.
B4X:
Sub FlipButton_Click
Dim Out As OutputStream
Dim Canvas1 As Canvas
Dim Bitmap1 As Bitmap
Dim DestRect As Rect
Canvas1.Initialize(PicTaken) ' <---- PicTaken is an ImageView on my layout
Bitmap1.Initialize(File.DirRootExternal, "/media/Snapshot.jpg")
DestRect.Initialize(0dip, 0dip, 320dip, 320dip)
Canvas1.DrawBitmapRotated(Bitmap1, Null, DestRect, 90)
Out = File.OpenOutput(File.DirRootExternal, "/media/Snapshot.jpg", False)
Canvas1.Bitmap.WriteToStream(Out, 75, "JPEG")
Out.Close
End Sub
I know I'm doing something wrong but I can't figure out what since I'm still green on B4A.
Thanks
Last edited: