Jayaprakash7
6/21/2017 - 11:56 AM

Convert image into bytearray to image view and vice versa in android

Convert image into bytearray to image view and vice versa in android

byte[] decodedString = Base64.decode(newsfeedDTO.getImageDp(), Base64.DEFAULT);
        Bitmap bmp = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
        holder.imageDp.setImageBitmap(bmp);
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();