【问题标题】:Low resolution IONIC CAMERA低分辨率离子相机
【发布时间】:2020-05-20 17:47:12
【问题描述】:

我的应用程序中的照片分辨率有问题。我的 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);
    })
  }

}

有人会知道发生了什么错误,因为在相机选项中我将质量设置为 100。 来自图库或相机的任何照片都在应用程序中以这种低质量呈现。

【问题讨论】:

    标签: ionic-framework mobile ionic4 ionic-native


    【解决方案1】:

    您的目标宽度和高度太低...删除它们或将它们设置得更高

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-18
      • 1970-01-01
      • 2020-11-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多