On my apps, I load every drawable and I save it on phone memory, but when I do this process, all drawable change to a big resolution :
Before Compress: FileA.PNG on drawable : 423x101 ; 9,52Ko
After Compress : FileA.PNG on SD Card : 1269x303 ; 89,36Ko
Do you know how to keep the ( Before ) resolution after compress ? I try with JPEG but same result.
public void SaveImage(int resId){
Bitmap bmp = BitmapFactory.decodeResource(getResources(), resId);
try {
OutputStream fOut = null;
File file = new File(Environment.getExternalStorageDirectory() + File.separator + "Folder", getResources().getResourceEntryName(resId)+".PNG");
file.createNewFile();
fOut = new FileOutputStream(file);
bmp.compress(Bitmap.CompressFormat.PNG, 100, fOut);
fOut.flush();
fOut.close();
MediaStore.Images.Media.insertImage(this.getContentResolver(), file.getAbsolutePath(), file.getName(), file.getName());
} catch (Exception e) {
}
}
If you can give me a clue ?
Thanks,
If you store images in the drawable
folder, they gets scaled automatically according to your device's resolution, hence making different size.
You will need to store them in the folder drawable-nodpi
, or somewhere in raw
or assets
.