Delphi APP 開發入門(九)拍照與分享

閲讀次數:3022 發表時間:2014/07/01

Delphi APP 開發入門(八)SQLite資料庫 << 前情

在眾多行動APP中,除了遊戲類之外,熱門的APP不外乎都會與拍照、分享、地圖等相關的技術有關聯,今天筆者就與朋友們分享Delphi XE6強大的功能,只要透過簡單的設定以及短短二行程式就能實作出一個擁有拍照及分享到Facebook的APP。
一、開啟新專案後,我們在畫面上佈置放置Toolbar元件

二、接著我們要實作"拍照"以及"分享"的功能,所以在ToolBar上放置二個Button,並藉由Button的StyelLookup屬性分別設為CameraToolbutton與ActionToolButton

3.接著我們要放置一個Image,把拍照後的相片顯示在手機上,將Align設為Client填滿。

4.最後放上ActionList元件完成畫面佈置。

5.接著我們要實作拍照功能很簡單,只要在拍照的按鈕上選擇 Action -> New Standard Action ->Media Library -> TTakePhotoFromCameraAction。沒錯!Delphi XE6把複雜的拍照功能封裝起來,只要透過設定就行了!

6.由於我們要將 拍完的照片顯示在畫面的Image裡,所以在 OnDidFinishTaking裡要加上以下的程式碼

procedure TForm1.TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
begin
Image1.Bitmap.Assign(Image); // 把照片指定到Image中
end;

7.接著要實作分享功能,也是很簡單只要在分享的按鈕上選擇 Action -> New Standard Action ->Media Library -> TShowShareSheetAction。

8.同樣的,在分享前我們要把照片設定到分享的內容中,所以需要在OnBeforeExecute(分享框執行前),將照片指定到上面。

procedure TForm1.ShowShareSheetAction1BeforeExecute(Sender: TObject);
begin
ShowShareSheetAction1.Bitmap.Assign(Image1.Bitmap);
end;


我們已經把程式寫好了 
看一下執行的結果吧

查看文章

GitHub原始碼下載 https://github.com/superlevin/XE6CameraAndShare

後續 >> Delphi APP 開發入門(十)REST Client 開發

Delphi APP 開發入門(九)拍照與分享的更多相关文章

  1. Delphi APP 開發入門(十)REST Client 開發

    Delphi APP 開發入門(十)REST Client 開發 分享: Share on facebookShare on twitterShare on google_plusone_share ...

  2. Delphi APP 開發入門(五)GPS 定位功能

    Delphi APP 開發入門(五)GPS 定位功能 分享: Share on facebookShare on twitterShare on google_plusone_share   閲讀次數 ...

  3. Delphi APP 開發入門(八)SQLite資料庫

    Delphi APP 開發入門(八)SQLite資料庫 分享: Share on facebookShare on twitterShare on google_plusone_share   閲讀次 ...

  4. Delphi APP 開發入門(四)簡易手電筒

    Delphi APP 開發入門(四)簡易手電筒 分享: Share on facebookShare on twitterShare on google_plusone_share   閲讀次數:32 ...

  5. Delphi APP 開發入門(六)Object Pascal 語法初探

    Delphi APP 開發入門(六)Object Pascal 語法初探 分享: Share on facebookShare on twitterShare on google_plusone_sh ...

  6. Delphi APP 開發入門(七)通知與雲端推播

    Delphi APP 開發入門(七)通知與雲端推播 分享: Share on facebookShare on twitterShare on google_plusone_share   閲讀次數: ...

  7. Delphi APP 開發入門(三)簡易計算機

    Delphi APP 開發入門(三)簡易計算機 分享: Share on facebookShare on twitterShare on google_plusone_share   閲讀次數:68 ...

  8. Delphi APP 開發入門(二)Android/iOS設定,Hello World

    Delphi APP 開發入門(二)Android/iOS設定,Hello World 分享: Share on facebookShare on twitterShare on google_plu ...

  9. Delphi APP 開發入門(一)重生的 Delphi

    Delphi APP 開發入門(一)重生的 Delphi 分享: Share on facebookShare on twitterShare on google_plusone_share   閲讀 ...

随机推荐

  1. ubuntu 解压命令全部

    .tar解包:tar xvf FileName.tar打包:tar cvf FileName.tar DirName(注:tar是打包,不是压缩!)-------------------------- ...

  2. 《Java并发编程实战》第八章 线程池的使用 读书笔记

    一.在任务与运行策略之间的隐性解耦 有些类型的任务须要明白地指定运行策略,包含: . 依赖性任务.依赖关系对运行策略造成约束.须要注意活跃性问题. 要求线程池足够大,确保任务都能放入. . 使用线程封 ...

  3. ionic ui 框架

    直接看着这写就行了 http://ionicframework.com/docs/components/

  4. cocos中lua使用shader实例

    local prog = cc.GLProgram:create("res/shader/light2d.vsh","res/shader/light2d.fsh&quo ...

  5. 在 Ubuntu Mate 16.04 上通过 PPA 升级 Mate 1.14

    导读 Mate 桌面环境 1.14 现在可以在 Ubuntu Mate 16.04 ("Xenial Xerus") 上使用了.根据这个版本的描述,为了全面测试 Mate 1.14 ...

  6. 分布式项目中 linux 服务器 部署jar 应用脚本 deploy.sh

    在实际项目的部署中,尤其是分布式项目,有很多服务的jar包需要 部署,这里抽取出公用的 deploy的脚本 下面是不含jdk配置的 #!/bin/bash JAVA_OPTIONS_INITIAL=- ...

  7. asp 中创建日志打印文件夹

    string FilePath = HttpRuntime.BinDirectory.ToString(); string FileName = FilePath + "日志" + ...

  8. you *might* want to use the less safe log_bin_trust_function_creators variable

    报错:you *might* want to use the less safe log_bin_trust_function_creators variable 解决方法如下: 1. mysql&g ...

  9. Sonnet-十四行诗

    <Wish> Of our best wishes we could desire increase, That thereby rose's aroma might never die, ...

  10. Zabbix的API的使用

    上一篇:Zabbix低级主动发现之MySQL多实例 登录请求(返回一个token,在后面的api中需要用到) curl -s -X POST -H 'Content-Type:application/ ...