Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Collab canvas - Java framework for graphics software enabling offline and shared
 * painting
 * Copyright (C) 2012 Martin Indra <aktive@seznam.cz>
 *
 * This file is part of Collab canvas.
 *
 * Collab canvas is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Collab canvas is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Collab canvas.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.awt.image.BufferedImage;

public class Main {
    protected static boolean testNeighbour(BufferedImage source, int x, int y, boolean alpha) {
        if (x >= 0 && y >= 0 && x < source.getWidth() && y < source.getHeight()) {
            int gray = source.getRGB(x, y) & 0x000000ff;
            int alphaI = (source.getRGB(x, y) & 0xff000000) >>> 24;
            return (alpha && alphaI == 0) || (!alpha && gray == 255);
        }
        return true;
    }
}