Java Image to Byte Array bufferedImageToByte(BufferedImage image, String format)

Here you can find the source of bufferedImageToByte(BufferedImage image, String format)

Description

buffered Image To Byte

License

Open Source License

Declaration

public static byte[] bufferedImageToByte(BufferedImage image, String format) throws IOException 

Method Source Code

//package com.java2s;
/* autonoesis -- Automatic Movie Processor
 * Copyright (C) 2008 Shuichi Kurabayashi <Shuichi.Kurabayashi@acm.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.//  w ww. j av a2 s.  co m
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

import java.awt.image.BufferedImage;

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

public class Main {
    public static byte[] bufferedImageToByte(BufferedImage image, String format) throws IOException {
        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ImageIO.write(image, format, bos);
        return bos.toByteArray();
    }
}

Related

  1. bufferedImageToByte(BufferedImage originalImage)
  2. bufferedImageToByteArray(BufferedImage bufferedImage)
  3. bufferedImageToByteArray(BufferedImage image)
  4. bufferedImageToByteArray(BufferedImage img)