Search in sources :

Example 1 with ImageProducer

use of java.awt.image.ImageProducer 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)

Example 2 with ImageProducer

use of java.awt.image.ImageProducer in project litiengine by gurkenlabs.

the class ImageProcessing method applyAlphaChannel.

/**
 * All pixels that have the specified color are rendered transparent.
 *
 * @param img
 *          the img
 * @param color
 *          the color
 * @return the image
 */
public static Image applyAlphaChannel(final Image img, final Color color) {
    if (color == null || img == null) {
        return img;
    }
    final ImageFilter filter = new RGBImageFilter() {

        // the color we are looking for... Alpha bits are set to opaque
        public final int markerRGB = color.getRGB() | 0xFF000000;

        @Override
        public final int filterRGB(final int x, final int y, final int rgb) {
            if ((rgb | 0xFF000000) == this.markerRGB) {
                // Mark the alpha bits as zero - transparent
                return 0x00FFFFFF & rgb;
            } else {
                // nothing to do
                return rgb;
            }
        }
    };
    final ImageProducer ip = new FilteredImageSource(img.getSource(), filter);
    return Toolkit.getDefaultToolkit().createImage(ip);
}
Also used : RGBImageFilter(java.awt.image.RGBImageFilter) RGBImageFilter(java.awt.image.RGBImageFilter) ImageFilter(java.awt.image.ImageFilter) ImageProducer(java.awt.image.ImageProducer) FilteredImageSource(java.awt.image.FilteredImageSource)

Example 3 with ImageProducer

use of java.awt.image.ImageProducer in project gephi by gephi.

the class WhiteFilter method createDisabledImage.

// ~ Methods --------------------------------------------------------------------------------------------------------------
/**
 * Creates a disabled image
 */
public static Image createDisabledImage(final Image i) {
    final WhiteFilter filter = new WhiteFilter();
    final ImageProducer prod = new FilteredImageSource(i.getSource(), filter);
    return Toolkit.getDefaultToolkit().createImage(prod);
}
Also used : ImageProducer(java.awt.image.ImageProducer) FilteredImageSource(java.awt.image.FilteredImageSource)

Example 4 with ImageProducer

use of java.awt.image.ImageProducer in project ultimate-java by pantinor.

the class ImageTransparency method makeColorTransparent.

public static BufferedImage makeColorTransparent(BufferedImage im, final Color color) {
    final ImageFilter filter = new RGBImageFilter() {

        public int markerRGB = color.getRGB();

        public final int filterRGB(int x, int y, int rgb) {
            int alpha = (rgb >> 24) & 0xff;
            int red = (rgb >> 16) & 0xFF;
            int green = (rgb >> 8) & 0xFF;
            int blue = rgb & 0xFF;
            if (red == MARKER_RED && green == MARKER_GREEN && blue == MARKER_BLUE) {
                // Mark the alpha bits as zero - transparent
                rgb = 0x00FFFFFF & rgb;
            }
            alpha = (rgb >> 24) & 0xff;
            red = (rgb >> 16) & 0xFF;
            green = (rgb >> 8) & 0xFF;
            blue = rgb & 0xFF;
            return rgb;
        }
    };
    ImageProducer ip = new FilteredImageSource(im.getSource(), filter);
    Image i = Toolkit.getDefaultToolkit().createImage(ip);
    sun.awt.image.ToolkitImage source = (sun.awt.image.ToolkitImage) i;
    source.preload(null);
    try {
        Thread.sleep(250);
    } catch (Exception e) {
    }
    return source.getBufferedImage();
}
Also used : RGBImageFilter(java.awt.image.RGBImageFilter) RGBImageFilter(java.awt.image.RGBImageFilter) ImageFilter(java.awt.image.ImageFilter) ImageProducer(java.awt.image.ImageProducer) FilteredImageSource(java.awt.image.FilteredImageSource) Image(java.awt.Image) BufferedImage(java.awt.image.BufferedImage)

Example 5 with ImageProducer

use of java.awt.image.ImageProducer in project jsql-injection by ron190.

the class MetalUtilsCustom method getOceanDisabledButtonIcon.

static Icon getOceanDisabledButtonIcon(Image image) {
    Object[] range = (Object[]) UIManager.get("Button.disabledGrayRange");
    int min = 180;
    int max = 215;
    if (range != null) {
        min = ((Integer) range[0]).intValue();
        max = ((Integer) range[1]).intValue();
    }
    ImageProducer prod = new FilteredImageSource(image.getSource(), new OceanDisabledButtonImageFilter(min, max));
    return new ImageIconUIResource(Toolkit.getDefaultToolkit().createImage(prod));
}
Also used : ImageIconUIResource(sun.swing.ImageIconUIResource) ImageProducer(java.awt.image.ImageProducer) FilteredImageSource(java.awt.image.FilteredImageSource) GradientPaint(java.awt.GradientPaint)

Aggregations

ImageProducer (java.awt.image.ImageProducer)14 FilteredImageSource (java.awt.image.FilteredImageSource)11 BufferedImage (java.awt.image.BufferedImage)5 ImageFilter (java.awt.image.ImageFilter)5 RGBImageFilter (java.awt.image.RGBImageFilter)4 Image (java.awt.Image)2 URL (java.net.URL)2 ImageIconUIResource (sun.swing.ImageIconUIResource)2 Dimension (java.awt.Dimension)1 GradientPaint (java.awt.GradientPaint)1 AreaAveragingScaleFilter (java.awt.image.AreaAveragingScaleFilter)1 ReplicateScaleFilter (java.awt.image.ReplicateScaleFilter)1 Field (java.lang.reflect.Field)1 Vector (java.util.Vector)1 ImageIcon (javax.swing.ImageIcon)1 JFrame (javax.swing.JFrame)1 Location (loci.common.Location)1 ReflectException (loci.common.ReflectException)1 CoreMetadata (loci.formats.CoreMetadata)1 FormatException (loci.formats.FormatException)1