如何在发送Android邮件时附加更高分辨率的照片

时间:2018-01-17 20:47:15

标签: android image bitmap email-attachments android-camera-intent

嗨所以我做了一个应用程序,我拍摄照片白色相机意图并将其保存在位图中,然后我压缩它并采取图像的路径并附加它,但测试后,发送测试邮件我观察到图像相当小(类似于height:100px && width: 50px但在此之后我尝试将其缩放到以下height: 500px && widht: 250px以保持image ratio,但在再次测试之后图像模糊但在我的手机图像更大,质量更好,我的问题是如何才能使图像更大,质量更好?

P.S:我压缩.JPEG文件中的位图和白色质量100%

我打算打开卡莱尔:

        img.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(i, 0);
        }
    });

我的startActivityForResult,这里是我创建img文件的地方:

    @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 0 && resultCode == RESULT_OK) {
        imgBitmap = (Bitmap) data.getExtras().get("data");
        img.setImageBitmap(imgBitmap);
        drawable = new BitmapDrawable(getResources(), imgBitmap);
        path = Environment.getExternalStorageDirectory().getAbsolutePath();
        File dir = new File(path);
        File file = new File(dir, "image.jpeg");
        FileOutputStream fOut = null;
        try {
            fOut = new FileOutputStream(file);
            imgBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
            fOut.flush();
            fOut.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } 
}

那么我可以修改哪些图像将具有更大的宽度和高度,并在将其作为附件发送后保持质量?

0 个答案:

没有答案