XE6 控件太强了CameraComponent就可以了
CameraComponent1.Active := True; procedure TCameraComponentForm.CameraComponent1SampleBufferReady(Sender: TObject; const ATime: Int64);
begin
TThread.Synchronize(TThread.CurrentThread, GetImage);
// imgCameraView.Width := imgCameraView.Bitmap.Width;
// imgCameraView.Height := imgCameraView.Bitmap.Height;
end; procedure TCameraComponentForm.GetImage;
begin
CameraComponent1.SampleBufferToBitmap(imgCameraView.Bitmap, True);
end; procedure TCameraComponentForm.btnSaveClick(Sender: TObject);
var
filename: string;
begin
filename := FormatDateTime('yymmddHHmmss', Now()) + '.jpg';
filename := TPath.GetPicturesPath + PathDelim + filename;
imgCameraView.Bitmap.SaveToFile(filename);
end;
前后照相机切换,自拍模式
procedure TCameraComponentForm.btnBackCameraClick(Sender: TObject);
begin
{ select Back Camera }
CameraComponent1.Active := False;
CameraComponent1.Kind := FMX.Media.TCameraKind.BackCamera;
CameraComponent1.Active := True;
end; procedure TCameraComponentForm.btnFrontCameraClick(Sender: TObject);
begin
{ select Front Camera }
CameraComponent1.Active := False;
CameraComponent1.Kind := FMX.Media.TCameraKind.FrontCamera;
CameraComponent1.Active := True;
end;
Image1.Bitmap.Assign(Image2.Bitmap);
ImageViewer1.Bitmap.LoadFromStream(stream)