iOS Question Picture is rotated after saved to disk

tufanv

Expert
Licensed User
Longtime User
Hello,

I am using cam to make the user select a picture from the disk and save it to file.dirdocuments. After that I always load the saved picture as profile pic. BUT when I load the image selected from the cam, there is no problem but after I load the pic that I saved to file.dirdocuments it is always rotated 90 degress.

I use the following code to save the pic:

B4X:
Sub Cam_Complete (Success As Boolean, Image As Bitmap, VideoPath As String)
    If Success Then
        If Image.IsInitialized Then
            imgmypic.Bitmap = Image
            Dim out As OutputStream = File.OpenOutput(File.DirDocuments, "mypic.png", False)
            Image.WriteToStream(out,100,"PNG")
            out.Close
        Else
        End If
    End If
End Sub

And to load:

B4X:
                If File.Exists(File.DirDocuments,"mypic.png") Then
                Log("exist")
                    imgmypic.Bitmap=LoadBitmap(File.DirDocuments,"mypic.png")
                Else
                Log("no")
                End If
                Else

How can I prevent the rotation?
 

agraham

Expert
Licensed User
Longtime User
Don't know why png does that.
A jpg saves the orientation at which is taken in the metadata for the picture so a control that displays a jpg usually shows it in the correct orientation. png doesn't have this capability so only displays in one orientation.
 
Upvote 0
Top