Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Copyright (c) 2014 tabletoptool.com team.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     rptools.com team - initial implementation
 *     tabletoptool.com team - further development
 */

import java.awt.image.BufferedImage;

public class Main {
    public static BufferedImage replaceColor(BufferedImage src, int sourceRGB, int replaceRGB) {

        for (int y = 0; y < src.getHeight(); y++) {
            for (int x = 0; x < src.getWidth(); x++) {

                int rawRGB = src.getRGB(x, y);
                int rgb = rawRGB & 0xffffff;
                int alpha = rawRGB & 0xff000000;

                if (rgb == sourceRGB) {
                    src.setRGB(x, y, alpha | replaceRGB);
                }
            }
        }

        return src;
    }
}