1 つの画像を byte[] から Bitmap に変換して、Android アプリケーションで画像を表示しようとしています。
byte[] の値はデータベースによって取得され、null でないことを確認しました。その後、画像を変換したいのですが、うまくいきませんでした。プログラムは、Bitmap の値が null であることを示しています。
変換プロセスに問題があると思います。
何かコツをご存知の方、教えてください。
byte[] image = null;
Bitmap bitmap = null;
try {
if (rset4 != null) {
while (rset4.next()) {
image = rset4.getBytes("img");
BitmapFactory.Options options = new BitmapFactory.Options();
bitmap = BitmapFactory.decodeByteArray(image, 0, image.length, options);
}
}
if (bitmap != null) {
ImageView researcher_img = (ImageView) findViewById(R.id.researcher_img);
researcher_img.setImageBitmap(bitmap);
System.out.println("bitmap is not null");
} else {
System.out.println("bitmap is null");
}
} catch (SQLException e) {
}