How to display blob image in Android?

I want to display an image that will be saved in the database in blob form on my Android. I use ImageView as an image container. Please offer me something soon.

Regards, Rahul

+4
source share
1 answer

There are basically two options:

  • The buffer is read from the BLOB wrapper in an InputStream, so you will have an InputStream that points to the BLOB data.
  • Saving BLOB data in a temporary file opens it as FileInputStream - so at the end you will again get the image data stream

in both cases, you can easily convert an InputStream to bitmap data as follows:

InputStream is; //stream pointing to your blob or file //... imageView=new ImageView(this); imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); imageView.setAdjustViewBounds(true); imageView.setImageBitmap(BitmapFactory.decodeStream(is)); 
+4
source

Source: https://habr.com/ru/post/1334173/


All Articles