Java ImageIcon createColorImageIcon(int w, int h, int c)

Here you can find the source of createColorImageIcon(int w, int h, int c)

Description

Create a colored image icon.

License

LGPL

Parameter

Parameter Description
w the width
h the height
c the fill color

Return

the image icon

Declaration

public static ImageIcon createColorImageIcon(int w, int h, int c) 

Method Source Code

//package com.java2s;
/*/*from   ww w .jav  a  2 s.c om*/
 * Copyright 2008-2014, David Karnok 
 * The file is part of the Open Imperium Galactica project.
 * 
 * The code should be distributed under the LGPL license.
 * See http://www.gnu.org/licenses/lgpl.html for details.
 */

import java.awt.image.BufferedImage;

import javax.swing.ImageIcon;

public class Main {
    /**
     * Create a colored image icon.
     * @param w the width
     * @param h the height
     * @param c the fill color
     * @return the image icon
     */
    public static ImageIcon createColorImageIcon(int w, int h, int c) {
        BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                img.setRGB(j, i, c);
            }
        }
        return new ImageIcon(img);
    }
}

Related

  1. absoluteDifferenceImage(ImageIcon icon1, ImageIcon icon2, double scale)
  2. componentToImageIcon(Component c, String description, boolean paintBorder)
  3. convert(ImageIcon icon)
  4. createBase64StringFromImage(ImageIcon image)
  5. createCursor(ImageIcon cursorIcon, Point hotSpot, String name)
  6. createCursor(ImageIcon icon, Point hotspot)
  7. createDisabledImage(final ImageIcon imageIcon)
  8. createEmptyImageIcon(final int width, final int height)