< prev index next >

src/java.desktop/share/classes/java/awt/image/AreaAveragingScaleFilter.java

Print this page




  65     private boolean passthrough;
  66     private float reds[], greens[], blues[], alphas[];
  67     private int savedy;
  68     private int savedyrem;
  69 
  70     /**
  71      * Constructs an AreaAveragingScaleFilter that scales the pixels from
  72      * its source Image as specified by the width and height parameters.
  73      * @param width the target width to scale the image
  74      * @param height the target height to scale the image
  75      */
  76     public AreaAveragingScaleFilter(int width, int height) {
  77         super(width, height);
  78     }
  79 
  80     /**
  81      * Detect if the data is being delivered with the necessary hints
  82      * to allow the averaging algorithm to do its work.
  83      * <p>
  84      * Note: This method is intended to be called by the
  85      * <code>ImageProducer</code> of the <code>Image</code> whose
  86      * pixels are being filtered.  Developers using
  87      * this class to filter pixels from an image should avoid calling
  88      * this method directly since that operation could interfere
  89      * with the filtering operation.
  90      * @see ImageConsumer#setHints
  91      */
  92     public void setHints(int hints) {
  93         passthrough = ((hints & neededHints) != neededHints);
  94         super.setHints(hints);
  95     }
  96 
  97     private void makeAccumBuffers() {
  98         reds = new float[destWidth];
  99         greens = new float[destWidth];
 100         blues = new float[destWidth];
 101         alphas = new float[destWidth];
 102     }
 103 
 104     private int[] calcRow() {
 105         float origmult = ((float) srcWidth) * srcHeight;


 219             }
 220             if (syrem == 0) {
 221                 syrem = destHeight;
 222                 sy++;
 223                 off += scansize;
 224             }
 225         }
 226         savedyrem = dyrem;
 227         savedy = dy;
 228     }
 229 
 230     /**
 231      * Combine the components for the delivered byte pixels into the
 232      * accumulation arrays and send on any averaged data for rows of
 233      * pixels that are complete.  If the correct hints were not
 234      * specified in the setHints call then relay the work to our
 235      * superclass which is capable of scaling pixels regardless of
 236      * the delivery hints.
 237      * <p>
 238      * Note: This method is intended to be called by the
 239      * <code>ImageProducer</code> of the <code>Image</code>
 240      * whose pixels are being filtered.  Developers using
 241      * this class to filter pixels from an image should avoid calling
 242      * this method directly since that operation could interfere
 243      * with the filtering operation.
 244      * @see ReplicateScaleFilter
 245      */
 246     public void setPixels(int x, int y, int w, int h,
 247                           ColorModel model, byte pixels[], int off,
 248                           int scansize) {
 249         if (passthrough) {
 250             super.setPixels(x, y, w, h, model, pixels, off, scansize);
 251         } else {
 252             accumPixels(x, y, w, h, model, pixels, off, scansize);
 253         }
 254     }
 255 
 256     /**
 257      * Combine the components for the delivered int pixels into the
 258      * accumulation arrays and send on any averaged data for rows of
 259      * pixels that are complete.  If the correct hints were not
 260      * specified in the setHints call then relay the work to our
 261      * superclass which is capable of scaling pixels regardless of
 262      * the delivery hints.
 263      * <p>
 264      * Note: This method is intended to be called by the
 265      * <code>ImageProducer</code> of the <code>Image</code>
 266      * whose pixels are being filtered.  Developers using
 267      * this class to filter pixels from an image should avoid calling
 268      * this method directly since that operation could interfere
 269      * with the filtering operation.
 270      * @see ReplicateScaleFilter
 271      */
 272     public void setPixels(int x, int y, int w, int h,
 273                           ColorModel model, int pixels[], int off,
 274                           int scansize) {
 275         if (passthrough) {
 276             super.setPixels(x, y, w, h, model, pixels, off, scansize);
 277         } else {
 278             accumPixels(x, y, w, h, model, pixels, off, scansize);
 279         }
 280     }
 281 }


  65     private boolean passthrough;
  66     private float reds[], greens[], blues[], alphas[];
  67     private int savedy;
  68     private int savedyrem;
  69 
  70     /**
  71      * Constructs an AreaAveragingScaleFilter that scales the pixels from
  72      * its source Image as specified by the width and height parameters.
  73      * @param width the target width to scale the image
  74      * @param height the target height to scale the image
  75      */
  76     public AreaAveragingScaleFilter(int width, int height) {
  77         super(width, height);
  78     }
  79 
  80     /**
  81      * Detect if the data is being delivered with the necessary hints
  82      * to allow the averaging algorithm to do its work.
  83      * <p>
  84      * Note: This method is intended to be called by the
  85      * {@code ImageProducer} of the {@code Image} whose
  86      * pixels are being filtered.  Developers using
  87      * this class to filter pixels from an image should avoid calling
  88      * this method directly since that operation could interfere
  89      * with the filtering operation.
  90      * @see ImageConsumer#setHints
  91      */
  92     public void setHints(int hints) {
  93         passthrough = ((hints & neededHints) != neededHints);
  94         super.setHints(hints);
  95     }
  96 
  97     private void makeAccumBuffers() {
  98         reds = new float[destWidth];
  99         greens = new float[destWidth];
 100         blues = new float[destWidth];
 101         alphas = new float[destWidth];
 102     }
 103 
 104     private int[] calcRow() {
 105         float origmult = ((float) srcWidth) * srcHeight;


 219             }
 220             if (syrem == 0) {
 221                 syrem = destHeight;
 222                 sy++;
 223                 off += scansize;
 224             }
 225         }
 226         savedyrem = dyrem;
 227         savedy = dy;
 228     }
 229 
 230     /**
 231      * Combine the components for the delivered byte pixels into the
 232      * accumulation arrays and send on any averaged data for rows of
 233      * pixels that are complete.  If the correct hints were not
 234      * specified in the setHints call then relay the work to our
 235      * superclass which is capable of scaling pixels regardless of
 236      * the delivery hints.
 237      * <p>
 238      * Note: This method is intended to be called by the
 239      * {@code ImageProducer} of the {@code Image}
 240      * whose pixels are being filtered.  Developers using
 241      * this class to filter pixels from an image should avoid calling
 242      * this method directly since that operation could interfere
 243      * with the filtering operation.
 244      * @see ReplicateScaleFilter
 245      */
 246     public void setPixels(int x, int y, int w, int h,
 247                           ColorModel model, byte pixels[], int off,
 248                           int scansize) {
 249         if (passthrough) {
 250             super.setPixels(x, y, w, h, model, pixels, off, scansize);
 251         } else {
 252             accumPixels(x, y, w, h, model, pixels, off, scansize);
 253         }
 254     }
 255 
 256     /**
 257      * Combine the components for the delivered int pixels into the
 258      * accumulation arrays and send on any averaged data for rows of
 259      * pixels that are complete.  If the correct hints were not
 260      * specified in the setHints call then relay the work to our
 261      * superclass which is capable of scaling pixels regardless of
 262      * the delivery hints.
 263      * <p>
 264      * Note: This method is intended to be called by the
 265      * {@code ImageProducer} of the {@code Image}
 266      * whose pixels are being filtered.  Developers using
 267      * this class to filter pixels from an image should avoid calling
 268      * this method directly since that operation could interfere
 269      * with the filtering operation.
 270      * @see ReplicateScaleFilter
 271      */
 272     public void setPixels(int x, int y, int w, int h,
 273                           ColorModel model, int pixels[], int off,
 274                           int scansize) {
 275         if (passthrough) {
 276             super.setPixels(x, y, w, h, model, pixels, off, scansize);
 277         } else {
 278             accumPixels(x, y, w, h, model, pixels, off, scansize);
 279         }
 280     }
 281 }
< prev index next >