Android 如何使用intent共享透明PNG文件?
我正在使用以下代码共享生成的位图文件:Android 如何使用intent共享透明PNG文件?,android,android-intent,bitmap,Android,Android Intent,Bitmap,我正在使用以下代码共享生成的位图文件: String pathofBmp = Images.Media.insertImage(getContentResolver(), captured,"title", null); Uri bmpUri = Uri.parse(pathofBmp); Intent emailIntent1 = new Intent(android.content.Intent.ACTION_SEND); emailIntent1.setFlags(Intent.FLAG_
String pathofBmp = Images.Media.insertImage(getContentResolver(), captured,"title", null);
Uri bmpUri = Uri.parse(pathofBmp);
Intent emailIntent1 = new Intent(android.content.Intent.ACTION_SEND);
emailIntent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent1.putExtra(Intent.EXTRA_STREAM, bmpUri);
emailIntent1.setType("image/png");
startActivity(Intent.createChooser(emailIntent1, "Share image using"));
一切正常,但共享照片失去了透明背景。所以我的问题是:如何使用透明背景的Intent共享位图文件。
有什么想法吗
更新:
我用这种方式拍摄屏幕截图:
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;
}
我想它应该是这样的。是什么让你相信你失去了透明度?@ligi我测试了结果,共享图像的背景是黑色的。保存到磁盘上的图像实际上是透明的,还是保存到有背景的磁盘上?我敢打赌,问题是在您保存时发生的,而不是在您共享时。@Tanis.7x我更新了我的问题。我演示了如何拍摄屏幕截图。当你拍摄屏幕截图时,我怀疑它使用的是非透明位图,因此你保存文件时首先没有透明度。