0
我從Web服務器獲取圖像(,它具有透明背景)。現在我需要將此圖像保存在我的SD卡上並顯示給用戶。但是,當我將圖像保存到SD卡..它節省了黑色background..i需要背景這一形象..以編程方式在android中創建透明圖像
I HV嘗試以下方法來保存圖像---
方法1:
Bitmap bitmap = BitmapFactory.decodeStream(is);
byte[] b;
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 75, bytes);
b = bytes.toByteArray();
try {
File myFile = new File("/sdcard/" + image_id + ".jpg");
myFile.createNewFile();
OutputStream filoutputStream = new FileOutputStream(myFile);
filoutputStream.write(b);
filoutputStream.flush();
filoutputStream.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.d("file", "not created");
}
方法2:
MediaStore.Images.Media.insertImage(getContentResolver(),
bitmap, "sample", "image/png");
plz幫助...
JPEG不支持透明度是這裏的關鍵! :) – Ewoks 2012-03-09 16:07:57
@Tughi你可以給示例代碼? – 2015-11-05 10:20:10