类java.awt.image.ImageProducer源码实例Demo

下面列出了怎么用java.awt.image.ImageProducer的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jdk8u-jdk   文件: WindowsLookAndFeel.java
/**
 * {@inheritDoc}
 *
 * @since 1.6
 */
public Icon getDisabledIcon(JComponent component, Icon icon) {
    // if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY
    // client property set to Boolean.TRUE, then use the new
    // hi res algorithm for creating the disabled icon (used
    // 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);
}
 
/**
 * {@inheritDoc}
 *
 * @since 1.6
 */
public Icon getDisabledIcon(JComponent component, Icon icon) {
    // if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY
    // client property set to Boolean.TRUE, then use the new
    // hi res algorithm for creating the disabled icon (used
    // 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);
}
 
源代码3 项目: openjdk-8   文件: WindowsLookAndFeel.java
/**
 * {@inheritDoc}
 *
 * @since 1.6
 */
public Icon getDisabledIcon(JComponent component, Icon icon) {
    // if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY
    // client property set to Boolean.TRUE, then use the new
    // hi res algorithm for creating the disabled icon (used
    // 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);
}
 
源代码4 项目: hottub   文件: WindowsLookAndFeel.java
/**
 * {@inheritDoc}
 *
 * @since 1.6
 */
public Icon getDisabledIcon(JComponent component, Icon icon) {
    // if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY
    // client property set to Boolean.TRUE, then use the new
    // hi res algorithm for creating the disabled icon (used
    // 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);
}
 
源代码5 项目: TencentKona-8   文件: WindowsLookAndFeel.java
/**
 * {@inheritDoc}
 *
 * @since 1.6
 */
public Icon getDisabledIcon(JComponent component, Icon icon) {
    // if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY
    // client property set to Boolean.TRUE, then use the new
    // hi res algorithm for creating the disabled icon (used
    // 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);
}
 
源代码6 项目: jdk8u-dev-jdk   文件: WindowsLookAndFeel.java
/**
 * {@inheritDoc}
 *
 * @since 1.6
 */
public Icon getDisabledIcon(JComponent component, Icon icon) {
    // if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY
    // client property set to Boolean.TRUE, then use the new
    // hi res algorithm for creating the disabled icon (used
    // 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);
}
 
源代码7 项目: jdk1.8-source-analysis   文件: SimpleBeanInfo.java
/**
 * This is a utility method to help in loading icon images.
 * It takes the name of a resource file associated with the
 * current object's class file and loads an image object
 * from that file.  Typically images will be GIFs.
 * <p>
 * @param resourceName  A pathname relative to the directory
 *          holding the class file of the current class.  For example,
 *          "wombat.gif".
 * @return  an image object.  May be null if the load failed.
 */
public Image loadImage(final String resourceName) {
    try {
        final URL url = getClass().getResource(resourceName);
        if (url != null) {
            final ImageProducer ip = (ImageProducer) url.getContent();
            if (ip != null) {
                return Toolkit.getDefaultToolkit().createImage(ip);
            }
        }
    } catch (final Exception ignored) {
    }
    return null;
}
 
源代码8 项目: FlatLaf   文件: FlatDisabledIconsTest.java
protected Icon createDisabledIcon( Icon icon ) {
	if( !(icon instanceof ImageIcon) )
		return null;

	Image image = ((ImageIcon) icon).getImage();
	ImageProducer producer = new FilteredImageSource( image.getSource(), filter );
	Image disabledImage = Toolkit.getDefaultToolkit().createImage( producer );
	return new ImageIcon( disabledImage );
}
 
源代码9 项目: scifio   文件: JPEGTileDecoder.java
public TileConsumer(final ImageProducer producer, final int y,
	final int h)
{
	this(producer);
	this.yy = y;
	this.hh = h;
}
 
源代码10 项目: openjdk-jdk8u-backup   文件: ToolkitImage.java
/**
 * Construct an image from an ImageProducer object.
 */
public ToolkitImage(ImageProducer is) {
    source = is;
    if (is instanceof InputStreamImageSource) {
        src = (InputStreamImageSource) is;
    }
}
 
源代码11 项目: openjdk-jdk9   文件: ToolkitImage.java
/**
 * Construct an image from an ImageProducer object.
 */
public ToolkitImage(ImageProducer is) {
    source = is;
    if (is instanceof InputStreamImageSource) {
        src = (InputStreamImageSource) is;
    }
}
 
源代码12 项目: jdk8u-jdk   文件: SimpleBeanInfo.java
/**
 * This is a utility method to help in loading icon images.
 * It takes the name of a resource file associated with the
 * current object's class file and loads an image object
 * from that file.  Typically images will be GIFs.
 * <p>
 * @param resourceName  A pathname relative to the directory
 *          holding the class file of the current class.  For example,
 *          "wombat.gif".
 * @return  an image object.  May be null if the load failed.
 */
public Image loadImage(final String resourceName) {
    try {
        final URL url = getClass().getResource(resourceName);
        if (url != null) {
            final ImageProducer ip = (ImageProducer) url.getContent();
            if (ip != null) {
                return Toolkit.getDefaultToolkit().createImage(ip);
            }
        }
    } catch (final Exception ignored) {
    }
    return null;
}
 
源代码13 项目: RipplePower   文件: GraphicsUtils.java
/**
 * 分割指定图像为image[]
 * 
 * @param image
 * @param row
 * @param col
 * @return
 */
public static Image[][] getSplit2Images(Image image, int row, int col, boolean isFiltrate) {
	int wlength = image.getWidth(null) / row;
	int hlength = image.getHeight(null) / col;
	Image[][] abufferedimage = new Image[wlength][hlength];
	for (int y = 0; y < hlength; y++) {
		for (int x = 0; x < wlength; x++) {
			abufferedimage[x][y] = GraphicsUtils.createImage(row, col, true);
			Graphics g = abufferedimage[x][y].getGraphics();
			g.drawImage(image, 0, 0, row, col, (x * row), (y * col), row + (x * row), col + (y * col), null);
			g.dispose();
			g = null;
			PixelGrabber pgr = new PixelGrabber(abufferedimage[x][y], 0, 0, -1, -1, true);
			try {
				pgr.grabPixels();
			} catch (InterruptedException ex) {
				ex.getStackTrace();
			}
			int pixels[] = (int[]) pgr.getPixels();
			if (isFiltrate) {
				for (int i = 0; i < pixels.length; i++) {
					int[] rgbs = LColor.getRGBs(pixels[i]);
					if ((rgbs[0] == 247 && rgbs[1] == 0 && rgbs[2] == 255)
							|| (rgbs[0] == 255 && rgbs[1] == 0 && rgbs[2] == 255)
							|| (rgbs[0] == 0 && rgbs[1] == 0 && rgbs[2] == 0)) {
						pixels[i] = 0;
					}
				}
			}
			ImageProducer ip = new MemoryImageSource(pgr.getWidth(), pgr.getHeight(), pixels, 0, pgr.getWidth());
			abufferedimage[x][y] = toolKit.createImage(ip);
		}
	}
	return abufferedimage;
}
 
源代码14 项目: jdk8u_jdk   文件: SimpleBeanInfo.java
/**
 * This is a utility method to help in loading icon images.
 * It takes the name of a resource file associated with the
 * current object's class file and loads an image object
 * from that file.  Typically images will be GIFs.
 * <p>
 * @param resourceName  A pathname relative to the directory
 *          holding the class file of the current class.  For example,
 *          "wombat.gif".
 * @return  an image object.  May be null if the load failed.
 */
public Image loadImage(final String resourceName) {
    try {
        final URL url = getClass().getResource(resourceName);
        if (url != null) {
            final ImageProducer ip = (ImageProducer) url.getContent();
            if (ip != null) {
                return Toolkit.getDefaultToolkit().createImage(ip);
            }
        }
    } catch (final Exception ignored) {
    }
    return null;
}
 
源代码15 项目: openjdk-8   文件: ToolkitImage.java
/**
 * Construct an image from an ImageProducer object.
 */
public ToolkitImage(ImageProducer is) {
    source = is;
    if (is instanceof InputStreamImageSource) {
        src = (InputStreamImageSource) is;
    }
}
 
源代码16 项目: TencentKona-8   文件: SimpleBeanInfo.java
/**
 * This is a utility method to help in loading icon images.
 * It takes the name of a resource file associated with the
 * current object's class file and loads an image object
 * from that file.  Typically images will be GIFs.
 * <p>
 * @param resourceName  A pathname relative to the directory
 *          holding the class file of the current class.  For example,
 *          "wombat.gif".
 * @return  an image object.  May be null if the load failed.
 */
public Image loadImage(final String resourceName) {
    try {
        final URL url = getClass().getResource(resourceName);
        if (url != null) {
            final ImageProducer ip = (ImageProducer) url.getContent();
            if (ip != null) {
                return Toolkit.getDefaultToolkit().createImage(ip);
            }
        }
    } catch (final Exception ignored) {
    }
    return null;
}
 
源代码17 项目: Java8CN   文件: SimpleBeanInfo.java
/**
 * This is a utility method to help in loading icon images.
 * It takes the name of a resource file associated with the
 * current object's class file and loads an image object
 * from that file.  Typically images will be GIFs.
 * <p>
 * @param resourceName  A pathname relative to the directory
 *          holding the class file of the current class.  For example,
 *          "wombat.gif".
 * @return  an image object.  May be null if the load failed.
 */
public Image loadImage(final String resourceName) {
    try {
        final URL url = getClass().getResource(resourceName);
        if (url != null) {
            final ImageProducer ip = (ImageProducer) url.getContent();
            if (ip != null) {
                return Toolkit.getDefaultToolkit().createImage(ip);
            }
        }
    } catch (final Exception ignored) {
    }
    return null;
}
 
源代码18 项目: jdk8u-jdk   文件: ToolkitImage.java
/**
 * Construct an image from an ImageProducer object.
 */
public ToolkitImage(ImageProducer is) {
    source = is;
    if (is instanceof InputStreamImageSource) {
        src = (InputStreamImageSource) is;
    }
}
 
源代码19 项目: TrakEM2   文件: ControlWindow.java
synchronized private JFrame newJFrame(final String title) {
	final JFrame frame = new JFrame(title);

	if (null == icon) {
		try {
			Field mic = ImageJ.class.getDeclaredField("iconPath");
			mic.setAccessible(true);
			String path = (String) mic.get(IJ.getInstance());
			icon = IJ.getInstance().createImage((ImageProducer) new URL("file:" + path).getContent());
		} catch (Exception e) {}
	}

	if (null != icon) frame.setIconImage(icon);
	return frame;
}
 
源代码20 项目: jdk8u-dev-jdk   文件: ToolkitImage.java
/**
 * Construct an image from an ImageProducer object.
 */
public ToolkitImage(ImageProducer is) {
    source = is;
    if (is instanceof InputStreamImageSource) {
        src = (InputStreamImageSource) is;
    }
}
 
源代码21 项目: JDKSourceCode1.8   文件: SimpleBeanInfo.java
/**
 * This is a utility method to help in loading icon images.
 * It takes the name of a resource file associated with the
 * current object's class file and loads an image object
 * from that file.  Typically images will be GIFs.
 * <p>
 * @param resourceName  A pathname relative to the directory
 *          holding the class file of the current class.  For example,
 *          "wombat.gif".
 * @return  an image object.  May be null if the load failed.
 */
public Image loadImage(final String resourceName) {
    try {
        final URL url = getClass().getResource(resourceName);
        if (url != null) {
            final ImageProducer ip = (ImageProducer) url.getContent();
            if (ip != null) {
                return Toolkit.getDefaultToolkit().createImage(ip);
            }
        }
    } catch (final Exception ignored) {
    }
    return null;
}
 
/**
 * Returns a <code>GenericImageSinglePassIterator</code> that is either a
 * <code>IntPixelIterator</code> or a <code>BytePixelIterator</code>.
 * 
 * @param image
 *            the image to iterate over.
 * @param iteratorType
 *            one of these 8 BufferedImage types: TYPE_INT_ARGB,
 *            TYPE_INT_ARGB_PRE, TYPE_INT_RGB, TYPE_INT_BGR, TYPE_3BYTE_BGR,
 *            TYPE_BYTE_GRAY, TYPE_4BYTE_ABGR, TYPE_4BYTE_ABGR_PRE.
 * @return a <code>GenericImageSinglePassIterator</code> for the image
 *         provided.
 */
