如何缩放jpg图像的大小

时间:2017-06-22 13:08:54

标签: java android bitmap android-bitmap

点击即可,我的用户可以在社交媒体或whatsapp中共享jpeg。

代码工作正常,但jpeg有点褪色:

String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)+"/share.jpg";
            OutputStream out = null;
            File file = new File(path);
            try {
                out = new FileOutputStream(file);
                bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
                out.flush();
                out.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
            path = file.getPath();
            Uri bmpUri = Uri.parse("file://"+path);
            Intent shareIntent = new Intent();
            shareIntent = new Intent(android.content.Intent.ACTION_SEND);
            shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
            shareIntent.setType("image/jpeg");
            startActivity(Intent.createChooser(shareIntent,"Post with"));

res \ drawable-hdpi文件夹中的jpeg文件。我尝试更改文件夹,但没有效果。 jpeg文件是185 * 200像素

0 个答案:

没有答案
相关问题