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


Java Image类代码示例

本文整理汇总了Java中java.awt.Image的典型用法代码示例。如果您正苦于以下问题:Java Image类的具体用法?Java Image怎么用?Java Image使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: copyImage

import java.awt.Image; //导入依赖的package包/类
/**
 * Not part of the advertised API but a useful utility method
 * to call internally.  This is for the case where we are
 * drawing to/from given coordinates using a given width/height,
 * but we guarantee that the surfaceData's width/height of the src and dest
 * areas are equal (no scale needed). Note that this method intentionally
 * ignore scale factor of the source image, and copy it as is.
 */
public boolean copyImage(Image img, int dx, int dy, int sx, int sy,
                         int width, int height, Color bgcolor,
                         ImageObserver observer) {
    try {
        return imagepipe.copyImage(this, img, dx, dy, sx, sy,
                                   width, height, bgcolor, observer);
    } catch (InvalidPipeException e) {
        try {
            revalidateAll();
            return imagepipe.copyImage(this, img, dx, dy, sx, sy,
                                       width, height, bgcolor, observer);
        } catch (InvalidPipeException e2) {
            // Still catching the exception; we are not yet ready to
            // validate the surfaceData correctly.  Fail for now and
            // try again next time around.
            return false;
        }
    } finally {
        surfaceData.markDirty();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:SunGraphics2D.java

示例2: getDisabledIcon

import java.awt.Image; //导入依赖的package包/类
public static XBIcon getDisabledIcon(int which, boolean selected) {
	if( which<0 || which>=disIcons.length ) return getDefaultIcon(selected);
	int i = selected ? 1 : 0;
	if( disIcons[which][i]!=null )return disIcons[which][i];
	int i1 = (i+1)%2;
	if( disIcons[which][i1]!=null ) {
		disIcons[which][i] = new XBIcon(disIcons[which][i1].getImage(), selected);
		return disIcons[which][i];
	}

	try {
		if( loader==null ) {
			loader = org.geomapapp.util.Icons.class.getClassLoader();
		}
		String path = "org/geomapapp/resources/icons/" +names[which];
		java.net.URL url = loader.getResource(path);
		BufferedImage im = ImageIO.read(url);
		Image im1 = GrayFilter.createDisabledImage(im);
		Graphics g = im.createGraphics();
		g.drawImage(im1,0,0, new JPanel() );
		disIcons[which][i] = new XBIcon(im, selected);
	} catch(Exception ex) {
		return getDefaultIcon(selected);
	}
	return disIcons[which][i];
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:27,代码来源:Icons.java

示例3: waitForDimensions

import java.awt.Image; //导入依赖的package包/类
private synchronized void waitForDimensions(Image img) {
    mHeight = img.getHeight(this);
    mWidth = img.getWidth(this);
    while (!badImage && (mWidth < 0 || mHeight < 0)) {
        try {
            Thread.sleep(50);
        } catch(InterruptedException e) {
            // do nothing.
        }
        mHeight = img.getHeight(this);
        mWidth = img.getWidth(this);
    }
    if (badImage) {
        mHeight = 0;
        mWidth = 0;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:PeekGraphics.java

示例4: SpriteManager

import java.awt.Image; //导入依赖的package包/类
public SpriteManager(String p, int tw, int th, int n,boolean l)
{
    loop = l;
    maxIms = n;
    index = 0;
    count = 0;
    delay = 10;

    currFrame = 0;
    ims = new Image[n];

    try
    {
        BufferedImage tIm = ImageIO.read(new File(p));            
        for (int i = 0; i < n; i++)
        {
            add(tIm.getSubimage(i*tw, 0, tw, th));
        }
    }
    catch(IOException e)
    {
        e.printStackTrace();
    }        
}
 
开发者ID:CoffeeCodeSwitzerland,项目名称:Lernkartei_2017,代码行数:25,代码来源:SpriteManager.java

示例5: FrameBuilder

import java.awt.Image; //导入依赖的package包/类
FrameBuilder(Instance instance, Heap heap) {
    super(instance, heap);
    
    title = Utils.getFieldString(instance, "title");
    undecorated = DetailsUtils.getBooleanFieldValue(instance, "undecorated", false);
    
    Image _image = null;
    Object icons = instance.getValueOfField("icons");
    if (icons instanceof Instance) {
        Instance i = (Instance)icons;
        if (DetailsUtils.getIntFieldValue(i, "size", 0) > 0) {
            Object elementData = i.getValueOfField("elementData");
            if (elementData instanceof ObjectArrayInstance) {
                Object o = ((ObjectArrayInstance)elementData).getValues().get(0);
                _image = o != null ? ImageBuilder.buildImage((Instance)o, heap) : null;
            }
        }
    }
    image = _image;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:WindowBuilders.java

示例6: readImage32

import java.awt.Image; //导入依赖的package包/类
protected static Image readImage32(FileInputStream fs, BitmapHeader bh) throws IOException {
	Image image;
	final int ndata[] = new int[bh.iHeight * bh.iWidth];
	final byte brgb[] = new byte[bh.iWidth * 4 * bh.iHeight];
	fs.read(brgb, 0, bh.iWidth * 4 * bh.iHeight);
	int nindex = 0;
	for (int j = 0; j < bh.iHeight; j++) {
		for (int i = 0; i < bh.iWidth; i++) {
			ndata[bh.iWidth * (bh.iHeight - j - 1) + i] = constructInt3(brgb, nindex);
			nindex += 4;
		}
	}
	image = Toolkit.getDefaultToolkit()
			.createImage(new MemoryImageSource(bh.iWidth, bh.iHeight, ndata, 0, bh.iWidth));
	fs.close();
	return (image);
}
 
开发者ID:zylo117,项目名称:SpotSpotter,代码行数:18,代码来源:BMPReader.java

示例7: convertToBufferedImage

import java.awt.Image; //导入依赖的package包/类
private BufferedImage convertToBufferedImage(Image image) throws IOException {
    if (image instanceof BufferedImage) {
        return (BufferedImage)image;

    } else {
        MediaTracker tracker = new MediaTracker(new Component(){}); // not sure if this is the right thing to do.
        tracker.addImage(image, 0);
        try {
            tracker.waitForAll();
        } catch (InterruptedException e) {
            throw new IOException(e.getMessage());
        }
        BufferedImage bufImage = new BufferedImage(
                image.getWidth(null),
                image.getHeight(null),
                BufferedImage.TYPE_INT_ARGB);

        Graphics g = bufImage.createGraphics();
        g.drawImage(image, 0, 0, null);
        return bufImage;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:RuntimeBuiltinLeafInfoImpl.java

示例8: getIcon

import java.awt.Image; //导入依赖的package包/类
@Override
public Icon getIcon() {
    Node[] nodes = getNodes();
    if (nodes.length > 1) {
        return MULTI_SELECTION_ICON;
    } else if (nodes.length == 1 && nodes[0] != null) {
        Node n = nodes[0];
        Image image = n.getIcon(BeanInfo.ICON_COLOR_16x16);
        if (image != null) {
            return ImageUtilities.image2Icon(image);
        } else {
            return null;
        }
    } else {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:SearchScopeNodeSelection.java

示例9: waitForDimensions

import java.awt.Image; //导入依赖的package包/类
synchronized private void waitForDimensions(Image img) {
    mHeight = img.getHeight(this);
    mWidth = img.getWidth(this);
    while (!badImage && (mWidth < 0 || mHeight < 0)) {
        try {
            Thread.sleep(50);
        } catch(InterruptedException e) {
            // do nothing.
        }
        mHeight = img.getHeight(this);
        mWidth = img.getWidth(this);
    }
    if (badImage) {
        mHeight = 0;
        mWidth = 0;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:PeekGraphics.java

示例10: getManager

import java.awt.Image; //导入依赖的package包/类
/**
 * Returns the SurfaceManager object contained within the given Image.
 */
public static SurfaceManager getManager(Image img) {
    SurfaceManager sMgr = imgaccessor.getSurfaceManager(img);
    if (sMgr == null) {
        /*
         * In practice only a BufferedImage will get here.
         */
        try {
            BufferedImage bi = (BufferedImage) img;
            sMgr = new BufImgSurfaceManager(bi);
            setManager(bi, sMgr);
        } catch (ClassCastException e) {
            throw new IllegalArgumentException("Invalid Image variant");
        }
    }
    return sMgr;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:SurfaceManager.java

示例11: annotateIcon

import java.awt.Image; //导入依赖的package包/类
@Override
@NonNull
public Image annotateIcon(
        @NonNull final Project p,
        @NonNull Image original,
        final boolean openedNode) {
    Boolean type = projectType.get(p);
    if (type != null) {
        if(type.booleanValue() == true) {
            final Image badge = getJFXBadge();
            if (badge != null) {
                original = ImageUtilities.mergeImages(original, badge, 8, 8);
            }
        }
    } else {
        evaluateProjectType(p);
    }
    return original;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:JFXProjectIconAnnotator.java

示例12: readIconFromFile

import java.awt.Image; //导入依赖的package包/类
private Icon readIconFromFile( File iconFile ) {
    try {
        Image img = ImageIO.read( iconFile.toURL() );
        if( null != img ) {
            ImageIcon res = new ImageIcon( img );
            if( res.getIconWidth() > 32 || res.getIconHeight() > 32 )  {
                JOptionPane.showMessageDialog(this, NbBundle.getMessage(TextImporterUI.class, "Err_IconTooBig"), //NOI18N
                        NbBundle.getMessage(TextImporterUI.class, "Err_Title"), JOptionPane.ERROR_MESSAGE  ); //NOI18N
                return null;
            }
            return res;
        }
    } catch( ThreadDeath td ) {
        throw td;
    } catch( Throwable ioE ) {
        //ignore
    }
    JOptionPane.showMessageDialog(this, 
            NbBundle.getMessage(TextImporterUI.class, "Err_CannotLoadIconFromFile", iconFile.getName()), //NOI18N
            NbBundle.getMessage(TextImporterUI.class, "Err_Title"), JOptionPane.ERROR_MESSAGE  ); //NOI18N
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:TextImporterUI.java

示例13: convertToPNG

import java.awt.Image; //导入依赖的package包/类
private static byte[] convertToPNG(Image image) {
   ByteArrayOutputStream out = new ByteArrayOutputStream();
   int width = image.getWidth(null);
   int height = image.getHeight(null);
   BufferedImage bi = new BufferedImage(width, height,
                                        BufferedImage.TYPE_INT_ARGB);
   Graphics2D g = bi.createGraphics();
   g.setComposite(AlphaComposite.Src);
   g.drawImage(image, 0, 0, null);
   g.dispose();
   ImageOutputStream ios = new MemoryCacheImageOutputStream(out);
   try {
      if (!ImageIO.write(bi, "PNG", ios)) {
         throw new IOException("ImageIO.write failed");
      }
      ios.close();
   } catch (IOException ex) {
      throw new RuntimeException("saveImage: " + ex.getMessage());
   }
   return out.toByteArray();
}
 
开发者ID:eric-roberts,项目名称:JavaPPTX,代码行数:22,代码来源:PPPicture.java

示例14: getSystemIcon

import java.awt.Image; //导入依赖的package包/类
/**
 * Icon for a file, directory, or folder as it would be displayed in
 * a system file browser. Example from Windows: the "M:\" directory
 * displays a CD-ROM icon.
 *
 * The default implementation gets information from the ShellFolder class.
 *
 * @param f a <code>File</code> object
 * @return an icon as it would be displayed by a native file chooser
 * @see JFileChooser#getIcon
 * @since 1.4
 */
public Icon getSystemIcon(File f) {
    if (f == null) {
        return null;
    }

    ShellFolder sf;

    try {
        sf = getShellFolder(f);
    } catch (FileNotFoundException e) {
        return null;
    }

    Image img = sf.getIcon(false);

    if (img != null) {
        return new ImageIcon(img, sf.getFolderType());
    } else {
        return UIManager.getIcon(f.isDirectory() ? "FileView.directoryIcon" : "FileView.fileIcon");
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:FileSystemView.java

示例15: getProperty

import java.awt.Image; //导入依赖的package包/类
/**
 * Return a property of the image by name.  Individual property names
 * are defined by the various image formats.  If a property is not
 * defined for a particular image, then this method will return the
 * UndefinedProperty object.  If the properties for this image are
 * not yet known, then this method will return null and the ImageObserver
 * object will be notified later.  The property name "comment" should
 * be used to store an optional comment which can be presented to
 * the user as a description of the image, its source, or its author.
 */
public Object getProperty(String name, ImageObserver observer) {
    if (name == null) {
        throw new NullPointerException("null property name is not allowed");
    }

    if (src != null) {
        src.checkSecurity(null, false);
    }
    if (properties == null) {
        addWatcher(observer, true);
        if (properties == null) {
            return null;
        }
    }
    Object o = properties.get(name);
    if (o == null) {
        o = Image.UndefinedProperty;
    }
    return o;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:31,代码来源:ToolkitImage.java


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