Java BufferedImage to Byte Array toByteArray(BufferedImage image)

Here you can find the source of toByteArray(BufferedImage image)

Description

to Byte Array

License

Open Source License

Declaration

public static byte[] toByteArray(BufferedImage image) 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.ByteArrayOutputStream;
import java.io.IOException;

public class Main {
    public static byte[] toByteArray(BufferedImage image) throws IOException {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        ImageIO.write(image, "png", outputStream);
        return outputStream.toByteArray();
    }//www. ja  v a 2 s. com
}

Related

  1. imageToByteArray(BufferedImage o)
  2. imageToBytes(BufferedImage image, String encoding)
  3. imageToBytes(BufferedImage image, String imageFormat)
  4. imageToBytes(BufferedImage img, String formatName)
  5. toArrayByte(BufferedImage image)
  6. toByteArray(BufferedImage image, float quality)
  7. toByteArray(BufferedImage image, String extension)
  8. toByteArray(BufferedImage image, String formatName)
  9. toByteArray(BufferedImage img, String imageFileType)