2362N/A * Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * This class implements a lookup operation from the source 0N/A * to the destination. The LookupTable object may contain a single array 0N/A * or multiple arrays, subject to the restrictions below. 0N/A * For Rasters, the lookup operates on bands. The number of 0N/A * lookup arrays may be one, in which case the same array is 0N/A * applied to all bands, or it must equal the number of Source 0N/A * For BufferedImages, the lookup operates on color and alpha components. 0N/A * The number of lookup arrays may be one, in which case the 0N/A * same array is applied to all color (but not alpha) components. 0N/A * Otherwise, the number of lookup arrays may 0N/A * equal the number of Source color components, in which case no 0N/A * lookup of the alpha component (if present) is performed. 0N/A * If neither of these cases apply, the number of lookup arrays 0N/A * must equal the number of Source color components plus alpha components, 0N/A * in which case lookup is performed for all color and alpha components. 0N/A * This allows non-uniform rescaling of multi-band BufferedImages. 0N/A * BufferedImage sources with premultiplied alpha data are treated in the same 0N/A * manner as non-premultiplied images for purposes of the lookup. That is, 0N/A * the lookup is done per band on the raw data of the BufferedImage source 0N/A * without regard to whether the data is premultiplied. If a color conversion 0N/A * is required to the destination ColorModel, the premultiplied state of 0N/A * both source and destination will be taken into account for this step. 0N/A * Images with an IndexColorModel cannot be used. 0N/A * If a RenderingHints object is specified in the constructor, the 0N/A * color rendering hint and the dithering hint may be used when color 0N/A * conversion is required. 0N/A * This class allows the Source to be the same as the Destination. 0N/A * @see java.awt.RenderingHints#KEY_COLOR_RENDERING 0N/A * @see java.awt.RenderingHints#KEY_DITHERING 0N/A * Constructs a <code>LookupOp</code> object given the lookup 0N/A * table and a <code>RenderingHints</code> object, which might 0N/A * be <code>null</code>. 0N/A * @param lookup the specified <code>LookupTable</code> 0N/A * @param hints the specified <code>RenderingHints</code>, 0N/A * or <code>null</code> 0N/A * Returns the <code>LookupTable</code>. 0N/A * @return the <code>LookupTable</code> of this 0N/A * <code>LookupOp</code>. 0N/A * Performs a lookup operation on a <code>BufferedImage</code>. 0N/A * If the color model in the source image is not the same as that 0N/A * in the destination image, the pixels will be converted 0N/A * in the destination. If the destination image is <code>null</code>, 0N/A * a <code>BufferedImage</code> will be created with an appropriate 0N/A * <code>ColorModel</code>. An <code>IllegalArgumentException</code> 0N/A * might be thrown if the number of arrays in the 0N/A * <code>LookupTable</code> does not meet the restrictions 0N/A * stated in the class comment above, or if the source image 0N/A * has an <code>IndexColorModel</code>. 0N/A * @param src the <code>BufferedImage</code> to be filtered 0N/A * @param dst the <code>BufferedImage</code> in which to 0N/A * store the results of the filter operation 0N/A * @return the filtered <code>BufferedImage</code>. 0N/A * @throws IllegalArgumentException if the number of arrays in the 0N/A * <code>LookupTable</code> does not meet the restrictions 0N/A * described in the class comments, or if the source image 0N/A * has an <code>IndexColorModel</code>. 0N/A "performed on an indexed image");
0N/A " is not compatible with the "+
0N/A ") not equal to dst width ("+
0N/A ") not equal to dst height ("+
0N/A // Do it the slow way 0N/A // ColorModels are not the same 0N/A * Performs a lookup operation on a <code>Raster</code>. 0N/A * If the destination <code>Raster</code> is <code>null</code>, 0N/A * a new <code>Raster</code> will be created. 0N/A * The <code>IllegalArgumentException</code> might be thrown 0N/A * if the source <code>Raster</code> and the destination 0N/A * <code>Raster</code> do not have the same 0N/A * number of bands or if the number of arrays in the 0N/A * <code>LookupTable</code> does not meet the 0N/A * restrictions stated in the class comment above. 0N/A * @param src the source <code>Raster</code> to filter 0N/A * @param dst the destination <code>WritableRaster</code> for the 0N/A * filtered <code>src</code> 0N/A * @return the filtered <code>WritableRaster</code>. 0N/A * @throws IllegalArgumentException if the source and destinations 0N/A * rasters do not have the same number of bands, or the 0N/A * number of arrays in the <code>LookupTable</code> does 0N/A * not meet the restrictions described in the class comments. 0N/A // Create a new destination Raster, if needed 0N/A ") does not match number of channels" 0N/A +
" in the destination (" 0N/A " is not compatible with the "+
0N/A // Optimize for cases we know about 0N/A // Not one we recognize so do it slowly 0N/A // Find data for all bands at this x,y position 0N/A // Lookup the data for all bands at this x,y position 0N/A // Put it back for all bands 0N/A * Returns the bounding box of the filtered destination image. Since 0N/A * this is not a geometric operation, the bounding box does not 0N/A * @param src the <code>BufferedImage</code> to be filtered 0N/A * @return the bounds of the filtered definition image. 0N/A * Returns the bounding box of the filtered destination Raster. Since 0N/A * this is not a geometric operation, the bounding box does not 0N/A * @param src the <code>Raster</code> to be filtered 0N/A * @return the bounds of the filtered definition <code>Raster</code>. 0N/A * Creates a zeroed destination image with the correct size and number of 0N/A * bands. If destCM is <code>null</code>, an appropriate 0N/A * <code>ColorModel</code> will be used. 0N/A * @param src Source image for the filter operation. 0N/A * @param destCM the destination's <code>ColorModel</code>, which 0N/A * can be <code>null</code>. 0N/A * @return a filtered destination <code>BufferedImage</code>. 0N/A // Dst raster should be of type byte 0N/A // For byte, no need to change the cm 0N/A * Creates a zeroed-destination <code>Raster</code> with the 0N/A * correct size and number of bands, given this source. 0N/A * @param src the <code>Raster</code> to be transformed 0N/A * @return the zeroed-destination <code>Raster</code>. 0N/A * Returns the location of the destination point given a 0N/A * point in the source. If <code>dstPt</code> is not 0N/A * <code>null</code>, it will be used to hold the return value. 0N/A * Since this is not a geometric operation, the <code>srcPt</code> 0N/A * will equal the <code>dstPt</code>. 0N/A * @param srcPt a <code>Point2D</code> that represents a point 0N/A * in the source image 0N/A * @param dstPt a <code>Point2D</code>that represents the location 0N/A * in the destination 0N/A * @return the <code>Point2D</code> in the destination that 0N/A * corresponds to the specified point in the source. 0N/A * Returns the rendering hints for this op. 0N/A * @return the <code>RenderingHints</code> object associated 0N/A // Find the ref to the table and the offset 0N/A // Check if it is one lookup applied to all bands 0N/A // Loop through the data 0N/A // Find data for this band, scanline 0N/A // Find the ref to the table and the offset 0N/A // Check if it is one lookup applied to all bands 0N/A // Loop through the data 0N/A // Find data for this band, scanline