Java Image to Byte Array bufferedImageToByte(BufferedImage originalImage)

Here you can find the source of bufferedImageToByte(BufferedImage originalImage)

Description

buffered Image To Byte

License

Open Source License

Declaration

public static byte[] bufferedImageToByte(BufferedImage originalImage)
            throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.*;

public class Main {
    public static byte[] bufferedImageToByte(BufferedImage originalImage)
            throws IOException {

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ImageIO.write(originalImage, "jpg", baos);
        baos.flush();//  w  w w  . jav  a 2s .c om
        byte[] imageInByte = baos.toByteArray();
        baos.close();
        return imageInByte;
    }
}

Related

  1. bufferedImageToByte(BufferedImage image, String format)
  2. bufferedImageToByteArray(BufferedImage bufferedImage)
  3. bufferedImageToByteArray(BufferedImage image)
  4. bufferedImageToByteArray(BufferedImage img)
  5. bufferedImageToBytes(final BufferedImage bufferedImage, final ImageWriter imageWriter, final ImageWriteParam imageWriteParameter)