android+删除相片代码,Android实例-从照相机或图库获取照片(XE8+小米2)

7c833a515c49584e05fff7aae796bfcb.png

结果:

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。

实例代码:

1 unitUnit1;2

3 interface

4

5 uses

6 System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,7 FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, System.Actions,8 FMX.ActnList, FMX.Objects, FMX.Controls.Presentation, FMX.StdCtrls,9 FMX.MediaLibrary.Actions, FMX.StdActns;10

11 type

12 TForm1 = class(TForm)13 Button1: TButton;14 Button2: TButton;15 Image1: TImage;16 ActionList1: TActionList;17 TakePhotoFromLibraryAction1: TTakePhotoFromLibraryAction;//手动增加的Action

18 TakePhotoFromCameraAction1: TTakePhotoFromCameraAction;//手动增加的Action

19 procedureTakePhotoFromLibraryAction1DidFinishTaking(Image: TBitmap);20 procedureTakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);21 private

22 {Private declarations}

23 public

24 {Public declarations}

25 end;26

27 var

28 Form1: TForm1;29

30 implementation

31

32 {$R *.fmx}

33 {$R *.NmXhdpiPh.fmx ANDROID}

34

35 //来自手机照相功能

36 procedureTForm1.TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);37 begin

38 Image1.Bitmap.Assign(Image);39 end;40

41 //来自手机的本地相册

42 procedureTForm1.TakePhotoFromLibraryAction1DidFinishTaking(Image: TBitmap);43 begin

44 Image1.Bitmap.Assign(Image);45 end;46

47 end.

原文:http://www.cnblogs.com/FKdelphi/p/4756871.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值