Save a BufferedImage to a Bitmap file. - Java 2D Graphics

Java examples for 2D Graphics:BufferedImage Convert

Description

Save a BufferedImage to a Bitmap file.

Demo Code


//package com.java2s;

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

import java.io.File;

public class Main {
    /**/*  ww  w  . j  a v  a2 s . c  om*/
     * Save a BufferedImage to a Bitmap file.
     */
    public static void saveBmp(BufferedImage bi, String filename) {
        try {
            ImageIO.write(bi, "bmp", new File(filename));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Related Tutorials