jpeg From Image - Java 2D Graphics

Java examples for 2D Graphics:Image

Description

jpeg From Image

Demo Code

// Licensed to the Apache Software Foundation (ASF) under one
//package com.java2s;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

public class Main {
    public static byte[] jpegFromImage(BufferedImage image)
            throws IOException {
        ByteArrayOutputStream bos = new ByteArrayOutputStream(128000);
        javax.imageio.ImageIO.write(image, "jpg", bos);

        byte[] jpegBits = bos.toByteArray();
        bos.close();/* ww  w  . j  a  v a2  s .  co  m*/
        return jpegBits;
    }
}

Related Tutorials