java.awt.image.ImageProducer Java Examples
The following examples show how to use
java.awt.image.ImageProducer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WindowsLookAndFeel.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * {@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); }
Example #2
Source File: WindowsLookAndFeel.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * {@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); }
Example #3
Source File: WindowsLookAndFeel.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * {@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); }
Example #4
Source File: WindowsLookAndFeel.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * {@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); }
Example #5
Source File: WindowsLookAndFeel.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * {@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); }
Example #6
Source File: WindowsLookAndFeel.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * {@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); }
Example #7
Source File: SimpleBeanInfo.java From Java8CN with Apache License 2.0 | 5 votes |
/** * 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; }
Example #8
Source File: JPEGTileDecoder.java From scifio with BSD 2-Clause "Simplified" License | 5 votes |
public TileConsumer(final ImageProducer producer, final int y, final int h) { this(producer); this.yy = y; this.hh = h; }
Example #9
Source File: SimpleBeanInfo.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * 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; }
Example #10
Source File: ToolkitImage.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Construct an image from an ImageProducer object. */ public ToolkitImage(ImageProducer is) { source = is; if (is instanceof InputStreamImageSource) { src = (InputStreamImageSource) is; } }
Example #11
Source File: GenericImageSinglePassIterator.java From pumpernickel with MIT License | 5 votes |
/** * 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(); }
Example #12
Source File: SimpleBeanInfo.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * 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; }
Example #13
Source File: ToolkitImage.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Construct an image from an ImageProducer object. */ public ToolkitImage(ImageProducer is) { source = is; if (is instanceof InputStreamImageSource) { src = (InputStreamImageSource) is; } }
Example #14
Source File: FlatDisabledIconsTest.java From FlatLaf with Apache License 2.0 | 5 votes |
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 ); }
Example #15
Source File: ToolkitImage.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Construct an image from an ImageProducer object. */ public ToolkitImage(ImageProducer is) { source = is; if (is instanceof InputStreamImageSource) { src = (InputStreamImageSource) is; } }
Example #16
Source File: ControlWindow.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
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; }
Example #17
Source File: SimpleBeanInfo.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #18
Source File: GraphicsUtils.java From RipplePower with Apache License 2.0 | 5 votes |
/** * 分割指定图像为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; }
Example #19
Source File: SimpleBeanInfo.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #20
Source File: ToolkitImage.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Construct an image from an ImageProducer object. */ public ToolkitImage(ImageProducer is) { source = is; if (is instanceof InputStreamImageSource) { src = (InputStreamImageSource) is; } }
Example #21
Source File: SimpleBeanInfo.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #22
Source File: ToolkitImage.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Construct an image from an ImageProducer object. */ public ToolkitImage(ImageProducer is) { source = is; if (is instanceof InputStreamImageSource) { src = (InputStreamImageSource) is; } }
Example #23
Source File: SimpleBeanInfo.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #24
Source File: bug7172833.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Override public Image createImage(final ImageProducer producer) { return null; }
Example #25
Source File: SunToolkit.java From Bytecoder with Apache License 2.0 | 4 votes |
@Override public Image createImage(ImageProducer producer) { return new ToolkitImage(producer); }
Example #26
Source File: NullComponentPeer.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public Image createImage(ImageProducer producer) { return null; }
Example #27
Source File: ToolkitImage.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public ImageProducer getSource() { if (src != null) { src.checkSecurity(null, false); } return source; }
Example #28
Source File: XComponentPeer.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public Image createImage(ImageProducer producer) { return new ToolkitImage(producer); }
Example #29
Source File: OffScreenImage.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public ImageProducer getSource() { if (osis == null) { osis = new OffScreenImageSource(this); } return osis; }
Example #30
Source File: NullComponentPeer.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public Image createImage(ImageProducer producer) { return null; }