将图片转为半透明,保存后没效果,高人求助!
String sourceFileName = "100480-102.jpg" ;
Drawable drawable = Drawable.createFromPath(Environment.getExternalStorageDirectory().toString() + File.separatorChar + sourceFileName);
((BitmapDrawable)drawable).getPaint().setAlpha(50);
File newFile = new File(Environment.getExternalStorageDirectory(), "1.png");
try {
newFile.createNewFile();
} catch (IOException e) {
Toast.makeText(this, e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
}
FileOutputStream fos = null;
try {
fos = new FileOutputStream(newFile);
((BitmapDrawable)drawable).getBitmap().compress(Bitmap.CompressFormat.PNG, 100,fos);
try {
fos.flush();
} catch (IOException e) {}
} catch (FileNotFoundException e) {
} finally {
try {
if (fos != null)
fos.close();
} catch (IOException e) {}
}
保存后除了体积大了,没什么不同啊