java.awt.image
Class AreaAveragingScaleFilter

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.awt.image.ImageFilter sample code for java.awt.image.ImageFilter definition code for java.awt.image.ImageFilter 
      extended by java.awt.image.ReplicateScaleFilter sample code for java.awt.image.ReplicateScaleFilter definition code for java.awt.image.ReplicateScaleFilter 
          extended by java.awt.image.AreaAveragingScaleFilter
All Implemented Interfaces:
ImageConsumer sample code for java.awt.image.ImageConsumer definition code for java.awt.image.ImageConsumer , Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable

public class AreaAveragingScaleFilter
extends ReplicateScaleFilter sample code for java.awt.image.ReplicateScaleFilter definition code for java.awt.image.ReplicateScaleFilter

An ImageFilter class for scaling images using a simple area averaging algorithm that produces smoother results than the nearest neighbor algorithm.

This class extends the basic ImageFilter Class to scale an existing image and provide a source for a new image containing the resampled image. The pixels in the source image are blended to produce pixels for an image of the specified size. The blending process is analogous to scaling up the source image to a multiple of the destination size using pixel replication and then scaling it back down to the destination size by simply averaging all the pixels in the supersized image that fall within a given pixel of the destination image. If the data from the source is not delivered in TopDownLeftRight order then the filter will back off to a simple pixel replication behavior and utilize the requestTopDownLeftRightResend() method to refilter the pixels in a better way at the end.

It is meant to be used in conjunction with a FilteredImageSource object to produce scaled versions of existing images. Due to implementation dependencies, there may be differences in pixel values of an image filtered on different platforms.

See Also:
FilteredImageSource sample code for java.awt.image.FilteredImageSource definition code for java.awt.image.FilteredImageSource , ReplicateScaleFilter sample code for java.awt.image.ReplicateScaleFilter definition code for java.awt.image.ReplicateScaleFilter , ImageFilter sample code for java.awt.image.ImageFilter definition code for java.awt.image.ImageFilter

Field Summary
 
Fields inherited from class java.awt.image.ReplicateScaleFilter sample code for java.awt.image.ReplicateScaleFilter definition code for java.awt.image.ReplicateScaleFilter
destHeight sample code for java.awt.image.ReplicateScaleFilter.destHeight definition code for java.awt.image.ReplicateScaleFilter.destHeight , destWidth sample code for java.awt.image.ReplicateScaleFilter.destWidth definition code for java.awt.image.ReplicateScaleFilter.destWidth , outpixbuf sample code for java.awt.image.ReplicateScaleFilter.outpixbuf definition code for java.awt.image.ReplicateScaleFilter.outpixbuf , srccols sample code for java.awt.image.ReplicateScaleFilter.srccols definition code for java.awt.image.ReplicateScaleFilter.srccols , srcHeight sample code for java.awt.image.ReplicateScaleFilter.srcHeight definition code for java.awt.image.ReplicateScaleFilter.srcHeight , srcrows sample code for java.awt.image.ReplicateScaleFilter.srcrows definition code for java.awt.image.ReplicateScaleFilter.srcrows , srcWidth sample code for java.awt.image.ReplicateScaleFilter.srcWidth definition code for java.awt.image.ReplicateScaleFilter.srcWidth
 
Fields inherited from class java.awt.image.ImageFilter sample code for java.awt.image.ImageFilter definition code for java.awt.image.ImageFilter
consumer sample code for java.awt.image.ImageFilter.consumer definition code for java.awt.image.ImageFilter.consumer
 
Fields inherited from interface java.awt.image.ImageConsumer sample code for java.awt.image.ImageConsumer definition code for java.awt.image.ImageConsumer
COMPLETESCANLINES sample code for java.awt.image.ImageConsumer.COMPLETESCANLINES definition code for java.awt.image.ImageConsumer.COMPLETESCANLINES , IMAGEABORTED sample code for java.awt.image.ImageConsumer.IMAGEABORTED definition code for java.awt.image.ImageConsumer.IMAGEABORTED , IMAGEERROR sample code for java.awt.image.ImageConsumer.IMAGEERROR definition code for java.awt.image.ImageConsumer.IMAGEERROR , RANDOMPIXELORDER sample code for java.awt.image.ImageConsumer.RANDOMPIXELORDER definition code for java.awt.image.ImageConsumer.RANDOMPIXELORDER , SINGLEFRAME sample code for java.awt.image.ImageConsumer.SINGLEFRAME definition code for java.awt.image.ImageConsumer.SINGLEFRAME , SINGLEFRAMEDONE sample code for java.awt.image.ImageConsumer.SINGLEFRAMEDONE definition code for java.awt.image.ImageConsumer.SINGLEFRAMEDONE , SINGLEPASS sample code for java.awt.image.ImageConsumer.SINGLEPASS definition code for java.awt.image.ImageConsumer.SINGLEPASS , STATICIMAGEDONE sample code for java.awt.image.ImageConsumer.STATICIMAGEDONE definition code for java.awt.image.ImageConsumer.STATICIMAGEDONE , TOPDOWNLEFTRIGHT sample code for java.awt.image.ImageConsumer.TOPDOWNLEFTRIGHT definition code for java.awt.image.ImageConsumer.TOPDOWNLEFTRIGHT
 
