Android instance-get photos from camera or gallery (xe8+ Xiaomi 2)

Source: Internet
Author: User

Results:

1. If you want to remove the local, millet mobile phone to pay attention to, can not take the network album.

Operation:

1. Two TButton (Button1 and Button2), one tactionlist (ActionList1), one timage (Image1).

2.button1 Stylelookup Choose Cameratoolbutton, Button1 stylelookup choose Organizetoolbutton.

3. Double-click ActionList1, click New Standard Action in the context menu in the Pop-up dialog box, and select Takephotofromlibraryaction ( Select a photo from the picture library and Takephotofromcameraaction (take a photo with your camera), so you have two standard Action.

4. Write the following code in the TakePhotoFromCameraAction1 ondidfinishtaking event:

Image1.Bitmap.Assign (Image);

Similarly, write the following code in the Ondidfinishtaking event of TakePhotoFromLibraryAction1:

Image1.Bitmap.Assign (Image);

5.button1 action set to Takephotofromcameraaction1,button2 is set to TakePhotoFromLibraryAction1.

Instance code:

1 UnitUnit1;2 3 Interface4 5 uses6 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;Ten  One type ATForm1 =class(Tform) - Button1:tbutton; - Button2:tbutton; the Image1:timage; - actionlist1:tactionlist; -Takephotofromlibraryaction1:ttakephotofromlibraryaction;//manually added action -Takephotofromcameraaction1:ttakephotofromcameraaction;//manually added action +     proceduretakephotofromlibraryaction1didfinishtaking (image:tbitmap); -     proceduretakephotofromcameraaction1didfinishtaking (image:tbitmap); +   Private A     {Private Declarations} at    Public -     {Public Declarations} -   End; -  - var - Form1:tform1; in  - Implementation to  + {$R *.FMX} - {$R *. NMXHDPIPH.FMX ANDROID} the  * //camera function from mobile phone $ proceduretform1.takephotofromcameraaction1didfinishtaking (image:tbitmap);Panax Notoginseng begin - Image1.Bitmap.Assign (Image); the End; +  A //local albums from the phone the proceduretform1.takephotofromlibraryaction1didfinishtaking (image:tbitmap); + begin - Image1.Bitmap.Assign (Image); $ End; $  - End.

Android instance-get photos from camera or gallery (xe8+ Xiaomi 2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.