Java BufferedImage Operation makeTintedCopy(BufferedImage bi, Color tint)

Here you can find the source of makeTintedCopy(BufferedImage bi, Color tint)

Description

make Tinted Copy

License

Open Source License

Declaration

public static BufferedImage makeTintedCopy(BufferedImage bi, Color tint) 

Method Source Code


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

import java.awt.*;
import java.awt.image.BufferedImage;

public class Main {
    public static BufferedImage makeTintedCopy(BufferedImage bi, Color tint) {
        GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
                .getDefaultConfiguration();

        BufferedImage tinted = gc.createCompatibleImage(bi.getWidth(), bi.getHeight(), Transparency.TRANSLUCENT);

        for (int y = 0; y < bi.getHeight(); y++) {
            for (int x = 0; x < bi.getWidth(); x++) {
                int rgb = bi.getRGB(x, y);

                if (rgb != 0)
                    tinted.setRGB(x, y, tint.getRGB());
            }//from   ww  w. j  av  a  2s .  c om
        }

        return tinted;
    }
}

Related

  1. makeImageTranslucent(BufferedImage source, float alpha)
  2. makeItBlack(BufferedImage image)
  3. makeMouseover(final BufferedImage src)
  4. makeOpaque(BufferedImage img, Color col)
  5. MakePoly(BufferedImage spr, int d, int angle, int baseX, int baseY)
  6. markImageBorders(final BufferedImage img, final int startW, final int startH)
  7. matBytesToBufferedImage(byte[] data, int cols, int rows, int type)
  8. matte(BufferedImage image, int top, int bottom, int left, int right, Color bg)
  9. mirror(final BufferedImage image, final boolean horizontal)