Android Question Camera picture size

gezueb

Active Member
Licensed User
Longtime User
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.

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
and this is the preparation of the preview
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
How can I get a picture back that is reasonably equal to the preview in scale?
 
Last edited:

gezueb

Active Member
Licensed User
Longtime User
Many thanks, Erel!
In the mean time, I found out that I can adjust the CaptureSize.Initialize value in the CamEx2 module which has the same effect. May I suggest that the that PictureSize and CaptureSize could be passed on to the CamEx2 library module in a future release (together with a list of supported sizes)?
 
Upvote 0
Top