结果:

1.同样是照相,自己的程序设置为高质量时刷新慢,而小米手机的相机那真心反映快呀。

2.就算我设置为最高质量,可相片也没有小米手机的相片大。我最大是2000*1000,而小米可以做到3000*2000,如果有人问我为什么都是整数,我会K你的。

实例代码:

 unit Unit1;

 interface

 uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
FMX.Controls.Presentation, FMX.StdCtrls, FMX.Objects, FMX.Media,
FMX.Platform,//需要引入
system.IOUtils,//需要引入
FMX.Layouts; type
TForm1 = class(TForm)
Label1: TLabel;
Image1: TImage;
GroupBox1: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
GroupBox2: TGroupBox;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
RadioButton5: TRadioButton;
GroupBox3: TGroupBox;
Button1: TButton;
Button2: TButton;
Button3: TButton;
CameraComponent1: TCameraComponent;
Timer1: TTimer;
Layout1: TLayout;
RadioButton6: TRadioButton;
RadioButton7: TRadioButton;
RadioButton8: TRadioButton;
RadioButton9: TRadioButton;
GroupBox4: TGroupBox;
RadioButton10: TRadioButton;
procedure FormCreate(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure RadioButton5Change(Sender: TObject);
procedure RadioButton1Change(Sender: TObject);
procedure RadioButton2Change(Sender: TObject);
procedure RadioButton4Change(Sender: TObject);
procedure RadioButton3Change(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure CameraComponent1SampleBufferReady(Sender: TObject;
const ATime: TMediaTime);
procedure RadioButton6Change(Sender: TObject);
procedure RadioButton7Change(Sender: TObject);
procedure RadioButton9Change(Sender: TObject);
procedure RadioButton8Change(Sender: TObject);
procedure RadioButton10Change(Sender: TObject);
private
//需要定义
function AppEvent(AAppEvent: TApplicationEvent; AContext: TObject): Boolean;
procedure GetImage;
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.fmx}
{$R *.NmXhdpiPh.fmx ANDROID} //程序事件处理
function TForm1.AppEvent(AAppEvent: TApplicationEvent;
AContext: TObject): Boolean;
begin
case AAppEvent of
TApplicationEvent.aeWillBecomeInactive: // 当程序将要变为不活动时
CameraComponent1.Active := False;
TApplicationEvent.aeEnteredBackground: // 当程序进入后台时
CameraComponent1.Active := False;
TApplicationEvent.aeWillTerminate: // 当程序将要关闭时
CameraComponent1.Active := False;
end;
end; //打开摄像头
procedure TForm1.Button1Click(Sender: TObject);
begin
CameraComponent1.Active := True;
end; //关闭摄像头
procedure TForm1.Button2Click(Sender: TObject);
begin
CameraComponent1.Active := False;
end; //保存照片
procedure TForm1.Button3Click(Sender: TObject);
begin
Image1.Bitmap.SaveToFile(TPath.GetSharedCameraPath+'/temp.jpg');
showmessage('保存成功!');
end; //从摄像头那里取相片
procedure TForm1.CameraComponent1SampleBufferReady(Sender: TObject;
const ATime: TMediaTime);
begin
GetImage;
end; procedure TForm1.FormCreate(Sender: TObject);
var
AppEventSvc: IFMXApplicationEventService;
begin
//启动一个服务,用来监控摄像头的状态
if TPlatformServices.Current.SupportsPlatformService(IFMXApplicationEventService, IInterface(AppEventSvc)) then
AppEventSvc.SetApplicationEventHandler(AppEvent); //AppEvent 为具做事的一个函数
CameraComponent1.Quality := TVideoCaptureQuality.vcPhotoQuality;//设置图像质量
//设置对焦方式
CameraComponent1.FocusMode := TFocusMode.fmContinuousAutoFocus;
end; procedure TForm1.FormResize(Sender: TObject);
begin
if Height < Width then //如果是横屏
Image1.RotationAngle := ;
if Height > Width then //如果是竖屏
if CameraComponent1.Kind = FMX.Media.TCameraKind.ckFrontCamera then//如果是前置摄像头
Image1.RotationAngle := -
else
Image1.RotationAngle := ;
end; //取相片
procedure TForm1.GetImage;
begin
CameraComponent1.SampleBufferToBitmap(Image1.Bitmap, true);
end; //选择摄像头
procedure TForm1.RadioButton1Change(Sender: TObject);
begin
//选择后置摄像头
CameraComponent1.Active := False;
CameraComponent1.Kind := FMX.Media.TCameraKind.ckBackCamera;
CameraComponent1.Active := True;
// 后置时,图像要旋转 90 度,如果是竖屏的话
if Height > Width then
Image1.RotationAngle := ;
end; procedure TForm1.RadioButton2Change(Sender: TObject);
begin
//选择前置摄像头
CameraComponent1.Active := False;
CameraComponent1.Kind := FMX.Media.TCameraKind.ckFrontCamera;
CameraComponent1.Active := True;
//前置时,图像要旋转-90 度,如果是竖屏的话
if Height > Width then
Image1.RotationAngle := -;
end; //如果有闪光灯,打开, ,但在程序运行过程中,看不出什么效果
procedure TForm1.RadioButton3Change(Sender: TObject);
begin
if CameraComponent1.HasFlash then
CameraComponent1.FlashMode := FMX.Media.TFlashMode.fmFlashOn;
end; //如果有闪光灯,关闭,但在程序运行过程中,看不出什么效果
procedure TForm1.RadioButton4Change(Sender: TObject);
begin
if CameraComponent1.HasFlash then
CameraComponent1.FlashMode := FMX.Media.TFlashMode.fmFlashOff;
end; //将闪光灯设置为自动模式
procedure TForm1.RadioButton5Change(Sender: TObject);
begin
if CameraComponent1.HasFlash then
CameraComponent1.FlashMode := FMX.Media.TFlashMode.fmAutoFlash;
end; //相片质量
procedure TForm1.RadioButton6Change(Sender: TObject);
begin
CameraComponent1.Quality := TVideoCaptureQuality.PhotoQuality;
end; //高质量
procedure TForm1.RadioButton7Change(Sender: TObject);
begin
CameraComponent1.Quality := TVideoCaptureQuality.HighQuality;
end; //中等质量
procedure TForm1.RadioButton10Change(Sender: TObject);
begin
CameraComponent1.Quality := TVideoCaptureQuality.CaptureSettings;
end; //低质量
procedure TForm1.RadioButton8Change(Sender: TObject);
begin
CameraComponent1.Quality := TVideoCaptureQuality.MediumQuality;
end; //捕捉设置
procedure TForm1.RadioButton9Change(Sender: TObject);
begin
CameraComponent1.Quality := TVideoCaptureQuality.LowQuality;
end; //刷新得到的摄像头的照片的显示
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Image1.Repaint;
end; end.

Android实例-操作摄像头(XE8+小米2)的更多相关文章

  1. Android实例-手机震动(XE8+小米2)

    相关资料:http://blog.csdn.net/laorenshen/article/details/41148843 结果: 1.打开Vibrate权限为True. 2.规律震动我没感觉出来,有 ...

  2. Android实例-LocationSensor位置传感器(XE8+小米2)

    结果: 1.启动后有时会闪退,后来重新做的工程就好了.原因不明(可能与地理反码有关). 2.原文是用的GOOGLE地图显示位置,但在咱们这里好像不行,改为百度,但百度用的是HTML文件.太麻烦了,大家 ...

  3. Android实例-MotionSensor加速度(XE8+小米2)

    结果: 1. 实例代码: unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classe ...

  4. Android实例-消息框(XE8+小米2)

    方法一支持. 方法二与方法三都是三方单元,功能相同. 方法4与方法5报错,提示平台不支持. 第三方单元一: unit Android.JNI.Toast; // Java bridge class i ...

  5. Android实例-操作sqlite数据库之Grid显示图片(XE8+小米2)

    结果: 1.数据库文件,记得打包到程序中(assets\internal\). 操作方法: 1.新建firemonkey mobile application①菜单->File->New- ...

  6. Android实例-操作sqlite数据之自建导航(XE8+小米2)

    相关资料: 源文:http://blog.sina.com.cn/s/blog_77691fb90101g9hh.html help://embarcadero.rs_xe5/rad/Mobile_T ...

  7. Android实例-实现扫描二维码并生成二维码(XE8+小米5)

    相关资料: 第三方资料太大没法写在博文上,请下载CSDN的程序包. 程序包下载: http://download.csdn.net/detail/zhujianqiangqq/9657186 注意事项 ...

  8. Android实例-调用GOOGLE的TTS实现文字转语音(XE7+小米2)(无图)

    注意:在手机上必须选安装文字转语音引擎“google Text To Speech”地址:http://www.shouji56.com/soft/GoogleWenZiZhuanYuYinYinQi ...

  9. Android实例-调用GOOGLE的TTS实现文字转语音(XE7+小米2)(XE10.1+小米5)

    相关资料: 注意:在手机上必须选安装文字转语音引擎“google Text To Speech”地址:http://www.shouji56.com/soft/GoogleWenZiZhuanYuYi ...

随机推荐

  1. Google-Gson使用

    转自:http://my.oschina.net/itblog/blog/204120 这几天,因为项目的需要,接触了Google的Gson库,发现这个东西很好用,遂记下简单的笔记,供以后参考.至于G ...

  2. 使用Data Annotations进行手动数据验证

    Data Annotations是在Asp.Net中用于表单验证的 它通过Attribute直接标记字段的有效性,简单且直观.在非Asp.Net程序中(如控制台程序),我们也可以使用Data Anno ...

  3. Stop-The-World

    Stop-The-World –Java中一种全局暂停的现象 –全局停顿,所有Java代码停止,native代码可以执行,但不能和JVM交互 –多半由于GC引起 •Dump线程 •死锁检查 •堆Dum ...

  4. 最短路径算法之四——SPFA算法

    SPAF算法 求单源最短路的SPFA算法的全称是:Shortest Path Faster Algorithm,该算法是西南交通大学段凡丁于1994年发表的. 它可以在O(kE)的时间复杂度内求出源点 ...

  5. 一个php类 Autoloader

    php autoloader: This is a class for PHP that keeps the user from having to manually include classes ...

  6. poj 1125 Stockbroker Grapevine(最短路 简单 floyd)

    题目:http://poj.org/problem?id=1125 题意:给出一个社交网络,每个人有几个别人可以传播谣言,传播谣言需要时间.问要使得谣言传播的最快,应该从那个人开始传播谣言以及使得所有 ...

  7. 从Excel表格导入数据到数据库

    数据库:SQL 1.小数据直接粘贴 2.用导入向导 3.用SSIS包 4.用SQL语句 现在详细说一下第4种方法,以.xlsx文件为例 .xlsx文件需要用provider“Microsoft.ACE ...

  8. oracle 分组排序

    SELECT * FROM (SELECT A.*, RANK() OVER(PARTITION BY A.DR_ATP_ID, A.AT_CODE ORDER BY A.KEY_CODE) RANK ...

  9. POJ 3204 Ikki's Story I-Road Reconstruction (网络流关键边)

    [题意]给定一个N个节点M条边的网络流,求有多少条边,使得当增其中加任何一个边的容量后,整个网络的流将增加. 挺好的一道题,考察对网络流和增广路的理解. [思路] 首先关键边一定是满流边.那么对于一个 ...

  10. MYSQL学习心得

    我的MYSQL学习心得(一) 简单语法 我的MYSQL学习心得(二) 数据类型宽度 我的MYSQL学习心得(三) 查看字段长度 我的MYSQL学习心得(四) 数据类型 我的MYSQL学习心得(五) 运 ...