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. getRequestDispatcher 和sendRedirect区别及路径问题

    getRequestDispatcher 和sendRedirect区别   getRequestDispatcher是服务器内部跳转,地址栏信息不变,只能跳转到web应用内的网页. sendRedi ...

  2. php -- in_array函数

    in_array    检查数组中是否存在某个值 说明 bool in_array ( mixed $needle , array $haystack [, bool $strict = FALSE  ...

  3. 【UVa】Palindromic Subsequence(dp+字典序)

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=465&page=s ...

  4. 【BZOJ】1625: [Usaco2007 Dec]宝石手镯(01背包)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1625 太水了. #include <cstdio> #include <cstri ...

  5. leetCode 77.Combinations (组合)

    Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For exampl ...

  6. Mac终端使用mysql

    1.安装完mysql后给mysql命别名 alias mysql=/usr/local/mysql/bin/mysql aliasmysqladmin=/usr/local/mysql/bin/mys ...

  7. Object Slicing in C++

    In C++, a derived class object can be assigned to base class, but the other way is not possible. cla ...

  8. hdu 1300(dp)

    一个模式的dp. Pearls Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  9. Django学习笔记第十一篇--关于session

    一.session和sessionid: sessionid是cookie的一个字段,sessionid一般如下: """请求报文""" & ...

  10. Android开源项目分类汇总【畜生级别】

    From :http://blog.csdn.net/forlong401/article/details/25459403?c=6c4cd677a617db4655988e41ee081691#t7 ...