All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.ojil.core.RgbMaskedImage Maven / Gradle / Ivy

There is a newer version: 0.0.11
Show newest version
/*
 * Copyright 2008 by Jon A. Webb
 *     This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU Lesser General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program 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 Lesser General Public License for more details.
 *
 *    You should have received a copy of the Lesser GNU General Public License
 *    along with this program.  If not, see .
 * @author webb
 */

package com.github.ojil.core;

/**
 * An RgbMaskedImage works just like an RgbImage except we use the
 * top A byte of the ARGB field as a mask value. If that byte is zero
 * the pixel is considered to be masked.
 * 
 */
public class RgbMaskedImage extends RgbImage {
    /**
     * Create a new RgbMaskedImage with the mask set to 0 (not masked)
     * @param nWidth width of image
     * @param nHeight height of image
     */
    public RgbMaskedImage(int nWidth, int nHeight) {
        super(nWidth, nHeight);
        // masked area is set to zero automatically since we
        // use unused A byte in ARGB field
    }
    
    
    /**
     * Create a new RgbMaskedImage from an existing RgbImage,
     * copying the pixel values and initializing it to unmasked.
     * @param rgb input RgbImage to use as a source.
     */
    public RgbMaskedImage(RgbImage rgb) {
        super(rgb.getWidth(), rgb.getHeight());
        // simply ocpy the RGB values into my array. The
        // A value will always be set to 0 in an RgbImage so
        // the image is automatically not masked.
        System.arraycopy(rgb.getData(), 0, super.getData(), 0, 
                super.getWidth() * super.getHeight());
        // ensure that all pixels are initially unmasked.
        for (int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy