Search in sources :

Example 6 with ImageProducer

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

the class WindowsLookAndFeel method getDisabledIcon.

/**
     * {@inheritDoc}
     *
     * @since 1.6
     */
public Icon getDisabledIcon(JComponent component, Icon icon) {
    // in particular by the WindowsFileChooserUI class)
    if (icon != null && component != null && Boolean.TRUE.equals(component.getClientProperty(HI_RES_DISABLED_ICON_CLIENT_KEY)) && icon.getIconWidth() > 0 && icon.getIconHeight() > 0) {
        BufferedImage img = new BufferedImage(icon.getIconWidth(), icon.getIconWidth(), BufferedImage.TYPE_INT_ARGB);
        icon.paintIcon(component, img.getGraphics(), 0, 0);
        ImageFilter filter = new RGBGrayFilter();
        ImageProducer producer = new FilteredImageSource(img.getSource(), filter);
        Image resultImage = component.createImage(producer);
        return new ImageIconUIResource(resultImage);
    }
    return super.getDisabledIcon(component, icon);
}
Also used : RGBImageFilter(java.awt.image.RGBImageFilter) ImageFilter(java.awt.image.ImageFilter) ImageIconUIResource(sun.swing.ImageIconUIResource) ImageProducer(java.awt.image.ImageProducer) FilteredImageSource(java.awt.image.FilteredImageSource) BufferedImage(java.awt.image.BufferedImage) BufferedImage(java.awt.image.BufferedImage)

Example 7 with ImageProducer

use of java.awt.image.ImageProducer in project cayenne by apache.

the class FilteredIconFactory method createIcon.

public static Icon createIcon(Icon icon, FilterType filterType) {
    if (icon != null && icon.getIconWidth() > 0 && icon.getIconHeight() > 0) {
        BufferedImage img = new BufferedImage(icon.getIconWidth(), icon.getIconWidth(), BufferedImage.TYPE_INT_ARGB);
        icon.paintIcon(DUMMY, img.getGraphics(), 0, 0);
        ImageProducer producer = new FilteredImageSource(img.getSource(), filterType.filter);
        Image resultImage = DUMMY.createImage(producer);
        return new ImageIcon(resultImage);
    }
    return null;
}
Also used : ImageIcon(javax.swing.ImageIcon) ImageProducer(java.awt.image.ImageProducer) FilteredImageSource(java.awt.image.FilteredImageSource) Image(java.awt.Image) BufferedImage(java.awt.image.BufferedImage) BufferedImage(java.awt.image.BufferedImage)

Example 8 with ImageProducer

use of java.awt.image.ImageProducer in project processdash by dtuma.

the class BufferedIcon method applyFilter.

public void applyFilter(RGBImageFilter filter) {
    ImageProducer prod = new FilteredImageSource(getImage().getSource(), filter);
    setImage(Toolkit.getDefaultToolkit().createImage(prod));
}
Also used : ImageProducer(java.awt.image.ImageProducer) FilteredImageSource(java.awt.image.FilteredImageSource)

Example 9 with ImageProducer

use of java.awt.image.ImageProducer in project rt.equinox.framework by eclipse.

the class URLHandlerTests method testImageProducer.

public void testImageProducer() throws IOException {
    URL testImage = getClass().getResource("debug.gif");
    Object content = testImage.getContent();
    assertTrue("Wrong content type: " + content.getClass().getName(), content instanceof ImageProducer);
}
Also used : ImageProducer(java.awt.image.ImageProducer) URL(java.net.URL)

Example 10 with ImageProducer

use of java.awt.image.ImageProducer in project bioformats by openmicroscopy.

the class LegacyQTReader method initFile.

// -- Internal FormatReader API methods --
/* @see loci.formats.FormatReader#initFile(String) */
@Override
protected void initFile(String id) throws FormatException, IOException {
    LOGGER.info("Checking for QuickTime Java");
    if (tools == null) {
        tools = new LegacyQTTools();
        r = tools.getUniverse();
    }
    tools.checkQTLibrary();
    super.initFile(id);
    LOGGER.info("Reading movie dimensions");
    try {
        r.exec("QTSession.open()");
        // open movie file
        Location file = new Location(id);
        r.setVar("path", file.getAbsolutePath());
        r.exec("qtf = new QTFile(path)");
        r.exec("openMovieFile = OpenMovieFile.asRead(qtf)");
        r.exec("m = Movie.fromFile(openMovieFile)");
        int numTracks = ((Integer) r.exec("m.getTrackCount()")).intValue();
        int trackMostLikely = 0;
        int trackNum = 0;
        while (++trackNum <= numTracks && trackMostLikely == 0) {
            r.setVar("trackNum", trackNum);
            r.exec("imageTrack = m.getTrack(trackNum)");
            r.exec("d = imageTrack.getSize()");
            Integer w = (Integer) r.exec("d.getWidth()");
            if (w.intValue() > 0)
                trackMostLikely = trackNum;
        }
        r.setVar("trackMostLikely", trackMostLikely);
        r.exec("imageTrack = m.getTrack(trackMostLikely)");
        r.exec("d = imageTrack.getSize()");
        Integer w = (Integer) r.exec("d.getWidth()");
        Integer h = (Integer) r.exec("d.getHeight()");
        r.exec("moviePlayer = new MoviePlayer(m)");
        r.setVar("dim", new Dimension(w.intValue(), h.intValue()));
        ImageProducer qtip = (ImageProducer) r.exec("qtip = new QTImageProducer(moviePlayer, dim)");
        image = Toolkit.getDefaultToolkit().createImage(qtip);
        r.setVar("zero", 0);
        r.setVar("one", 1f);
        r.exec("timeInfo = new TimeInfo(zero, zero)");
        r.exec("moviePlayer.setTime(zero)");
        Vector<Integer> v = new Vector<Integer>();
        int time = 0;
        Integer q = new Integer(time);
        do {
            v.add(q);
            r.exec("timeInfo = imageTrack.getNextInterestingTime(" + "StdQTConstants.nextTimeMediaSample, timeInfo.time, one)");
            q = (Integer) r.getVar("timeInfo.time");
            time = q.intValue();
        } while (time >= 0);
        CoreMetadata m = core.get(0);
        m.imageCount = v.size();
        times = new int[getImageCount()];
        for (int i = 0; i < times.length; i++) {
            q = v.elementAt(i);
            times[i] = q.intValue();
        }
        LOGGER.info("Populating metadata");
        BufferedImage img = AWTImageTools.makeBuffered(image);
        m.sizeX = img.getWidth();
        m.sizeY = img.getHeight();
        m.sizeZ = 1;
        m.sizeC = img.getRaster().getNumBands();
        m.sizeT = getImageCount();
        m.pixelType = AWTImageTools.getPixelType(img);
        m.dimensionOrder = "XYCTZ";
        m.rgb = true;
        m.interleaved = false;
        m.littleEndian = false;
        m.indexed = false;
        m.falseColor = false;
        MetadataStore store = makeFilterMetadata();
        MetadataTools.populatePixels(store, this);
    } catch (ReflectException e) {
        throw new FormatException("Open movie failed", e);
    }
}
Also used : Dimension(java.awt.Dimension) CoreMetadata(loci.formats.CoreMetadata) ReflectException(loci.common.ReflectException) BufferedImage(java.awt.image.BufferedImage) FormatException(loci.formats.FormatException) MetadataStore(loci.formats.meta.MetadataStore) LegacyQTTools(loci.formats.gui.LegacyQTTools) ImageProducer(java.awt.image.ImageProducer) Vector(java.util.Vector) Location(loci.common.Location)

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