当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Camera.getPicture方法代码示例

本文整理汇总了TypeScript中ionic-native.Camera.getPicture方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Camera.getPicture方法的具体用法?TypeScript Camera.getPicture怎么用?TypeScript Camera.getPicture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ionic-native.Camera的用法示例。


在下文中一共展示了Camera.getPicture方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: getPhoto

 getPhoto() {
   this.options = {
     destinationType: Camera.DestinationType.DATA_URL,
     sourceType: Camera.PictureSourceType.CAMERA,
     encodingType: Camera.EncodingType.JPEG,
     targetWidth: 400,
     targetHeight: 400
   };
   this.options.quality = this.cameraOpt.quality;
   this.options.allowEdit = this.cameraOpt.allowEdit;
   this.options.saveToPhotoAlbum = this.cameraOpt.saveToPhotoAlbum;
   this.options.correctOrientation = this.cameraOpt.correctOrientation;
   console.log(this.onDevice);
   if (this.onDevice) {
     Camera.getPicture(this.options).then((imageData) => {
       // imageData is either a base64 encoded string or a file URI
       // If it's base64:
       this.base64Image = "data:image/jpeg;base64," + imageData;
     }, (err) => {
       this.display.displayToast("CamĂŠra erreur : "+err);
     });
   } else {
       this.display.displayToast("CamĂŠra non disponible en mode WEB");
   }
 }
开发者ID:thgautier92,项目名称:ionicV2,代码行数:25,代码来源:camera.ts

示例2: constructor

 constructor() {
   Camera.getPicture({}).then((imageData) => {
     console.log(imageData);
   }, (error) => {
     console.log('camera error:', error);
   });
 }
开发者ID:matewka,项目名称:pgs-hackaton,代码行数:7,代码来源:scanner.ts

示例3: takePhoto

    takePhoto(){
        let options = {
			quality: 80,
			destinationType: window["Camera"].DestinationType.FILE_URI,
			encodingType: window["Camera"].EncodingType.JPEG,
			correctOrientation: true
		};
        
        Camera.getPicture(options).then(fileUrl => {
           let currentFileName = fileUrl.replace(/^.*[\\\/]/, "");
           let pathMinusFileName = fileUrl.replace(currentFileName, "");
           let newfileName = `${(new Date()).getTime()}.jpg`;
           return File.moveFile(pathMinusFileName, currentFileName, window["cordova"].file.dataDirectory, newfileName);
        }).then(fileDescriptor => {
           return fileDescriptor.nativeURL; 
        }).then(fileUrl => {
            let photo = new Photo();
            photo.filePath = fileUrl;
            console.log("fileUrl: ", fileUrl);
            this.ngZone.run( () => {
                this.photos.push(photo);    
            });
        }).catch(error => {
           alert(`Failed to take photo and persist to app storage - ${error.message}`); 
        });
    }
开发者ID:Anhmike,项目名称:ionic2-weight-tracker,代码行数:26,代码来源:WeighInForm.ts

示例4: take_photo

  take_photo(source_type: number = 1) {
    var options = {
          quality:100,
          destinationType: 1, // 0:DATA_URL ; 1: FILE_URI ; 2: NATIVE_URI
          sourceType: source_type, // 0: PHOTO_ALBUM ; 1: CAMERA ; 2: SAVEDPHOTOALBUM
          allowEdit: false,
      };
      console.log("CHECKPOINT 001");
      
      this.app_storage.set_current_geolocation();
      this.app_storage.current_time = (new Date()).toISOString();

      Camera.getPicture(options).then(
        (camera_data) => {
          console.log("Raw Image Data", camera_data);
          //var imgdata = "data:image/jpeg;base64," + results[0];
          var imgdata = camera_data;
          this.zone.run(
            () => {
              this.app_storage.current_photo.src = imgdata;
              localStorage.setItem('cover_photo_src', imgdata)
              console.log("Image Data Captured", imgdata);
            }
          );
        },
        (camera_error) => {
          let modal = Modal.create(AppModalBox, { title: "Access to Image Source Denied", content: "Sorry, we are unable to use Image Files.<br>" + JSON.stringify(camera_error) })
          this.nav.present(modal);
        }
      );
  }
