低分辨率IONIC CAMERA

问题描述 投票:1回答:1

我的应用程序中的照片分辨率有问题。我的TS文件。这与以下配置。

import { Component, OnInit } from '@angular/core';
import { PictureSourceType, Camera, CameraOptions } from '@ionic-native/camera/ngx';
import { Router } from '@angular/router';
import { ActionSheetController } from '@ionic/angular';


@Component({
  selector: 'app-pic-register',
  templateUrl: './pic-register.page.html',
  styleUrls: ['./pic-register.page.scss'],
})

export class PicRegisterPage implements OnInit {

   public photo: string;

  constructor(
    private router: Router,
    private camera: Camera,
    private ActionSheetController: ActionSheetController

  ) { }


  ngOnInit() {
  }

  updateStoredImage(image) {

  }

  documentFront(){
    console.log('aqui');
    this.router.navigateByUrl('/register/document-front')
  }


  async selectImage() {


    const actionSheet = await this.ActionSheetController.create({
      header: 'Selecione uma image',
      buttons: [{
        text: 'Galeria',
        icon: 'file-tray-full-outline',
        handler: () => {
          this.takePicture(this.camera.PictureSourceType.PHOTOLIBRARY);
        }
      }, {
        text: 'Camera',
        icon: 'camera',
        handler: () => {
          this.takePicture(this.camera.PictureSourceType.CAMERA)
        }
      }, {
        text: 'Cancelar',
        role: 'cancel',
        icon: 'log-out-outline',
      }]
    });
    await actionSheet.present();

  }

  takePicture(sourceType: PictureSourceType) {

    this.photo = '';

    var options: CameraOptions = {
      quality: 100,
      sourceType: sourceType,
      saveToPhotoAlbum: false,
      correctOrientation: true,
      destinationType: this.camera.DestinationType.NATIVE_URI,
      encodingType: this.camera.EncodingType.JPEG,
      mediaType: this.camera.MediaType.PICTURE,
      targetWidth: 100,
      targetHeight: 100
    }

    this.camera.getPicture(options).then(imageData => {
      let base64image = 'data:image/jpeg;base64,' + imageData;
      this.photo = base64image;
    }, error =>{
      console.log(error);
    }).catch(error => {
      console.log(error);
    })
  }

}

enter image description here

有人知道是什么错误吗? 因为在相机选项中,我把质量调到了100. 任何来自图库或相机的照片都会在应用程序中以这种低质量的方式呈现。

ionic-framework mobile ionic4 ionic-native
1个回答
1
投票

你的目标宽度和高度太低了......删除它们或者设置得更高一些。

© www.soinside.com 2019 - 2024. All rights reserved.