Constructor Summary
AreaAveragingScaleFilter sample code for java.awt.image.AreaAveragingScaleFilter.AreaAveragingScaleFilter(int, int) definition code for java.awt.image.AreaAveragingScaleFilter.AreaAveragingScaleFilter(int, int) (int width, int height)
          Constructs an AreaAveragingScaleFilter that scales the pixels from its source Image as specified by the width and height parameters.
 
Method Summary
 void setHints sample code for java.awt.image.AreaAveragingScaleFilter.setHints(int) definition code for java.awt.image.AreaAveragingScaleFilter.setHints(int) (int hints)
          Detect if the data is being delivered with the necessary hints to allow the averaging algorithm to do its work.
 void setPixels sample code for java.awt.image.AreaAveragingScaleFilter.setPixels(int, int, int, int, java.awt.image.ColorModel, byte[], int, int) definition code for java.awt.image.AreaAveragingScaleFilter.setPixels(int, int, int, int, java.awt.image.ColorModel, byte[], int, int) (int x, int y, int w, int h, ColorModel sample code for java.awt.image.ColorModel definition code for java.awt.image.ColorModel  model, byte[] pixels, int off, int scansize)
          Combine the components for the delivered byte pixels into the accumulation arrays and send on any averaged data for rows of pixels that are complete.
 void setPixels sample code for java.awt.image.AreaAveragingScaleFilter.setPixels(int, int, int, int, java.awt.image.ColorModel, int[], int, int) definition code for java.awt.image.AreaAveragingScaleFilter.setPixels(int, int, int, int, java.awt.image.ColorModel, int[], int, int) (int x, int y, int w, int h, ColorModel sample code for java.awt.image.ColorModel definition code for java.awt.image.ColorModel  model, int[] pixels, int off, int scansize)
          Combine the components for the delivered int pixels into the accumulation arrays and send on any averaged data for rows of pixels that are complete.
 
Methods inherited from class java.awt.image.ReplicateScaleFilter sample code for java.awt.image.ReplicateScaleFilter definition code for java.awt.image.ReplicateScaleFilter
setDimensions sample code for java.awt.image.ReplicateScaleFilter.setDimensions(int, int) definition code for java.awt.image.ReplicateScaleFilter.setDimensions(int, int) , setProperties sample code for java.awt.image.ReplicateScaleFilter.setProperties(java.util.Hashtable) definition code for java.awt.image.ReplicateScaleFilter.setProperties(java.util.Hashtable)
 
Methods inherited from class java.awt.image.ImageFilter sample code for java.awt.image.ImageFilter definition code for java.awt.image.ImageFilter
clone sample code for java.awt.image.ImageFilter.clone() definition code for java.awt.image.ImageFilter.clone() , getFilterInstance sample code for java.awt.image.ImageFilter.getFilterInstance(java.awt.image.ImageConsumer) definition code for java.awt.image.ImageFilter.getFilterInstance(java.awt.image.ImageConsumer) , imageComplete sample code for java.awt.image.ImageFilter.imageComplete(int) definition code for java.awt.image.ImageFilter.imageComplete(int) , resendTopDownLeftRight sample code for java.awt.image.ImageFilter.resendTopDownLeftRight(java.awt.image.ImageProducer) definition code for java.awt.image.ImageFilter.resendTopDownLeftRight(java.awt.image.ImageProducer) , setColorModel sample code for java.awt.image.ImageFilter.setColorModel(java.awt.image.ColorModel) definition code for java.awt.image.ImageFilter.setColorModel(java.awt.image.ColorModel)
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

AreaAveragingScaleFilter sample code for java.awt.image.AreaAveragingScaleFilter(int, int) definition code for java.awt.image.AreaAveragingScaleFilter(int, int)

public AreaAveragingScaleFilter(int width,
                                int height)
Constructs an AreaAveragingScaleFilter that scales the pixels from its source Image as specified by the width and height parameters.

Parameters:
width - the target width to scale the image
height - the target height to scale the image
Method Detail

setHints sample code for java.awt.image.AreaAveragingScaleFilter.setHints(int) definition code for java.awt.image.AreaAveragingScaleFilter.setHints(int)

public void setHints(int hints)
Detect if the data is being delivered with the necessary hints to allow the averaging algorithm to do its work.

Note: This method is intended to be called by the ImageProducer of the Image whose pixels are being filtered. Developers using this class to filter pixels from an image should avoid calling this method directly since that operation could interfere with the filtering operation.

