我正在使用Bitmap.compres(...)
,但是我必须使用BitmapFactory为其解码一堆位图,这需要很多时间。我想以任何可以使其更快的方式跳过该解码。有办法做到吗?
for (int i = 0; i < inAssets.length; i++) {
try {
inAssetsFolder = assetManager.list("");
toWrite = new File(pathToFile);
toWrite.mkdir();
for (int j = 0; j < inAssetsFolder.length; j++) {
inputStream = assetManager.open(inAssetsFolder[j]);
bmp = BitmapFactory.decodeStream(inputStream);
image = new File(toWrite.getAbsolutePath(),inAssetsFolder[j]);
fileOutputStream = new FileOutputStream(image);
bmp.compress(Bitmap.CompressFormat.PNG, 100, fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}