as bm.compress(Bitmap.CompressFormat.PNG, 50, out); //here 50 will not work as PNG is lossless
有什麼辦法可以降低PNG大小?
如何縮小.png圖片大小? 也只是應付外部位置從可繪製的文件大小增加5至10倍?
Bitmap bm=BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher);
String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
File file = new File(extStorageDirectory, "ic_launcher.PNG");
outStream = new FileOutputStream(file);
bm.compress(Bitmap.CompressFormat.PNG, 100, outStream);
outStream.flush();
outStream.close();
這樣做的意義何在? (從drawable到外部應對) – Selvin
@selvin可能會出現這種情況,您想要將所有可繪製的PNG放在用戶文件夾中,以便用戶可以在其他某些應用程序中使用這些PNG ... :) –