get White Image - Java 2D Graphics

Java examples for 2D Graphics:Image

Description

get White Image

Demo Code


//package com.java2s;
import java.awt.Color;
import java.awt.image.BufferedImage;

public class Main {
    public static void main(String[] argv) throws Exception {
        int width = 2;
        int height = 2;
        System.out.println(getWhiteImage(width, height));
    }// w w  w  .  j  a v  a 2s  . c  o  m

    public static BufferedImage getWhiteImage(int width, int height) {
        BufferedImage image = new BufferedImage(width, height,
                BufferedImage.TYPE_INT_ARGB);

        for (int i = 0; i < width - 1; i++) {
            for (int j = 0; j < height - 1; j++) {
                image.setRGB(i, j, Color.white.getRGB());
            }
        }

        return image;
    }
}

Related Tutorials