In android which class corresponds to class Image of javaFX

0

I have an image server implemented in javaEE, in javaFX I make an image request to the server that returns an array of bytes, with this result I create the image on the client side:

** Image in PNG format.

byte buffer[] -> image bytes retornado pelo servidor

// no javaFX    
Image image = new Image(new ByteArrayInputStream(buffer));  

How do I create the image from the byte array in android?

On the server I read the image as follows:

private byte[] readImage(String imageName) throws FileNotFoundException
{
    File fle = new File(imageName); 
    FileInputStream new FileInputStream(fle);   

    byte buf[] = new byte[(int) fle.length()];

    rea.read(buf,0,buf.length);         

    rea.close();

    return buf;                                 
}
    
asked by anonymous 25.09.2016 / 15:21

1 answer

2

The class used in Android to work with images whose format represents a bits map is Bitmap .

Having the array bytes use the decodeByteArray () of class BitmapFactory to decode the array into a Bitmap .

Use this:

Bitmap bitmap = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.lenght);

You can resize the image at the same time it decodes by passing an object BitmapFactory.Options method decodeByteArray() , see this response .

    
25.09.2016 / 15:52