Here you can find the source of getImage(byte[] imageBytes)
Parameter | Description |
---|---|
imageBytes | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static BufferedImage getImage(byte[] imageBytes) throws IOException
//package com.java2s; /**//from ww w . java2 s. co m * Copyright (c) 2013-2016 BITPlan GmbH * * http://www.bitplan.com * * This file is part of the Opensource project at: * https://github.com/BITPlan/com.bitplan.mjpegstreamer * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import javax.imageio.ImageIO; public class Main { /** * get the image from the given bytes * @param imageBytes * @return the image * @throws IOException */ public static BufferedImage getImage(byte[] imageBytes) throws IOException { ByteArrayInputStream jpgIn = new ByteArrayInputStream(imageBytes); BufferedImage bufImg = getImage(jpgIn); return bufImg; } /** * get the Image from the given Input Stream * @param jpgIn * @return the image * @throws IOException */ public static BufferedImage getImage(InputStream jpgIn) throws IOException { BufferedImage bufImg = ImageIO.read(jpgIn); jpgIn.close(); return bufImg; } }