Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在android中动态创建位图,并使用Intent共享,而不会丢失质量_Android_Image_Android Intent_Bitmap - Fatal编程技术网

在android中动态创建位图,并使用Intent共享,而不会丢失质量

在android中动态创建位图,并使用Intent共享,而不会丢失质量,android,image,android-intent,bitmap,Android,Image,Android Intent,Bitmap,我使用以下代码将视图作为参数并从中创建位图: public Bitmap screenShot(View view) { Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); view.draw(canvas);

我使用以下代码将视图作为参数并从中创建位图:

public Bitmap screenShot(View view) {
        Bitmap bitmap = Bitmap.createBitmap(view.getWidth(),
                view.getHeight(), Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        view.draw(canvas);
        return bitmap;
}
现在,我使用以下代码从特定视图拍摄屏幕截图,并使用Intent进行共享:

Bitmap captured = commons.screenShot(view);
String pathofBmp = Images.Media.insertImage(getContentResolver(), captured,"title", null);
Uri bmpUri = Uri.parse(pathofBmp);
Intent emailIntent1 = new Intent(android.content.Intent.ACTION_SEND);
emailIntent1.setType("image/jpeg");
emailIntent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent1.putExtra(Intent.EXTRA_STREAM, bmpUri);
startActivity(Intent.createChooser(emailIntent1, "Share image using"));
它工作得很好。但结果是图像背景为黑色,质量较低。
例如,我搜索了很多,但问题仍然存在。
有什么想法吗?

高级感谢。

如果insertImage()降低了图片质量,为什么不将位图保存到您自己的文件中?此外,我想知道您认为“结果是图像…”中的结果是什么。在哪里可以看到结果?实际上,我不想保存文件,我只需要动态创建位图。