1

バイト配列があり、それを Android Drawable に変換する必要があります。

この変換を実行するにはどうすればよいですか?

私はこれを試しましたが、うまくいきません:

fileDatabyte[]配列です

Drawable image = null;
image =  new BitmapDrawable(BitmapFactory.decodeByteArray(fileData, 0, fileData.length));
4

1 に答える 1

1

このコードを使用しました

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));
                }
于 2013-06-27T11:46:56.650 に答える