Advanced camera library causing error on some devices and not others.

Mickster

Active Member
Licensed User
Longtime User
Hey guys,

I'm using this library to change the resolution of images I'm taking on a Toshiba Thrive device, which is working perfectly fine. We are also running the same code on a Motorola Xoom tablet (very similar in specs to the thrive) and the line that modifies the resolution is causing a runtimeexception.

Has anyone seen this before?

Here is the routine causing the crash:

B4X:
Sub Camera1_Ready (Success As Boolean)

    If Success Then
'        Camera1.PictureSize(pnlCamera.Width, pnlCamera.Height)
        Camera1.StartPreview
        btnTakePicture.Enabled = True
    Else
        ToastMessageShow("Cannot open camera.", True)
    End If
    
End Sub
I commented out the line that is causing the issue for clarity.

Thanks
 

Ian Garton

Member
Licensed User
Longtime User
Different devices support different image resolutions.

I had to use the SupportedPictureSize property, and the getSupportedPictureSizeWidth and getSupportedPictureSizeHeight methods to work out a suitable size at runtime.
 
Upvote 0

Mickster

Active Member
Licensed User
Longtime User
Ah, I should have been more specific. I was asking Ian Garton to elaborate!

Different devices support different image resolutions.

I had to use the SupportedPictureSize property, and the getSupportedPictureSizeWidth and getSupportedPictureSizeHeight methods to work out a suitable size at runtime.
 
Upvote 0

vb1992

Well-Known Member
Licensed User
Longtime User
I don't know, if someone told me to look in the example link for the answer...
I would...

because the answer is there,
I would have opened up the file

this is inside

B4X:
Try
      lstResolution.Clear
      For i = 0 To objCamera.SupportedPictureSize - 1
         lstResolution.Add(objCamera.getSupportedPictureSizeWidth(i) & "x" & objCamera.getSupportedPictureSizeHeight(i))
         If objCamera.CurrentPictureSizeWidth= objCamera.getSupportedPictureSizeWidth(i) AND _
         objCamera.CurrentPictureSizeHeight = objCamera.getSupportedPictureSizeHeight(i) Then
            LastResolution = lstResolution.Get(i)
         End If
      Next
   Catch
   End Try
 
Last edited:
Upvote 0
Top