【问题标题】:Resize image after capture it from native camera but before save it to SD card从本机相机捕获图像后但在将其保存到 SD 卡之前调整图像大小
【发布时间】:2012-10-08 11:01:43
【问题描述】:

我在单击按钮时在我的应用程序中打开默认相机。当我单击按钮时,它工作正常。但它捕获默认大小的图像,我想在将图像保存到 SD 卡之前重新调整大小从默认相机捕捉它。

【问题讨论】:

    标签: android android-camera android-image


    【解决方案1】:

    使用以下代码为相机意图设置适当的宽度和高度。

                Intent intent = new Intent( Intent.ACTION_PICK,
                MediaStore.Images.Media.INTERNAL_CONTENT_URI );
        intent.putExtra("outputX",
                width_of_output_image);
        intent.putExtra("outputY",
                height_of_output_image);
        intent.putExtra("aspectX", 1);
        intent.putExtra("aspectY", 1);
        intent.putExtra( "scale", true );
                startActivityForResult( intent, 1 );
    

    【讨论】:

    【解决方案2】:

    我认为这对你有帮助:-

    Bitmap.createScaledBitmap(Bitmap src, int dstWidth, int dstHeight, boolean filter);
    

    【讨论】:

      【解决方案3】:
          BitmapFactory.Options optionsSignature = new BitmapFactory.Options();
      
          final Bitmap bitmapSignature = BitmapFactory.decodeFile(
                  fileUriSignature.getPath(), optionsSignature);
      
          Bitmap resizedSignature = Bitmap.createScaledBitmap(
                  bitmapSignature, 256, 128, true);
      
          signature.setImageBitmap(resizedSignature);
      

      【讨论】:

        猜你喜欢
        • 2012-07-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-12-14
        • 2011-09-01
        相关资源
        最近更新 更多