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

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

Description

Converts the provided byte buffer into an BufferedImage

License

Apache License

Parameter

Parameter Description
buf byte[] of an image as it would exist on disk

Exception

Parameter Description
IOException an exception

Declaration

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

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.awt.image.BufferedImage;

import java.io.ByteArrayInputStream;

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

public class Main {
    /**//from  w w  w.ja va2  s .  c o  m
     * Converts the provided byte buffer into an BufferedImage
     * @param buf byte[] of an image as it would exist on disk
     * @return
     * @throws IOException
     */
    public static BufferedImage bytesToImage(byte[] buf) throws IOException {
        ByteArrayInputStream bais = new ByteArrayInputStream(buf);
        return ImageIO.read(bais);
    }
}

Related

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