I found an article telling you that you can compress the size of a picture using a Bitmap and avoid the error OutOfMemory. They show how they take those very pictures from the SD card, and I need them to take pictures from resources. How can I do it?
- oneI think the name does not quite match the question - Unick
- If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky ♦
|
1 answer
Google: android get bitmap from resources. We see the correct answer
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.image);
From your example, replace these lines:
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),"map.jpg"); Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
- @ user207012, if the answer resolves your task, then you can mark it correct by clicking on the check mark to the left of the response body. - Yuriy SPb ♦
- I can not, low reputation. - FLWRZ4U
|