I'm using Bitmap.compres(...)
, but I have to decode a bunch of bitmaps for that using BitmapFactory which takes a lot of time. I want to skip that decoding, if it is possible, in any way that I can make it faster. Is there a way of doing that and how?
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();
}
}