I've been browsing the API
of android for a while trying to understand the function of BitmapFactory
.
At what times am I supposed to use BitmapFactory
, and why?
I've been browsing the API
of android for a while trying to understand the function of BitmapFactory
.
At what times am I supposed to use BitmapFactory
, and why?
The BitmapFactory class creates bitmap objects to from different sources that can be files, streams, or byte-arrays . Its use is suggested when loading images from the sdcard or disk.
An example, create a bitmap object from an image stored in the sdcard and which we add to an ImageView:
ImageView imageView = (ImageView) findViewById(R.id.mi_imagen);
//Convierte a mapa de bits
Bitmap bitMap = BitmapFactory.decodeFile("/sdcard/mi_imagen.png");
//Carga imagen en imageView obtenida a partir de un recurso.
imageView.setImageBitmap(bitMap);