From today the instruction .Rotate for a bitmap is behaving in a strange way. I think the only thing changed is that I update to iOS 14.3.
My tests The code
B4X:
Sub Cam_Complete(Success As Boolean, Image as Bitmap, VideoPath As String)
If Success Then
If Image.IsInitialized Then
btnDelete_Click 'delete previous chached images'
imgCL.ContentMode = imgCL.MODE_FIT
imgCL.Bitmap = Image
Dim out as OutputStream = File.OpenOutput(path, fname, False)
Image.Rotate(90).WriteToStream(out, 50, "JPEG")
Dim p as Phone
p.AddImageToAlbum(LoadBitmap(path, fname))
End If
End If
End Sub
This code ☝result is this image:
I changed the line 10 to:
B4X:
Image.WriteToStream(out, 50, "JPEG")
then I recompiled the app, and take another shot.
and the result was this:
this is the right real-life aspect
I'm not sure if you are joking but the second image is a completely different image to the first. Look elsewhere in your code for whatever the problem is.
I'm not sure if you are joking but the second image is a completely different image to the first. Look elsewhere in your code for whatever the problem is.
1. i compiled the app
2. I take the shot
3. I changed the line
4. i re-compiled the app
5. i taked another shot of the SAME subject just to show the differences
ok... if you take a closer look to the two images, you can immediately notice that the RESULT image when I use ".Rotate(90)" it is SQUEEZED on the Y Axes (instead of rotated 90° however).
If I remove the ".Rotate(90)" function the image result it's correct, no squeezing, no stretching.
As soon as Windows finishes the update, i try to execute the same app on an iPhone5 with iOS 11 I think
The effect is much more obvious in the video than in the original photos, where I still can't really see the stretching despite now knowing what to look for! My guess is that it is due to the EXIF information regarding the camera orientation when the photo was taken.
It is possible that the effect is caused when displaying the photo and not when saving it as the image jpg might contain conflicting width/height/EXIF information but it would need further testing to check this out. First thing I would do is put the image on a PC and display it with several different image viewers and also look at the EXIF data for the normal and the stretched versions.
I put both the images in the first post just to give to all of you a reference. I thought it was clear that the first photo isn't representing the real-world in a correct way ... compared to the one I classified like "the good one" (the second). (just compare the height and width of the two images... )
In the original project, the image file (the same I save in the Photo app of the iPhone) is sent to an FTP Server.
For obvious reasons I did not implemented this in the demo project.
however, the images are displayed in the same way on Pc too, I verified it by downloading the images from the FTP Server
I tried this tool: http://exif.regex.info/exif.cgi with the image I attach. I can't upload the image, it too large..
It says "horizontal" as orientation
The only thing I can suggest is that you try saving without rotation then reload an image from the file, rotate it and save again to see if that makes any difference.
The only thing I can suggest is that you try saving without rotation then reload an image from the file, rotate it and save again to see if that makes any difference.
@agraham i modified the Example by changing the "Cam_complete" function to:
B4X:
Sub Cam_Complete (Success As Boolean, image As Bitmap, VideoPath As String)
If Success Then
If image.IsInitialized Then
imageview.ContentMode = imageview.MODE_FIT
imageview.Bitmap = image
Dim out As OutputStream = File.OpenOutput(File.DirLibrary & "/" & "TestBitmap", "bitmap.jpeg", False)
image.WriteToStream(out, 50, "JPEG")
out.Close
Dim im As Bitmap = LoadBitmap(File.DirLibrary & "/" & "TestBitmap", "bitmap.jpeg")
If Switch1.Value Then
im = im.Rotate(90)
End If
Dim p As Phone
p.AddImageToAlbum(im)
End If
End If
End Sub
So the image saved to Album is alwasy an image loaded from the memory.
If the switch is on, then before save the image to the Album it rotates
Not necessarily, it depends on how the EXIF data is treated within an Image and written to file.
However you haven't done what I suggested and saved the rotated image to file and then reloaded it to see if it makes a difference. You have only rotated the image in memory. I don't really expect a difference as maybe rotate() is broken but try it anyway.
This is the updated function. Same result. when the switch is on, the image is squeezed instead of rotated
B4X:
Sub Cam_Complete (Success As Boolean, image As Bitmap, VideoPath As String)
If Success Then
If image.IsInitialized Then
If Switch1.Value Then
image = image.Rotate(90)
End If
imageview.ContentMode = imageview.MODE_FIT
imageview.Bitmap = image
Dim out As OutputStream = File.OpenOutput(File.DirLibrary & "/" & "TestBitmap", "bitmap.jpeg", False)
image.WriteToStream(out, 50, "JPEG")
out.Close
Dim p As Phone
p.AddImageToAlbum(image)
End If
End If
End Sub
This is the updated function. Same result. when the switch is on, the image is squeezed instead of rotated
B4X:
Sub Cam_Complete (Success As Boolean, image As Bitmap, VideoPath As String)
If Success Then
If image.IsInitialized Then
If Switch1.Value Then
image = image.Rotate(90)
End If
imageview.ContentMode = imageview.MODE_FIT
imageview.Bitmap = image
Dim out As OutputStream = File.OpenOutput(File.DirLibrary & "/" & "TestBitmap", "bitmap.jpeg", False)
image.WriteToStream(out, 50, "JPEG")
out.Close
Dim p As Phone
p.AddImageToAlbum(image)
End If
End If
End Sub
I can't do it for two reasons.
1. I don't know how to rotate a panel (no the main problem)
2. I need the FILE, because I need to send the image via FTP then. (the true reason), so I need to actually manipulate the image file.