Here you can find the source of bytesToImage(byte[] buf)
Parameter | Description |
---|---|
buf | byte[] of an image as it would exist on disk |
Parameter | Description |
---|---|
IOException | an exception |
public static BufferedImage bytesToImage(byte[] buf) throws IOException
//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); } }