Hello
@tsteward,
You can easily do all that with the CameraEx class, I do not use Camera2 class simply because it fails on my older phones and tablet devices, where as the original CameraEx class works on both my older and newer devices and is great for taking photos too. Shrinking the photo down can be easily done too.
I personally added a routine the cycles through the phone camera modes until it finds an 3:4 ratio somewhere around the 800*600 ratio, I then set the CameraEx class to use that particular camera mode via CamExt.SetPictureSize.
In Erels example for CameraEx, I added the following to code into the Camera1_Ready sub set and take a smaller photo in size and storage space in databases.
I set the photo size with the following code, I set the physical photo size to a smaller more manageable 4:3 ratio 800*600. For example a 3Mb photo ends up being an 4:3 ratio 800*600 photo of about 800Kb in size.
'Loop through to find closest 4:3 ratio (800*600)
For Each CamResSize As CameraSize In CamExt.GetSupportedPicturesSizes
Log(CamResSize)
Dim Width As Int = CamResSize.Width
Dim Height As Int = CamResSize.Height
'GETA AS CLOSE TOO 800 BY 600 4 BY 3 AS POSSIBLE
If Height <= 600 And Width - Height + Height = Width Then
Log($"Resolution = ${Width} by ${Height}"$)
CamExt.SetJpegQuality(100) '75 = 75% out of 100% etc
CamExt.SetContinuousAutoFocus
CamExt.SetPictureSize(Width, Height)
'CamExt.SetPreviewSize(Width, Height)
CamExt.CommitParameters
CamExt.StartPreview
Log($"Preview Size = ${CamExt.GetPreviewSize.Width} by ${CamExt.GetPreviewSize.Height}"$)
Exit
End If
Next
Once I take the 4:3 ratio 800*600 photo for example, I then save the photo directly onto the device. Next I reload the saved photo using BitMap.resize, I then save the photo again using a Canvas as follows.
Setting the quality to 50 shrinks the photo size down even more to about 225Kb +/- 20%, quality is still good.
CnvPhoto.Bitmap.WriteToStream(Out, 50, Starter.FileExt) '50 = 50% quality
I have missed out the fact that I actually make an 800*800 square background and I place the 800*600 photo on top of the 800*600 background, then I save the photo. This gives me a perfectly square 800*800 photo (top and bottom can be either white or transparent), but that does not apply to you
@tsteward as you never asked for that information
You can now save the photo data directly into your database encoded as Base64, I presume that you already know how to insert data into your own online database. Don't forget to delete the previously saved photos on your device after saving the Base64 data into the database.
I personally always save photos and images directly into databases encoded as Base64, that's my personal option and if other developers don't like it that's really their problem, anyway it's just an easy no messing about solution that has never ever failed me. One of my clients is a Ford parts distributor with 1000's of photos of parts in one of my MySQL online databases on my server. Their database has been running with no issues whatsoever for well over 12 years now.
Anyway, you can use my library
HERE to easily convert photos/images into a Base64 string and back again. Just use my library to convert your last saved photo and save the Base64 string directly into your database, you can use the same library to convert and load the Base64 string directly into an ImageView again.
Please note that there are countless solution to your questions, this is just my take on it rightly or wrongly, and it runs seamlessly and fast too.
Enjoy...