Search in sources :

Example 1 with ReplicateScaleFilter

use of java.awt.image.ReplicateScaleFilter in project jdk8u_jdk by JetBrains.

the class Image method getScaledInstance.

/**
     * Creates a scaled version of this image.
     * A new <code>Image</code> object is returned which will render
     * the image at the specified <code>width</code> and
     * <code>height</code> by default.  The new <code>Image</code> object
     * may be loaded asynchronously even if the original source image
     * has already been loaded completely.
     *
     * <p>
     *
     * If either <code>width</code>
     * or <code>height</code> is a negative number then a value is
     * substituted to maintain the aspect ratio of the original image
     * dimensions. If both <code>width</code> and <code>height</code>
     * are negative, then the original image dimensions are used.
     *
     * @param width the width to which to scale the image.
     * @param height the height to which to scale the image.
     * @param hints flags to indicate the type of algorithm to use
     * for image resampling.
     * @return     a scaled version of the image.
     * @exception IllegalArgumentException if <code>width</code>
     *             or <code>height</code> is zero.
     * @see        java.awt.Image#SCALE_DEFAULT
     * @see        java.awt.Image#SCALE_FAST
     * @see        java.awt.Image#SCALE_SMOOTH
     * @see        java.awt.Image#SCALE_REPLICATE
     * @see        java.awt.Image#SCALE_AREA_AVERAGING
     * @since      JDK1.1
     */
public Image getScaledInstance(int width, int height, int hints) {
    ImageFilter filter;
    if ((hints & (SCALE_SMOOTH | SCALE_AREA_AVERAGING)) != 0) {
        filter = new AreaAveragingScaleFilter(width, height);
    } else {
        filter = new ReplicateScaleFilter(width, height);
    }
    ImageProducer prod;
    prod = new FilteredImageSource(getSource(), filter);
    return Toolkit.getDefaultToolkit().createImage(prod);
}
Also used : ImageFilter(java.awt.image.ImageFilter) ImageProducer(java.awt.image.ImageProducer) FilteredImageSource(java.awt.image.FilteredImageSource) AreaAveragingScaleFilter(java.awt.image.AreaAveragingScaleFilter) ReplicateScaleFilter(java.awt.image.ReplicateScaleFilter)

Aggregations

AreaAveragingScaleFilter (java.awt.image.AreaAveragingScaleFilter)1 FilteredImageSource (java.awt.image.FilteredImageSource)1 ImageFilter (java.awt.image.ImageFilter)1 ImageProducer (java.awt.image.ImageProducer)1 ReplicateScaleFilter (java.awt.image.ReplicateScaleFilter)1