如何将相机拍摄的图像保存到我的电脑上

时间:2017-05-13 11:16:31

标签: typescript nativescript

这个我的组件拍照,这个Code Compiler正确 constat.ts



import { Component,OnInit } from "@angular/core";
import { Router,ActivatedRoute,NavigationExtras } from "@angular/router";
import { VoitureService } from "../../voiture/voiture.service";
import { ImageAsset } from "image-asset";
import * as camera from "nativescript-camera";

@Component({
  selector: "constat",
  moduleId:module.id,
  templateUrl: './constat.html',
  providers: [VoitureService]
})
export class ConstatComponent {

public imageTaken: ImageAsset;
    public saveToGallery: boolean = true;
    public keepAspectRatio: boolean = true;
    public width: number = 300;
    public height: number = 300;

    onTakePhoto() {
        let options = {
            width: this.width,
            height: this.height,
            keepAspectRatio: this.keepAspectRatio,
            saveToGallery: this.saveToGallery
        };

        camera.takePicture(options)
            .then(imageAsset => {
                this.imageTaken = imageAsset;
                console.log("Size: " + imageAsset.options.width + "x" + imageAsset.options.height);
            }).catch(err => {
                console.log(err.message);
            });
    }
    // << camera-module-photo-code

    // >> camera-module-perm-code
    onRequestPermissions() {
        camera.requestPermissions();
    }
    // << camera-module-perm-code

    // >> camera-module-avai-code
    onCheckForCamera() {
        let isCameraAvailable = camera.isAvailable();
        console.log("Is camera hardware available: " + isCameraAvailable);
    }
    
}
&#13;
<ActionBar title="Constat" class="heading">
     <NavigationButton text="Go Back" android.systemIcon="ic_menu_back" 
    (tap)="onTap()"></NavigationButton>
</ActionBar>

<ScrollView sdkExampleTitle sdkToggleNavButton>
    <!-- >> camera-module-html -->
    <FlexboxLayout flexDirection="column-reverse">
        <Image [src]="imageTaken" flexGrow="3" class="p-15 img-rounded"></Image>
        <Button text="Take Photo" class="btn btn-primary btn-active" (tap)="onTakePhoto()" flexGrow="1"></Button>
        <Button text="Request permissions" class="btn btn-primary btn-active" (tap)="onRequestPermissions()" flexGrow="1"></Button>
    </FlexboxLayout>
    <!-- << camera-module-html -->
</ScrollView>
&#13;
&#13;
&#13;

此图片保存在galerie中!我需要解决方案将此图像保存在我的电脑中 我怎么能保存这张图片? 我需要一些帮助

0 个答案:

没有答案