Hi all,
today I used Mediachooser to take a couple of photos, limiting the file size, but I found that a "complex" image returns an error about the final file size exceeding the limit imposed.
With "complex" image I mean an image with many colors and labels. The same code on a simpler version of the same image doesn't raise the error.
I tried the following code:
The only change in Erel's code is about a parameter for ShowMedia which is used to select among two different target panels.
MaxImageFileSize alone raised the error about file size
MaxImageSize was an attempt to keep the image smaller "before" saving to a file, but it didn't work
So, the question is: how to save to a 2MB (or less) file an image taken with a camera able to take photos at 12Mpixels (or whatever) ?
Or should I leave a file size limit high enough for the camera and make use of panel.snapshot to save a smaller file?
Fundamentally, I'd like to save a couple of photos along with other simple data in a compact "message" to be sent to a remore server. The goal is to minimize data traffic in both directions.
TIA
today I used Mediachooser to take a couple of photos, limiting the file size, but I found that a "complex" image returns an error about the final file size exceeding the limit imposed.
With "complex" image I mean an image with many colors and labels. The same code on a simpler version of the same image doesn't raise the error.
I tried the following code:
B4X:
smm.MaxImageSize = 1 * 1024 * 1024
smm.MaxImageFileSize = 4 * 1024 * 1024
'...
Private Sub lblTakeFr_Click
KeepRunningService.NotificationTitle = "Taking a photo"
Wait For (chooser.CaptureImage) Complete (Result As MediaChooserResult)
ShowMedia(pnlFronte,Result)
End Sub
Private Sub ShowMedia (apnl As B4XView, Result As MediaChooserResult)
If Result.Success Then
smm.SetMediaFromFile(apnl, Result.MediaDir, Result.MediaFile, Result.Mime, Null)
Else
apnl.RemoveAllViews
Log("errore smm")
End If
End Sub
MaxImageFileSize alone raised the error about file size
MaxImageSize was an attempt to keep the image smaller "before" saving to a file, but it didn't work
So, the question is: how to save to a 2MB (or less) file an image taken with a camera able to take photos at 12Mpixels (or whatever) ?
Or should I leave a file size limit high enough for the camera and make use of panel.snapshot to save a smaller file?
Fundamentally, I'd like to save a couple of photos along with other simple data in a compact "message" to be sent to a remore server. The goal is to minimize data traffic in both directions.
TIA