1

I have an array of bytes and I need to convert it into a Android Drawable.

How can I perform this conversion?

I have try this but doesn't works:

fileData is the byte[] array

Drawable image = null;
image =  new BitmapDrawable(BitmapFactory.decodeByteArray(fileData, 0, fileData.length));
Pranav Singh
  • 17,079
  • 30
  • 77
  • 104
Scabam
  • 23
  • 1
  • 2
  • 5

1 Answers1

1

used this code

byte[] imageByteArray = cursor.getBlob(cursor
                        .getColumnIndex(SQLiteAdapter.KEY_CONTENT11));

                if (imageByteArray != null) {
                    ByteArrayInputStream imageStream = new ByteArrayInputStream(
                            imageByteArray);
                    Bitmap company_logo = BitmapFactory
                            .decodeStream(imageStream);
                    img_logo.setBackgroundDrawable(null);
                    img_logo.setBackgroundDrawable(new BitmapDrawable(
                            getResources(), company_logo));
                }
GrIsHu
  • 29,068
  • 10
  • 64
  • 102
haresh
  • 321
  • 2
  • 3