Java BufferedImage to Byte Array getBytes(BufferedImage image)

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

Description

get Bytes

License

Open Source License

Declaration

public static byte[] getBytes(BufferedImage image) 

Method Source Code


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

import java.awt.image.BufferedImage;

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

public class Main {
    public static byte[] getBytes(BufferedImage image) {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        try {//from   w w  w  . j  a  v  a 2 s  . com
            ImageIO.write(image, "png", outputStream);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return outputStream.toByteArray();
    }
}

Related

  1. getByteArray(File file)
  2. getByteArray(RenderedImage image, String formatName)
  3. getByteBuffer(BufferedImage bufferedImage)
  4. getByteBufferToImage(ByteBuffer buffer, int width, int height)
  5. getByteImage(BufferedImage imagem)
  6. getBytes(final InputStream is, final int bufferSize)
  7. getBytesFromBufferedImage(BufferedImage bi, String format)
  8. getBytesFromImage(String fileIn, String fileOut)
  9. getBytesPerPixel(int bufferedImageType)