Source for java.awt.image.AreaAveragingScaleFilter

   1: /* AreaAveragingScaleFilter.java -- Java class for filtering images
   2:    Copyright (C) 1999 Free Software Foundation, Inc.
   3: 
   4: This file is part of GNU Classpath.
   5: 
   6: GNU Classpath is free software; you can redistribute it and/or modify
   7: it under the terms of the GNU General Public License as published by
   8: the Free Software Foundation; either version 2, or (at your option)
   9: any later version.
  10: 
  11: GNU Classpath is distributed in the hope that it will be useful, but
  12: WITHOUT ANY WARRANTY; without even the implied warranty of
  13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14: General Public License for more details.
  15: 
  16: You should have received a copy of the GNU General Public License
  17: along with GNU Classpath; see the file COPYING.  If not, write to the
  18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19: 02110-1301 USA.
  20: 
  21: Linking this library statically or dynamically with other modules is
  22: making a combined work based on this library.  Thus, the terms and
  23: conditions of the GNU General Public License cover the whole
  24: combination.
  25: 
  26: As a special exception, the copyright holders of this library give you
  27: permission to link this library with independent modules to produce an
  28: executable, regardless of the license terms of these independent
  29: modules, and to copy and distribute the resulting executable under
  30: terms of your choice, provided that you also meet, for each linked
  31: independent module, the terms and conditions of the license of that
  32: module.  An independent module is a module which is not derived from
  33: or based on this library.  If you modify this library, you may extend
  34: this exception to your version of the library, but you are not
  35: obligated to do so.  If you do not wish to do so, delete this
  36: exception statement from your version. */
  37: 
  38: 
  39: package java.awt.image;
  40: 
  41: /**
  42:  * This filter should produce images which do not have image artifacts
  43:  * like broken lines which were originally unbroken.  The cost is of
  44:  * course speed.  Using bi-linear interpolation here against 4 pixel
  45:  * points should give the desired results although Sun does not 
  46:  * specify what the exact algorithm should be.
  47:  * <br>
  48:  * FIXME: Currently this filter does nothing and needs to be implemented.
  49:  *
  50:  * @author C. Brian Jones (cbj@gnu.org) 
  51:  */
  52: public class AreaAveragingScaleFilter extends ReplicateScaleFilter
  53: {
  54:     /**
  55:      * Construct an instance of <code>AreaAveragingScaleFilter</code> which
  56:      * should be used in conjunction with a <code>FilteredImageSource</code>
  57:      * object.
  58:      * 
  59:      * @param width the width of the destination image
  60:      * @param height the height of the destination image
  61:      */
  62:     public AreaAveragingScaleFilter(int width, int height) {
  63:     super(width, height);
  64:     }
  65: 
  66:     /**
  67:      * The <code>ImageProducer</code> should call this method with a
  68:      * bit mask of hints from any of <code>RANDOMPIXELORDER</code>,
  69:      * <code>TOPDOWNLEFTRIGHT</code>, <code>COMPLETESCANLINES</code>,
  70:      * <code>SINGLEPASS</code>, <code>SINGLEFRAME</code> from the 
  71:      * <code>ImageConsumer</code> interface.
  72:      * <br>
  73:      * FIXME - more than likely Sun's implementation desires 
  74:      * <code>TOPDOWNLEFTRIGHT</code> order and this method is overloaded here
  75:      * in order to assure that mask is part of the hints added to
  76:      * the consumer.
  77:      * 
  78:      * @param flags a bit mask of hints
  79:      * @see ImageConsumer
  80:      */
  81:     public void setHints(int flags)
  82:     {
  83:       if (consumer != null)
  84:     consumer.setHints(flags);
  85:     }
  86: 
  87:     /**
  88:      * This function delivers a rectangle of pixels where any
  89:      * pixel(m,n) is stored in the array as a <code>byte</code> at
  90:      * index (n * scansize + m + offset).  
  91:      *
  92:      * @param x the x coordinate of the rectangle
  93:      * @param y the y coordinate of the rectangle
  94:      * @param w the width of the rectangle
  95:      * @param h the height of the rectangle
  96:      * @param model the <code>ColorModel</code> used to translate the pixels
  97:      * @param pixels the array of pixel values
  98:      * @param offset the index of the first pixels in the <code>pixels</code> array
  99:      * @param scansize the width to use in extracting pixels from the <code>pixels</code> array
 100:      */
 101:     public void setPixels(int x, int y, int w, int h, 
 102:        ColorModel model, byte[] pixels, int offset, int scansize)
 103:     {
 104:       if (consumer != null)
 105:     consumer.setPixels(x, y, w, h, model, pixels, offset, scansize);
 106:     }
 107: 
 108:     /**
 109:      * This function delivers a rectangle of pixels where any
 110:      * pixel(m,n) is stored in the array as an <code>int</code> at
 111:      * index (n * scansize + m + offset).  
 112:      *
 113:      * @param x the x coordinate of the rectangle
 114:      * @param y the y coordinate of the rectangle
 115:      * @param w the width of the rectangle
 116:      * @param h the height of the rectangle
 117:      * @param model the <code>ColorModel</code> used to translate the pixels
 118:      * @param pixels the array of pixel values
 119:      * @param offset the index of the first pixels in the <code>pixels</code> array
 120:      * @param scansize the width to use in extracting pixels from the <code>pixels</code> array
 121:      */
 122:     public void setPixels(int x, int y, int w, int h, 
 123:            ColorModel model, int[] pixels, int offset, int scansize)
 124:     {
 125:       if (consumer != null)
 126:     consumer.setPixels(x, y, w, h, model, pixels, offset, scansize);
 127:     }
 128: 
 129: }