Has anyone been able to take pictures from camera on Android from within the app written in Delphi Firemonkey XE5? How about the video capture?
This is believed to be either a bug in a framework or just something with missing documentation about it.
Can anyone tell why the code bellow doesn't work / retrieve any image from a camera on Android?
Dropped a TCameraComponent on a form, and a TImage component as well, and nothing happens.
procedure TCameraComponentForm.OnCreate(Sender: TObject);
begin
CameraComponent1.Kind := FMX.Media.TCameraKind.ckFrontCamera;
CameraComponent1.FlashMode := FMX.Media.TFlashMode.fmFlashOff;
CameraComponent1.Active := True;
end;
procedure TCameraComponentForm.CameraComponent1SampleBufferReady(
Sender: TObject; const ATime: Int64);
begin
CameraComponent1.SampleBufferToBitmap(Image1.Bitmap, True);
Image1.Width := Image1.Bitmap.Width;
Image1.Height := Image1.Bitmap.Height;
end;
Permissions are set correctly.
This code works fine:
procedure TfrmPrincipal.SampleBufferSync;
begin
cmcPrincipal.SampleBufferToBitmap(imgFoto.Bitmap, true);
end;
procedure TfrmPrincipal.cmcPrincipalSampleBufferReady(Sender: TObject;
const ATime: Int64);
begin
TThread.Synchronize(TThread.CurrentThread, SampleBufferSync);
// CameraComponent1.SampleBufferToBitmap(imgFoto.Bitmap, True);
// imgFoto.Width := imgFoto.Bitmap.Width;
// imgFoto.Height := imgFoto.Bitmap.Height;
end;
procedure TfrmPrincipal.FormShow(Sender: TObject);
begin
cmcPrincipal.Kind := FMX.Media.TCameraKind.ckBackCamera;
try
cmcPrincipal.FlashMode := FMX.Media.TFlashMode.fmFlashOff;
except
end;
cmcPrincipal.Active := True;
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With