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. 测试RESTful API利器-Postman

    对于前端开发者而言,最需要的往往不是技术本身,其实技术都没什么难的,而最缺少的则是各种各样好的兵器,比如调试,开发工具等等. 我们这里就推荐一款前端开发的利器-Postman,它是Google Chr ...

  2. 【noip模拟题】天神下凡(贪心)

    vijos某次模拟赛原题... 处理出每个圆的一级祖先就行了... 其实没有那么麻烦,贪心即可出解. 我们将每个圆转换成线段后按左端点小右端点大的方法排序 然后维护一个栈: 对于每一个圆i 如果栈顶右 ...

  3. 【BZOJ】1699: [Usaco2007 Jan]Balanced Lineup排队(rmq/树状数组)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1699 我是用树状数组做的..rmq的st的话我就不敲了.. #include <cstdio& ...

  4. php和js实现文件拖拽上传

    Dropzone.js实现文件拖拽上传 http://www.sucaihuo.com/php/1399.html demo http://www.sucaihuo.com/jquery/13/139 ...

  5. Sqlite - constraint failed[0x1555]: UNIQUE constraint failed

    执行插入操作时,出现异常constraint failed[0x1555]: UNIQUE constraint failed 意思是:sqlite 唯一约束失败 定位于某个表字段上,该字段是表的主键 ...

  6. Rename a local and remote branch in git

    If you have named a branch incorrectly AND pushed this to the remote repository follow these steps b ...

  7. ios开发之 -- Swap file ".Podfile.swp" already exists!

  8. 【RF库测试】对出错的处理

    1.出错后继续执行:Run Keyword And Continue On Failure 2.获取关键字执行结果后继续执行:Run Keyword And Ignore Error 有时候,我们需要 ...

  9. tortoiseSVN如何回滚(切换至)某个历史版本?

    tortoiseSVN如何回滚(切换至)某个历史版本? 1.右键需要回滚的项目,tortoiseSVN - >show log 2.右键需要回滚的历史版本,选择revert to this re ...

  10. JsBridge的异步不执行的处理--promise异步变同步

    Hybird App:H5内嵌APP,前端用vue,APP之间的交互处理,适配安卓ios, 为了降低开发成本,减少前端适配工作量,三端统一使用  WebViewJavascriptBridge 在进行 ...