Java Image Create makeImage(double[][] levels)

Here you can find the source of makeImage(double[][] levels)

Description

make Image

License

Open Source License

Declaration

public static BufferedImage makeImage(double[][] levels) 

Method Source Code

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

import java.awt.image.BufferedImage;

import java.awt.image.WritableRaster;

public class Main {
    public static BufferedImage makeImage(double[][] levels) {
        BufferedImage image = new BufferedImage(levels.length, levels[0].length, BufferedImage.TYPE_BYTE_GRAY);
        WritableRaster writeableRaster = image.getRaster();
        for (int i = 0; i < writeableRaster.getWidth(); ++i) {
            for (int j = 0; j < writeableRaster.getHeight(); ++j) {
                writeableRaster.setPixel(i, j, new double[] { levels[i][j] });
            }//  ww  w. ja  va2 s  .c om
        }
        return image;
    }
}

Related

  1. getImage(final int width, final int height)
  2. getImage(final String name)
  3. getImage(ImageIcon imageIcon)
  4. getImage(JComponent component)
  5. getImage(Object obj, String filePath)
  6. makeImageResizer(String srcImgPath, String targerPath, int scaledWidth, int scaledHeight, boolean preserveAlpha)