当前位置: 首页>>代码示例>>Java>>正文


Java ImageIcon.getImage方法代码示例

本文整理汇总了Java中javax.swing.ImageIcon.getImage方法的典型用法代码示例。如果您正苦于以下问题:Java ImageIcon.getImage方法的具体用法?Java ImageIcon.getImage怎么用?Java ImageIcon.getImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.ImageIcon的用法示例。


在下文中一共展示了ImageIcon.getImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLogo

import javax.swing.ImageIcon; //导入方法依赖的package包/类
/**
 * Returns the JFreeChart logo (a picture of a gorilla).
 *
 * @return  the JFreeChart logo.
 */
public Image getLogo() {

    Image logo = super.getLogo();
    if (logo == null) {
        URL imageURL = ClassLoader.getSystemResource("org/jfree/chart/gorilla.jpg");
        if (imageURL != null) {
            ImageIcon temp = new ImageIcon(imageURL);  // use ImageIcon because it waits for
                                                       // the image to load...
            logo = temp.getImage();
            setLogo(logo);
        }
    }
    return logo;

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:JFreeChart.java

示例2: aplicaTransparencia

import javax.swing.ImageIcon; //导入方法依赖的package包/类
/**
 * Aplica transparência a uma determinada cor
 *
 * @param image imagem a ser editada
 * @param keyColor cor a se tornar transparente
 * @return imagem editada
 */
public static ImageIcon aplicaTransparencia(ImageIcon image, Color keyColor) {
    try {
        Image img = image.getImage();
        int w = img.getWidth(null);
        int h = img.getHeight(null);
        int[] pxls = getPixels(img);
        for (int i = 0; i < pxls.length; i++) {
            if (pxls[i] == keyColor.getRGB()) {
                pxls[i] = 0x00ffffff;
            }
        }
        return new ImageIcon(getImage(pxls, w, h));
    } catch (Exception e) {
        e.printStackTrace();
        return image;
    }
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:25,代码来源:Img.java

示例3: ImageLabel

import javax.swing.ImageIcon; //导入方法依赖的package包/类
public ImageLabel( String url, ImageIcon img, String description ) {
    super( new MaxSizeImageIcon(img.getImage()) );
    this.url = url;
    if( null != description )
        setToolTipText( "<html>" + description ); //NOI18N
    setOpaque( false );
    setBorder( BorderFactory.createEmptyBorder(1,1,1,1) );
    addMouseListener( this );
    setCursor( Cursor.getPredefinedCursor(Cursor.HAND_CURSOR) );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:DemoPanel.java

示例4: loadImageAwt

import javax.swing.ImageIcon; //导入方法依赖的package包/类
/**  Loads the image from this directory, please put all images in the class
 * package.
 *
 * @param imageName string containing the image name
 * @return the image
 */
public static Image loadImageAwt(String imageName) {
	ImageIcon img = imageLoader.loadIcon(imageName);
	if (img != null) {
		return img.getImage();
	} else {
		return null;
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:15,代码来源:JMTImageLoader.java

示例5: loadIcon

import javax.swing.ImageIcon; //导入方法依赖的package包/类
/**
 * Loads an icon with specified name and caches it, then resizes it.
 * @param iconName name of the icon to be loaded. Extensions are automatically added, if needed.
 * @param size target dimension of image. a negative number means to maintain aspect ratio on that dimension
 * @return icon if found, null otherwise
 */
public ImageIcon loadIcon(String iconName, Dimension size) {
	ImageIcon im = loadIcon(iconName);
	if (im != null) {
		Image scaled = im.getImage();
		scaled = scaled.getScaledInstance(size.width, size.height, Image.SCALE_SMOOTH);
		return new ImageIcon(scaled);
	} else {
		return im;
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:17,代码来源:ImageLoader.java

示例6: convertToBufferedImage

import javax.swing.ImageIcon; //导入方法依赖的package包/类
/**
 * Converts the icon in labelMap in a buffered image.
 *
 * @param labelMap
 * @return
 */
private static BufferedImage convertToBufferedImage(JLabel labelMap) {
    ImageIcon imgIcon = ((ImageIcon) labelMap.getIcon());
    Image image = imgIcon.getImage();
    BufferedImage newImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = newImage.createGraphics();
    g.drawImage(image, 0, 0, null);
    g.dispose();
    return newImage;
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-B,代码行数:16,代码来源:LabelMapListener.java

示例7: afficheRune

import javax.swing.ImageIcon; //导入方法依赖的package包/类
private void afficheRune(String url){
   java.net.URL imageURL = Main.class.getResource(url);
   ImageIcon icon = new ImageIcon(imageURL);
   if (url.equals("/images/stele.png")){
       java.awt.Image imagePhoto=icon.getImage();
       imagePhoto=imagePhoto.getScaledInstance(88,112,java.awt.Image.SCALE_SMOOTH);
       icon.setImage(imagePhoto);
   }
   runeLbl.setIcon(icon);
}
 
开发者ID:Denis-Bonnot-project,项目名称:Jeu-de-runes,代码行数:11,代码来源:Rune.java

示例8: colorize

import javax.swing.ImageIcon; //导入方法依赖的package包/类
private ImageIcon colorize(ImageIcon icon, Color color) {
    int[] pixels = new int[icon.getIconHeight() * icon.getIconWidth()];
    try {
        PixelGrabber grabber = new PixelGrabber(icon.getImage(), 0, 0, icon.getIconWidth(),
                                                icon.getIconHeight(), pixels, 0,
                                                icon.getIconWidth());
        grabber.grabPixels();
        int r = color.getRed();
        int g = color.getGreen();
        int b = color.getBlue();

        int pixel;
        for (int i = 0, acm; i < pixels.length; i++) {
        	pixel = pixels[i];
        	int alpha = (pixel >> 24) & 0xff;
            int red   = (pixel >> 16) & 0xff;
            int green = (pixel >>  8) & 0xff;
            int blue  = pixel & 0xff;
            acm = (blue + green + red) / 3;
            int max = 255;
            pixels[i] = (((acm * r)/max) << 16) + (((acm * g)/max) << 8) + ((acm * b)/max) + (alpha << 24);
        }
    } catch (InterruptedException ex) {
        ex.printStackTrace();
    }
    MemoryImageSource mis = new MemoryImageSource(icon.getIconWidth(),
                                                  icon.getIconHeight(),
                                                  pixels, 0,
                                                  icon.getIconWidth());
    return new ImageIcon(component.createImage(mis));
}
 
开发者ID:adbenitez,项目名称:jNotifyOSD,代码行数:32,代码来源:NotifyConfig.java

示例9: attachIcon

import javax.swing.ImageIcon; //导入方法依赖的package包/类
public static void attachIcon(Window frame) {
	if (ICONS == null) {
		List<Image> loadedIcons = new ArrayList<Image>();
		ClassLoader loader = LFrame.class.getClassLoader();
		for (int size : SIZES) {
			URL url = loader.getResource(PATH + size + ".png");
			if (url != null) {
				ImageIcon icon = new ImageIcon(url);
				loadedIcons.add(icon.getImage());
				if (size == DEFAULT_SIZE) {
					DEFAULT_ICON = icon.getImage();
				}
			}
		}
		ICONS = loadedIcons;
	}

	boolean success = false;
	try {
		if (ICONS != null && !ICONS.isEmpty()) {
			Method set = frame.getClass().getMethod("setIconImages", List.class);
			set.invoke(frame, ICONS);
			success = true;
		}
	} catch (Exception e) {
	}

	if (!success && frame instanceof JFrame && DEFAULT_ICON != null) {
		((JFrame) frame).setIconImage(DEFAULT_ICON);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:32,代码来源:LFrame.java

示例10: createCursor

import javax.swing.ImageIcon; //导入方法依赖的package包/类
/** Creates a named cursor from a given file. */
static private Cursor createCursor(String name, ImageIcon icon) {
    if (GraphicsEnvironment.isHeadless()) {
        // The environtment variable DISPLAY is not set. We can't call
        // createCustomCursor from the awt toolkit because this causes
        // a java.awt.HeadlessException. In any case we don't need the
        // cursor because we are running without GUI, so we just abort.
        return null;
    } else {
        Toolkit tk = Toolkit.getDefaultToolkit();
        Image cursorImage = icon.getImage();
        return tk.createCustomCursor(cursorImage, new Point(0, 0), name);
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:15,代码来源:Icons.java

示例11: returnBoxImage

import javax.swing.ImageIcon; //导入方法依赖的package包/类
public Image returnBoxImage() {
	ImageIcon i = new ImageIcon(getClass().getResource(imagePathBox));
	return i.getImage();

}
 
开发者ID:dviol,项目名称:Project15,代码行数:6,代码来源:Game.java

示例12: returnBlueImage

import javax.swing.ImageIcon; //导入方法依赖的package包/类
public Image returnBlueImage() {
	ImageIcon i = new ImageIcon(getClass().getResource(imagePathBlueKey));
	return i.getImage();

}
 
开发者ID:dviol,项目名称:Project15,代码行数:6,代码来源:Game.java

示例13: returnYellowImage

import javax.swing.ImageIcon; //导入方法依赖的package包/类
public Image returnYellowImage() {
	ImageIcon i = new ImageIcon(getClass().getResource(imagePathYellowKey));
	return i.getImage();

}
 
开发者ID:dviol,项目名称:Project15,代码行数:6,代码来源:Game.java

示例14: returnGreenImage

import javax.swing.ImageIcon; //导入方法依赖的package包/类
public Image returnGreenImage() {
	ImageIcon i = new ImageIcon(getClass().getResource(imagePathGreenKey));
	return i.getImage();

}
 
开发者ID:dviol,项目名称:Project15,代码行数:6,代码来源:Game.java

示例15: returnPinkImage

import javax.swing.ImageIcon; //导入方法依赖的package包/类
public Image returnPinkImage() {
	ImageIcon i = new ImageIcon(getClass().getResource(imagePathPinkKey));
	return i.getImage();

}
 
开发者ID:dviol,项目名称:Project15,代码行数:6,代码来源:Game.java


注:本文中的javax.swing.ImageIcon.getImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。