public static GenericImageSinglePassIterator get(Image image,
		int iteratorType) {
	if (!(iteratorType == BufferedImage.TYPE_INT_ARGB
			|| iteratorType == BufferedImage.TYPE_INT_ARGB_PRE
			|| iteratorType == BufferedImage.TYPE_INT_RGB
			|| iteratorType == BufferedImage.TYPE_INT_BGR
			|| iteratorType == BufferedImage.TYPE_3BYTE_BGR
			|| iteratorType == BufferedImage.TYPE_BYTE_GRAY
			|| iteratorType == BufferedImage.TYPE_4BYTE_ABGR || iteratorType == BufferedImage.TYPE_4BYTE_ABGR_PRE)) {
		throw new IllegalArgumentException("illegal iterator type: "
				+ iteratorType);
	}
	final ImageProducer producer = image.getSource();
	final Consumer consumer = new Consumer(producer, iteratorType);
	// ImageProducer.startProduction often starts its own thread, but it's
	// not
	// required to. Sometimes in my testing a BufferedImage would make
	// this a blocking call. So to be safe this call should be in its
	// own thread:
	Thread productionThread = new Thread(
			"GenericImageSinglePassIterator: Production Thread") {
		@Override
		public void run() {
			producer.startProduction(consumer);
		}
	};
	productionThread.start();
	return consumer.getPixelIterator();
}
 
源代码23 项目: jdk8u-dev-jdk   文件: SimpleBeanInfo.java
/**
 * This is a utility method to help in loading icon images.
 * It takes the name of a resource file associated with the
 * current object's class file and loads an image object
 * from that file.  Typically images will be GIFs.
 * <p>
 * @param resourceName  A pathname relative to the directory
 *          holding the class file of the current class.  For example,
 *          "wombat.gif".
 * @return  an image object.  May be null if the load failed.
 */
public Image loadImage(final String resourceName) {
    try {
        final URL url = getClass().getResource(resourceName);
        if (url != null) {
            final ImageProducer ip = (ImageProducer) url.getContent();
            if (ip != null) {
                return Toolkit.getDefaultToolkit().createImage(ip);
            }
        }
    } catch (final Exception ignored) {
    }
    return null;
}
 
源代码24 项目: hottub   文件: ToolkitImage.java
public ImageProducer getSource() {
    if (src != null) {
        src.checkSecurity(null, false);
    }
    return source;
}
 
源代码25 项目: openjdk-8-source   文件: bug7172833.java
@Override
public Image createImage(final ImageProducer producer) {
    return null;
}
 
源代码26 项目: jdk8u-jdk   文件: OffScreenImage.java
public ImageProducer getSource() {
    if (osis == null) {
        osis = new OffScreenImageSource(this);
    }
    return osis;
}
 
源代码27 项目: openjdk-jdk8u   文件: FilteredImageSourceTest.java
public EmptyFilteredImage(ImageProducer imgSource) {
    filter = new ImageFilter();
    producer = new FilteredImageSource(imgSource, filter);
}
 
源代码28 项目: java-swing-tips   文件: MainPanel.java
protected ListItem(String title, String iconfile) {
  this.nicon = new ImageIcon(getClass().getResource(iconfile));
  ImageProducer ip = new FilteredImageSource(nicon.getImage().getSource(), new SelectedImageFilter());
  this.sicon = new ImageIcon(Toolkit.getDefaultToolkit().createImage(ip));
  this.title = title;
}
 
源代码29 项目: openjdk-jdk8u-backup   文件: ToolkitImage.java
public ImageProducer getSource() {
    if (src != null) {
        src.checkSecurity(null, false);
    }
    return source;
}
 
源代码30 项目: java-swing-tips   文件: MainPanel.java
protected ListItem(String title, String iconfile) {
  this.nicon = new ImageIcon(getClass().getResource(iconfile));
  ImageProducer ip = new FilteredImageSource(nicon.getImage().getSource(), new SelectedImageFilter());
  this.sicon = new ImageIcon(Toolkit.getDefaultToolkit().createImage(ip));
  this.title = title;
}
 
 类所在包
 类方法
 同包方法