Reputation: 2781
I want to write an image into database as blob type. But when i load this image from database, it's different from source image. I write source image into database as follow:
ByteArrayOutputStream bs = new ByteArrayOutputStream();
Bitmap medBmp = BitmapFactory.decodeStream(this.getResources().openRawResource(R.drawable.source_image));
medBmp.compress(Bitmap.CompressFormat.JPEG, 100, bs);
initialValues.put(IMAGE_COL,bs.toByteArray());
And here are images
source image:
Image is loaded from database
The background of source image is transparent, but the image is loaded from db has background in black.why are they different?What is wrong with my code?
Please help me out, thanks you so much.
Upvotes: 1
Views: 330
Reputation: 9117
You are saving the image as JPEG, and JPEG's don't support transparency. So, you would get that black background. Try using PNG format.
Upvotes: 7