/[classpath]/classpath/java/awt/image/LookupOp.java
ViewVC logotype

Diff of /classpath/java/awt/image/LookupOp.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by smarothy, Sat Nov 6 16:24:37 2004 UTC revision 1.2 by mark, Sun Nov 7 23:07:44 2004 UTC
# Line 1  Line 1 
1  /* ColorModel.java --  /* LookupOp.java -- Filter that converts each pixel using a lookup table.
2  Copyright (C) 2004  Free Software Foundation  Copyright (C) 2004  Free Software Foundation
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
# Line 35  this exception to your version of the li Line 35  this exception to your version of the li
35  obligated to do so.  If you do not wish to do so, delete this  obligated to do so.  If you do not wish to do so, delete this
36  exception statement from your version. */  exception statement from your version. */
37    
 /*  
  * Created on Oct 6, 2004  
  *  
  * TODO To change the template for this generated file go to  
  * Window - Preferences - Java - Code Style - Code Templates  
  */  
38  package java.awt.image;  package java.awt.image;
39    
40  import java.awt.Graphics2D;  import java.awt.Graphics2D;
# Line 67  import java.awt.geom.Rectangle2D; Line 61  import java.awt.geom.Rectangle2D;
61   *   *
62   * @author jlquinn   * @author jlquinn
63   */   */
64  public class LookupOp implements BufferedImageOp, RasterOp {  public class LookupOp implements BufferedImageOp, RasterOp
65    {
66    private LookupTable lut;    private LookupTable lut;
67    private RenderingHints hints;    private RenderingHints hints;
68        
# Line 89  public class LookupOp implements Buffere Line 84  public class LookupOp implements Buffere
84    {    {
85      if (src.getColorModel() instanceof IndexColorModel)      if (src.getColorModel() instanceof IndexColorModel)
86        throw new IllegalArgumentException("LookupOp.filter: IndexColorModel "        throw new IllegalArgumentException("LookupOp.filter: IndexColorModel "
87                                                                           + "not allowed");                                           + "not allowed");
88      if (dst == null)      if (dst == null)
89        dst = createCompatibleDestImage(src, src.getColorModel());        dst = createCompatibleDestImage(src, src.getColorModel());
90    
# Line 122  public class LookupOp implements Buffere Line 117  public class LookupOp implements Buffere
117            dr.setPixel(x, y, lut.lookupPixel(tmp, dbuf));            dr.setPixel(x, y, lut.lookupPixel(tmp, dbuf));
118          }          }
119      }      }
120      else if (lut.getNumComponents() != 1 &&      else if (lut.getNumComponents() != 1
121                   lut.getNumComponents() != src.getColorModel().getNumComponents())               &&
122        throw new IllegalArgumentException("LookupOp.filter: Incompatible lookup "               lut.getNumComponents() != src.getColorModel().getNumComponents())
123                           + "table and source image");        throw new IllegalArgumentException("LookupOp.filter: "
124                                             + "Incompatible lookup "
125                                             + "table and source image");
126    
127      // No alpha to ignore      // No alpha to ignore
128      int[] dbuf = new int[src.getColorModel().getNumComponents()];      int[] dbuf = new int[src.getColorModel().getNumComponents()];
# Line 160  public class LookupOp implements Buffere Line 157  public class LookupOp implements Buffere
157     * @see java.awt.image.BufferedImageOp#createCompatibleDestImage(java.awt.image.BufferedImage, java.awt.image.ColorModel)     * @see java.awt.image.BufferedImageOp#createCompatibleDestImage(java.awt.image.BufferedImage, java.awt.image.ColorModel)
158     */     */
159    public BufferedImage createCompatibleDestImage(BufferedImage src,    public BufferedImage createCompatibleDestImage(BufferedImage src,
160                                                                                           ColorModel dstCM)                                                   ColorModel dstCM)
161    {    {
162      // FIXME: set properties to those in src      // FIXME: set properties to those in src
163      return new BufferedImage(dstCM,      return new BufferedImage(dstCM,
164                                                  src.getRaster().createCompatibleWritableRaster(),                               src.getRaster().createCompatibleWritableRaster(),
165                                                  src.isPremultiplied, null);                               src.isPremultiplied, null);
166    }    }
167    
168    /** Return corresponding destination point for source point.    /** Return corresponding destination point for source point.
# Line 177  public class LookupOp implements Buffere Line 174  public class LookupOp implements Buffere
174     */     */
175    public Point2D getPoint2D(Point2D src, Point2D dst)    public Point2D getPoint2D(Point2D src, Point2D dst)
176    {    {
177      if (dst == null) return (Point2D)src.clone();      if (dst == null)
178          return (Point2D) src.clone();
179    
180      dst.setLocation(src);      dst.setLocation(src);
181      return dst;      return dst;
182    }    }
# Line 218  public class LookupOp implements Buffere Line 217  public class LookupOp implements Buffere
217        if (src.getNumBands() != dest.getNumBands())        if (src.getNumBands() != dest.getNumBands())
218          throw new IllegalArgumentException();          throw new IllegalArgumentException();
219    
220      if (lut.getNumComponents() != 1 && lut.getNumComponents() != src.getNumBands())      if (lut.getNumComponents() != 1
221            && lut.getNumComponents() != src.getNumBands())
222        throw new IllegalArgumentException();        throw new IllegalArgumentException();
223    
224        

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26