结果:

1.如果要取本地相册的话,小米手机要注意一下,不能取网络相册。

操作:

1.两个 TButton (Button1 和 Button2) , 一个 TActionList(ActionList1) ,一个 TImage(Image1)。

2.Button1 的 stylelookup 选 择 cameratoolbutton , Button1 的 stylelookup 选择organizetoolbutton。

3.双击 ActionList1,在弹出的对话框中点击右键菜单中的new standard action,然后选择TakePhotoFromLibraryAction( 从图片库中选择照片)和TakePhotoFromCameraAction(通过相机拍摄照片),这样就加入了两个标准的 Action。

4.在 TakePhotoFromCameraAction1 的 onDidFinishTaking 事件中写如下代码:

Image1.Bitmap.Assign(Image);

同样,在 TakePhotoFromLibraryAction1 的 onDidFinishTaking 事件中写如下代码:

Image1.Bitmap.Assign(Image);

5.Button1 的 Action 设置为 TakePhotoFromCameraAction1,Button2 的 Action 设置为TakePhotoFromLibraryAction1。

实例代码:

 unit Unit1;

 interface

 uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, System.Actions,
FMX.ActnList, FMX.Objects, FMX.Controls.Presentation, FMX.StdCtrls,
FMX.MediaLibrary.Actions, FMX.StdActns; type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Image1: TImage;
ActionList1: TActionList;
TakePhotoFromLibraryAction1: TTakePhotoFromLibraryAction;//手动增加的Action
TakePhotoFromCameraAction1: TTakePhotoFromCameraAction;//手动增加的Action
procedure TakePhotoFromLibraryAction1DidFinishTaking(Image: TBitmap);
procedure TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.fmx}
{$R *.NmXhdpiPh.fmx ANDROID} //来自手机照相功能
procedure TForm1.TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
begin
Image1.Bitmap.Assign(Image);
end; //来自手机的本地相册
procedure TForm1.TakePhotoFromLibraryAction1DidFinishTaking(Image: TBitmap);
begin
Image1.Bitmap.Assign(Image);
end; end.

Android实例-从照相机或图库获取照片(XE8+小米2)的更多相关文章

  1. Android实例-拍摄和分享照片、分享文本(XE8+小米2)

    结果: 1.分享文本不好使,原因不明.有大神了解的,请M我,在此十分感谢. 2.如果想支持图片编辑,将Action事件的Editable改为True. 相关资料: 官网地址:http://docwik ...

  2. Android基础知识复习之打开照相机拍照并获取照片

    对于我来说,做一件事情: 首先要理清我的思路,我要打开照相机,我能想到的是:在Android中我要打开系统应用,肯定需要一个隐式意图,那就要查询Android照相机的源码,查看并找到意图过滤器的书写方 ...

  3. Android实例-IdHTTP下载(并实现自动安装)(XE10+小米2)

    相关资料: 1.群号 383675978 2.运行时提示"connection closed gracefully"错误原因与解决 http://www.delphifans.co ...

  4. Android拍照和从相册获取照片

    1.从相册获取照片 private void openAlumb() { //mRxPermissions:三方权限库 mRxPermissions .request(Manifest.permiss ...

  5. 【Android Developers Training】 48. 轻松拍摄照片

    注:本文翻译自Google官方的Android Developers Training文档,译者技术一般,由于喜爱安卓而产生了翻译的念头,纯属个人兴趣爱好. 原文链接:http://developer ...

  6. 移动端Vue图片获取,压缩,预览组件-upload-img(H5+获取照片,压缩,预览)

    组件示例图 组件代码 upload_img.vue <div id="uploadImg"> <div class="upload_image_box& ...

  7. 45个android实例源码

    分享45个android实例源码,很好很强大http://www.apkbus.com/android-20978-1-1.html andriod闹钟源代码http://www.apkbus.com ...

  8. 分享45个android实例源码,很好很强大

    分享45个android实例源码,很好很强大 http://www.apkbus.com/android-20978-1-1.html 分享45个android实例源码,很好很强大http://www ...

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

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

随机推荐

  1. 阿里云PHP Redis代码示例

    测试代码示例 <?php /* 这里替换为连接的实例host和port */ $host = "localhost"; $port = 6379; /* 这里替换为实例id和 ...

  2. photoshop:制作木板木纹

    1.设置颜色为木头相近颜色 2.滤镜->渲染->云彩 3.滤镜->杂色->添加杂色 4.滤镜->模糊->动感模糊 5.用矩形选取选取某块区域 6.滤镜->扭曲 ...

  3. JVM内存管理(一)

    方法区: 方法区存放了要加载的类的信息(名称.修饰符等).类的静态变量.类中定义为final类型的常量.类中的field信息.类中的方法信息.当开发人员在程序中通过Class对象的getName.is ...

  4. Layout Resource官方教程(4)<include>与<merge>

    Re-using Layouts with <include/> THIS LESSON TEACHES YOU TO Create a Re-usable Layout Use the ...

  5. Visual C#每一次新版本的变化

    What's New in Visual C# .NET 2003[Visual Studio .NET 2003] What's New in Visual C# 2005 What's New i ...

  6. Android开发之读写联系人

    读写联系人需要用到android的ContentProvider 同时需要读和写联系人的权限 需要使用到联系人数据库中的 * raw_contacts表: * contact_id:联系人id * d ...

  7. WPF程序中处理Windows消息

    首先通过WindowInteropHelper类,我们可以获取WPF Window的Handle. WindowInteropHelper helper = new WindowInteropHelp ...

  8. Java [leetcode 32]Longest Valid Parentheses

    题目描述: Given a string containing just the characters '(' and ')', find the length of the longest vali ...

  9. 【原创】深度神经网络(Deep Neural Network, DNN)

    线性模型通过特征间的现行组合来表达“结果-特征集合”之间的对应关系.由于线性模型的表达能力有限,在实践中,只能通过增加“特征计算”的复杂度来优化模型.比如,在广告CTR预估应用中,除了“标题长度.描述 ...

  10. Ruby基础类型,动态特性,代码块

    #Ruby内置基础数据类型 NilClass,TureClass,FalseClass,Time,Date,String,Range,Struct,Array,Hash #Numerice 1.分为I ...