convert To Buffered Image - Java 2D Graphics

Java examples for 2D Graphics:BufferedImage

Description

convert To Buffered Image

Demo Code


//package com.java2s;

import java.awt.image.BufferedImage;

public class Main {
    public static BufferedImage convertToBufferedImage(double[][] image) {
        BufferedImage bi = new BufferedImage(image[0].length, image.length,
                BufferedImage.TYPE_BYTE_GRAY);
        for (int i = 0; i < image.length; i++) {
            for (int j = 0; j < image[0].length; j++) {
                bi.getRaster().setPixel(j, i, new double[] { image[i][j] });
            }//from ww w  .  ja  va 2s  .  co m
        }
        return bi;
    }
}

Related Tutorials