我正在尝试将图像保存在 sqlite 数据库中,然后再检索它。我以 byte[] 的形式存储了它。BUt 位图没有形成!
存储图像:(blob 类型)
Drawable myDrawable = getResources().getDrawable(arr[i]);
myLogo = ((BitmapDrawable) myDrawable).getBitmap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
myLogo.compress(Bitmap.CompressFormat.JPEG, 100, stream);
b = stream.toByteArray();
我的检索代码:
byte[] Image;
Image = c.getBlob(c.getColumnIndex("img_str"));
BitmapFactory.Options options = new BitmapFactory.Options();
decodedByte = BitmapFactory.decodeByteArray(Image, 0,Image.length, options);
arr_img.add(decodedByte);
System.out.println("Image = " + Image);
System.out.println("decodedByte = " + decodedByte);
日志猫:
07-22 07:15:55.482: D/skia(19319): --- SkImageDecoder::Factory returned null
07-22 07:15:55.482: I/System.out(19319): Image = [B@4057ea48
07-22 07:15:55.482: I/System.out(19319): decodedByte = null
07-22 07:15:55.521: D/dalvikvm(19319): GC_EXPLICIT freed 114K, 50% free 2871K/5639K,external 5406K/5783K, paused 43ms
07-22 07:15:55.541: D/skia(19319): --- SkImageDecoder::Factory returned null
07-22 07:15:55.541: I/System.out(19319): Image = [B@40577aa0
07-22 07:15:55.541: I/System.out(19319): decodedByte = null
请帮忙,因为我不知道为什么这不起作用。谢谢