Convert byte array to BufferedImage - Java 2D Graphics

Java examples for 2D Graphics:BufferedImage Convert

Description

Convert byte array to BufferedImage

Demo Code


//package com.java2s;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;

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

public class Main {
    /**//from  w  w  w  .  ja  v  a2s. co  m
     * Convert byte array to {@link BufferedImage}
     * 
     * @param array
     * @return
     * @throws IOException
     */
    public static BufferedImage byteArrayToBufferedImage(byte[] array)
            throws IOException {
        InputStream in = new ByteArrayInputStream(array);
        BufferedImage bImageFromConvert = ImageIO.read(in);
        return bImageFromConvert;
    }
}

Related Tutorials