Show image stored in SQLServer in an ImageView (Java, Android Studio) [closed]

0

I'm doing an application on android with sql server and I do not know how to create the function ByteToImagen in java, that is in c # and vb.net had a function that I used to take the string of bytes [] stored in the image field of sql server, I did the conversion and I returned the image. But I'm new to java and I do not know how to achieve this result. : (

    
asked by Seto 26.04.2018 в 09:27
source

1 answer

0
public Bitmap getStringToBitmap() {
    if (getString() != null) {
        InputStream stream = new ByteArrayInputStream(getString().getBytes());
        Bitmap bitmap = BitmapFactory.decodeStream(stream);
        return bitmap;
    } else {
        return null;
    }
}

I suppose that to the chain of bytes of the SQL Server you will accede through some REST request that will return an xml, JSON or similar, getString () will be a method that simply gives you that string of bytes in String.

With this method that I put you will get a Bitmap from that chain that you can then load into an ImageView with the following instruction.

imageView.setImageBitmap(getStringToBitmap());
    
answered by 26.04.2018 / 10:19
source