com.github.ojil.core.RgbMaskedImage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ojil-core Show documentation
Show all versions of ojil-core Show documentation
Open Java Imaging Library.
/*
* 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