0

On both Android & iOS, I am successfully using TTakePhotoFromCameraAction in FMX to save photos taken by the user into a TImage.

When using TTakePhotoFromCameraAction, can I control the resolution (ultimately the size in bytes) of the photo that's taken? If so, how?

What is the best way to "post process" the resultant TImage to achieve a reduction in size? I ask this because I may need this functionality anyway if I am to begin using TTakePhotoFromLibraryAction to allow a user to choose an existing photo from their gallery.

I do need a solution that will work with both Android & iOS, please.

I am currently using Delphi 10.4.2 Sydney

Ken White
  • 123,280
  • 14
  • 225
  • 444
rhazell
  • 285
  • 1
  • 3
  • 5
  • I've removed your paragraph about purchasing a library, because its inclusion makes your post off-topic here. Questions asking (or implying that they'd like) a tool, software library or other off-site resources are not accepted here according to the [help/on-topic] guidelines. – Ken White Aug 28 '21 at 00:59
  • Not to you Ken but to the ridiculous guidelines... Isn't Delphi & FMX technically an off-site resource? – rhazell Aug 28 '21 at 02:10
  • Delphi is an IDE and programming language, and questions related to using that IDE or code are entirely appropriate here. It would be an off-site resource if you were asking which programming language to use, which is entirely different. Read the guidelines that I linked, rather than making snarky remarks when people try to help you learn the guidelines to keep yourself out of trouble here. There's a difference between asking questions about use of a programming tool or library and asking about a recommendation for one. The guidelines make that distinction quite clear. – Ken White Aug 28 '21 at 02:25
  • As far as your remark about the *ridiculous guidelines*, they exist to keep the garbage and noise away, to keep this a useful resource for programmers. If they're not to your liking, you're free to use one of the garbage collection sites like Reddit to ask your questions, but good luck finding anything with nearly as good quality there. – Ken White Aug 28 '21 at 02:31

1 Answers1

2

When using TTakePhotoFromCameraAction, can I control the resolution (ultimately the size in bytes) of the photo that's taken? If so, how?

TTakePhotoFromCameraAction has MaxWidth and MaxHeight properties.

If you use IFMXCameraService.TakePhoto() instead, it has an overload that takes a TParamsPhotoQuery parameter, which has a RequiredResolution field.

What is the best way to "post process" the resultant TImage to achieve a reduction in size? I ask this because I may need this functionality anyway if I am to begin using TTakePhotoFromLibraryAction to allow a user to choose an existing photo from their gallery.

TTakePhotoFromLibraryAction also has MaxWidth and MaxHeight properties.

And IFMXTakenImageService.TakeImageFromLibrary() has an overload that has an ARequiredResolution parameter, and an overload that takes a TParamsPhotoQuery parameter.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • Thank you got your response. Sadly Embarcadero documentation gives zero explanation of those two very important properties. – rhazell Aug 28 '21 at 02:15
  • Besides, then don't (always) work. On my Samsung S20+ the values are ignored and I always get a size of 960x720 pixels, no matter what I set these values to. I have tried setting it to 480x480 and 1024x1024 and in both cases, I get 960x720 (but the MaxWidth and MaxHeight of the TTakePhotoFromCameraAction instance still has the values I set). – HeartWare Mar 16 '23 at 09:16