The code below takes a picture, saves and loads it back. However, the image after the code execution is not scaled as in the preview, it looks as if cropped and then resized to the view.
and this is the preparation of the preview
How can I get a picture back that is reasonably equal to the preview in scale?
B4X:
Sub TakePicture
Wait For(cam.FocusAndTakePicture(MyTaskIndex)) Complete (Data() As Byte)
cam.DataToFile(Data, File.DirInternal, "Chess.jpg")
cam.Stop 'must be reopened before another picture will be taken
'now load th epicture back
dstIV.Initialize("")
dstIV.Gravity=Gravity.FILL
Activity.AddView(dstIV, 0,100dip,100%X, 100%X*480/640 )
dstIV.Bitmap = LoadBitmapResize(File.DirInternal,"Chess.jpg",dstIV.Width,dstIV.Height,False)
dstIV.Invalidate
End Sub
B4X:
Sub PrepareSurface As ResumableSub
cam.PreviewSize.Initialize(640, 480)
Wait For (cam.PrepareSurface(MyTaskIndex)) Complete (Success As Boolean)
If Success Then cam.StartPreview(MyTaskIndex, VideoMode)
Return Success
End Sub
Last edited: