本文整理匯總了Java中javax.swing.ImageIcon.getImage方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageIcon.getImage方法的具體用法?Java ImageIcon.getImage怎麽用?Java ImageIcon.getImage使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.ImageIcon的用法示例。
在下文中一共展示了ImageIcon.getImage方法的19個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: getLogo
點讚 4
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,
示例2: aplicaTransparencia
點讚 3
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,
示例3: ImageLabel
點讚 2
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( "" + description ); //NOI18N
setOpaque( false );
setBorder( BorderFactory.createEmptyBorder(1,1,1,1) );
addMouseListener( this );
setCursor( Cursor.getPredefinedCursor(Cursor.HAND_CURSOR) );
}
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,
示例4: loadImageAwt
點讚 2
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,
示例5: loadIcon
點讚 2
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,
示例6: convertToBufferedImage
點讚 2
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,
示例7: afficheRune
點讚 2
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,
示例8: colorize
點讚 2
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,
示例9: attachIcon
點讚 2
import javax.swing.ImageIcon; //導入方法依賴的package包/類
public static void attachIcon(Window frame) {
if (ICONS == null) {
List loadedIcons = new ArrayList();
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,
示例10: createCursor
點讚 2
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,
示例11: returnBoxImage
點讚 2
import javax.swing.ImageIcon; //導入方法依賴的package包/類
public Image returnBoxImage() {
ImageIcon i = new ImageIcon(getClass().getResource(imagePathBox));
return i.getImage();
}
開發者ID:dviol,項目名稱:Project15,代碼行數:6,
示例12: returnBlueImage
點讚 2
import javax.swing.ImageIcon; //導入方法依賴的package包/類
public Image returnBlueImage() {
ImageIcon i = new ImageIcon(getClass().getResource(imagePathBlueKey));
return i.getImage();
}
開發者ID:dviol,項目名稱:Project15,代碼行數:6,
示例13: returnYellowImage
點讚 2
import javax.swing.ImageIcon; //導入方法依賴的package包/類
public Image returnYellowImage() {
ImageIcon i = new ImageIcon(getClass().getResource(imagePathYellowKey));
return i.getImage();
}
開發者ID:dviol,項目名稱:Project15,代碼行數:6,
示例14: returnGreenImage
點讚 2
import javax.swing.ImageIcon; //導入方法依賴的package包/類
public Image returnGreenImage() {
ImageIcon i = new ImageIcon(getClass().getResource(imagePathGreenKey));
return i.getImage();
}
開發者ID:dviol,項目名稱:Project15,代碼行數:6,
示例15: returnPinkImage
點讚 2
import javax.swing.ImageIcon; //導入方法依賴的package包/類
public Image returnPinkImage() {
ImageIcon i = new ImageIcon(getClass().getResource(imagePathPinkKey));
return i.getImage();
}
開發者ID:dviol,項目名稱:Project15,代碼行數:6,
示例16: returnSilverImage
點讚 2
import javax.swing.ImageIcon; //導入方法依賴的package包/類
public Image returnSilverImage() {
ImageIcon i = new ImageIcon(getClass().getResource(imagePathSilverKey));
return i.getImage();
}
開發者ID:dviol,項目名稱:Project15,代碼行數:6,
示例17: returnOrangeImage
點讚 2
import javax.swing.ImageIcon; //導入方法依賴的package包/類
public Image returnOrangeImage() {
ImageIcon i = new ImageIcon(getClass().getResource(imagePathOrangeKey));
return i.getImage();
}
開發者ID:dviol,項目名稱:Project15,代碼行數:6,
示例18: getObstacleImage
點讚 1
import javax.swing.ImageIcon; //導入方法依賴的package包/類
public Image getObstacleImage() {
ImageIcon i = new ImageIcon(getClass().getResource(imagePath));
return i.getImage();
}
開發者ID:dviol,項目名稱:Project15,代碼行數:7,
示例19: getImage
點讚 1
import javax.swing.ImageIcon; //導入方法依賴的package包/類
public Image getImage() {
ImageIcon i = new ImageIcon(getClass().getResource(imagePath));
return i.getImage();
}
開發者ID:dviol,項目名稱:Project15,代碼行數:7,
注:本文中的javax.swing.ImageIcon.getImage方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。