开发者ID:rubyjedi,项目名称:RealBugTrackerClient,代码行数:31,代码来源:snap_it.ts

示例5: addPhoto

    /**
    * try and add a photo to the database
    *
    * @param _callback {Function} called when the process is complete
     * 
     * @memberOf ToDoService
     */
    addPhoto(_callback) {
        let that = this


        let options = {
            quality: 50,
            destinationType: 1, // Camera.DestinationType.FILE_URI,
            sourceType: 0,      // Camera.PictureSourceType.PHOTOLIBRARY,
            encodingType: 1      // Camera.EncodingType.PNG        
        };

        Camera.getPicture(options).then((imageURI) => {
            window.resolveLocalFileSystemURL(imageURI,
                (_file) => {
                    this._readImageFileFromCamera(_file, this, _callback)
                },
                (_error) => {
                    _callback({
                        success: false,
                        result: _error
                    })
                });
        }).catch((message) => {
            alert('Failed because: ' + message);
            _callback({
                success: false,
                result: message
            })
        })

    }
开发者ID:aaronksaunders,项目名称:kinvey-starter-ionic2,代码行数:38,代码来源:_todoService.ts

示例6: scanImage

  scanImage(){

    console.log('console working');

    let options = {
      destinationType: Camera.DestinationType.FILE_URI,
      sourceType: Camera.PictureSourceType.CAMERA,
      encodingType: Camera.EncodingType.JPEG,
      quality: 75,
      allowEdit: false,
      saveToPhotoAlbum: false
    }

    Camera.getPicture(options).then((fileUrl)=>{
      console.log(fileUrl);
      this.fileTransfer.upload(fileUrl, 'http://terry.jasperyap.com').then( (results)=>{
        alert(JSON.stringify(results));
      });
    },(err) => {
      if(err === 'cordova_not_available'){
        // switch out to normal
        let modal = Modal.create(CameraPage);
        this.nav.present(modal);
      }
    });
  }
开发者ID:jaspersorrio,项目名称:terry,代码行数:26,代码来源:tabs.ts

示例7:

 }).then(buttonIndex => {
     if (buttonIndex < 3) {
         Camera.getPicture({
             sourceType: buttonIndex - 1
         })
     }
     console.log('Button pressed:' + buttonLabels[buttonIndex - 1])
 })
开发者ID:iDevJS,项目名称:idevjs-ionic2,代码行数:8,代码来源:user-profile.ts

示例8: takePicture

  	takePicture(){

  		Camera.getPicture(options).then((imageData) => {
		 // imageData is either a base64 encoded string or a file URI
		 // If it's base64:
		 let base64Image = "data:image/jpeg;base64," + imageData;
		}, (err) => {
		});
  	}
开发者ID:geniepapai,项目名称:reckon2,代码行数:9,代码来源:take-photo.ts

示例9: getPicture

 private getPicture(opts: CameraOptions): void {
     console.log('gittin da pic');
     Camera.getPicture(opts)
         .then((imgData) => {
             this.photo = 'data:image/jpeg;base64,' + imgData;
         }, (er) => {
             console.error(er);
         });
 }
开发者ID:dually8,项目名称:Ionic2-Workshop,代码行数:9,代码来源:upload-page.ts

示例10: addPhoto

 addPhoto(mode:number){
   Camera.getPicture({'sourceType':mode}).then((imageData) => {
     let base64Image= "data:image/jpeg;base64," + imageData;
     if(imageData.startsWith("file"))
       base64Image=imageData;
     this.notes.push(new Note(null,base64Image,null,Date.now()))
     this.save();
   })
 }
开发者ID:themarek,项目名称:jax2016,代码行数:9,代码来源:details.ts


注:本文中的ionic-native.Camera.getPicture方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。