Here you can find the source of generateBlankImage(int w, int h, Color col)
public static Image generateBlankImage(int w, int h, Color col)
//package com.java2s; //License from project: Open Source License import java.awt.Color; import java.awt.Graphics2D; import java.awt.Image; import java.awt.image.BufferedImage; public class Main { public static Image generateBlankImage(int w, int h, Color col) { BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = (Graphics2D) img.getGraphics(); g2.setBackground(col);/*from ww w . ja va2 s . co m*/ g2.clearRect(0, 0, w, h); return img; } }