Specified by:
setHints sample code for java.awt.image.ImageConsumer.setHints(int) definition code for java.awt.image.ImageConsumer.setHints(int) in interface ImageConsumer sample code for java.awt.image.ImageConsumer definition code for java.awt.image.ImageConsumer
Overrides:
setHints sample code for java.awt.image.ImageFilter.setHints(int) definition code for java.awt.image.ImageFilter.setHints(int) in class ImageFilter sample code for java.awt.image.ImageFilter definition code for java.awt.image.ImageFilter
Parameters:
hints - a set of hints that the ImageConsumer uses to process the pixels
See Also:
ImageConsumer.setHints(int) sample code for java.awt.image.ImageConsumer.setHints(int) definition code for java.awt.image.ImageConsumer.setHints(int)

setPixels sample code for java.awt.image.AreaAveragingScaleFilter.setPixels(int, int, int, int, java.awt.image.ColorModel, byte[], int, int) definition code for java.awt.image.AreaAveragingScaleFilter.setPixels(int, int, int, int, java.awt.image.ColorModel, byte[], int, int)

public void setPixels(int x,
                      int y,
                      int w,
                      int h,
                      ColorModel sample code for java.awt.image.ColorModel definition code for java.awt.image.ColorModel  model,
                      byte[] pixels,
                      int off,
                      int scansize)
Combine the components for the delivered byte pixels into the accumulation arrays and send on any averaged data for rows of pixels that are complete. If the correct hints were not specified in the setHints call then relay the work to our superclass which is capable of scaling pixels regardless of the delivery hints.

Note: This method is intended to be called by the ImageProducer of the Image whose pixels are being filtered. Developers using this class to filter pixels from an image should avoid calling this method directly since that operation could interfere with the filtering operation.

Specified by:
setPixels sample code for java.awt.image.ImageConsumer.setPixels(int, int, int, int, java.awt.image.ColorModel, byte[], int, int) definition code for java.awt.image.ImageConsumer.setPixels(int, int, int, int, java.awt.image.ColorModel, byte[], int, int) in interface ImageConsumer sample code for java.awt.image.ImageConsumer definition code for java.awt.image.ImageConsumer
Overrides:
setPixels sample code for java.awt.image.ReplicateScaleFilter.setPixels(int, int, int, int, java.awt.image.ColorModel, byte[], int, int) definition code for java.awt.image.ReplicateScaleFilter.setPixels(int, int, int, int, java.awt.image.ColorModel, byte[], int, int) in class ReplicateScaleFilter sample code for java.awt.image.ReplicateScaleFilter definition code for java.awt.image.ReplicateScaleFilter
w - the width of the area of pixels
h - the height of the area of pixels
model - the specified ColorModel
pixels - the array of pixels
off - the offset into the pixels array
scansize - the distance from one row of pixels to the next in the pixels array
See Also:
ReplicateScaleFilter sample code for java.awt.image.ReplicateScaleFilter definition code for java.awt.image.ReplicateScaleFilter

setPixels sample code for java.awt.image.AreaAveragingScaleFilter.setPixels(int, int, int, int, java.awt.image.ColorModel, int[], int, int) definition code for java.awt.image.AreaAveragingScaleFilter.setPixels(int, int, int, int, java.awt.image.ColorModel, int[], int, int)

public void setPixels(int x,
                      int y,
                      int w,
                      int h,
                      ColorModel sample code for java.awt.image.ColorModel definition code for java.awt.image.ColorModel  model,
                      int[] pixels,
                      int off,
                      int scansize)
Combine the components for the delivered int pixels into the accumulation arrays and send on any averaged data for rows of pixels that are complete. If the correct hints were not specified in the setHints call then relay the work to our superclass which is capable of scaling pixels regardless of the delivery hints.

Note: This method is intended to be called by the ImageProducer of the Image whose pixels are being filtered. Developers using this class to filter pixels from an image should avoid calling this method directly since that operation could interfere with the filtering operation.

Specified by:
setPixels sample code for java.awt.image.ImageConsumer.setPixels(int, int, int, int, java.awt.image.ColorModel, int[], int, int) definition code for java.awt.image.ImageConsumer.setPixels(int, int, int, int, java.awt.image.ColorModel, int[], int, int) in interface ImageConsumer sample code for java.awt.image.ImageConsumer definition code for java.awt.image.ImageConsumer
Overrides:
setPixels sample code for java.awt.image.ReplicateScaleFilter.setPixels(int, int, int, int, java.awt.image.ColorModel, int[], int, int) definition code for java.awt.image.ReplicateScaleFilter.setPixels(int, int, int, int, java.awt.image.ColorModel, int[], int, int) in class ReplicateScaleFilter sample code for java.awt.image.ReplicateScaleFilter definition code for java.awt.image.ReplicateScaleFilter
w - the width of the area of pixels
h - the height of the area of pixels
model - the specified ColorModel
pixels - the array of pixels
off - the offset into the pixels array
scansize - the distance from one row of pixels to the next in the pixels array
See Also:
ReplicateScaleFilter sample code for java.awt.image.ReplicateScaleFilter definition code for java.awt.image.ReplicateScaleFilter