Java Byte Array to BufferedImage bytesToImage(byte[] imageData)

Here you can find the source of bytesToImage(byte[] imageData)

Description

Converts a byte array into an image.

License

Open Source License

Parameter

Parameter Description
imageData The byte array of the data to convert.

Exception

Parameter Description

Return

Image The image instance created from the byte array

Declaration

static public BufferedImage bytesToImage(byte[] imageData) throws IOException 

Method Source Code


//package com.java2s;

import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;

import java.io.IOException;
import javax.imageio.ImageIO;

public class Main {
    /**/*from  www. j a va  2  s . co  m*/
     * Converts a byte array into an image. The byte array must include the
     * image header, so that a decision about format can be made.
     *
     * @param imageData The byte array of the data to convert.
     * @return Image The image instance created from the byte array
     * @throws java.io.IOException if any.
     * @see java.awt.Toolkit#createImage(byte[] imagedata)
     */
    static public BufferedImage bytesToImage(byte[] imageData) throws IOException {
        return ImageIO.read(new ByteArrayInputStream(imageData));
    }
}

Related

  1. byteArrayToBufferedImage(byte[] image)
  2. byteArrayToImage(byte[] imagebytes)
  3. byteArrayToImage(byte[] imageData)
  4. bytesToBufferedImage(final byte[] imageData)
  5. bytesToImage(byte[] buf)
  6. bytesToImage(byte[] imageData)
  7. byteToBufferedImage(byte[] buff)
  8. byteToBufferedImage(byte[] imgBytes)