• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ICODecoder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: changed

import net.sf.image4j.codec.ico.ICODecoder; //导入依赖的package包/类
@Override
public void changed(ObservableValue<? extends State> observable, State oldState, State newState) {
	if (newState == Worker.State.SUCCEEDED) {
		try {
			//Determine the full url
			String favIconFullURL = getHostName(webEngine.getLocation()) + "favicon.ico";
			//System.out.println(favIconFullURL)
			
			//Create HttpURLConnection 
			HttpURLConnection httpcon = (HttpURLConnection) new URL(favIconFullURL).openConnection();
			httpcon.addRequestProperty("User-Agent", "Mozilla/5.0");
			List<BufferedImage> image = ICODecoder.read(httpcon.getInputStream());
			
			//Set the favicon
			facIconImageView.setImage(SwingFXUtils.toFXImage(image.get(0), null));
			
		} catch (Exception ex) {
			//ex.printStackTrace()
			facIconImageView.setImage(null);
		}
	}
}
 
开发者ID:goxr3plus,项目名称:JavaFX-Web-Browser,代码行数:23,代码来源:WebBrowserTabController.java


示例2: decodeIcon

import net.sf.image4j.codec.ico.ICODecoder; //导入依赖的package包/类
private ImageIcon decodeIcon(String url) throws IOException {
    try (InputStream stream = new URL(url).openStream()) {
        List<BufferedImage> images = ICODecoder.read(stream);
        for (BufferedImage image : images) {
            if (image.getWidth() == 16) return new ImageIcon(image);
        }
        return scaleImage(images.get(0));
    }
}
 
开发者ID:jonestimd,项目名称:finances,代码行数:10,代码来源:IconLoader.java


示例3: read

import net.sf.image4j.codec.ico.ICODecoder; //导入依赖的package包/类
private static BufferedImage read(URL imageSource, boolean isIcon) throws Exception {
    if (isIcon) {
        java.util.List<BufferedImage> images = ICODecoder.read(imageSource.openStream());
        return images.get(0);
    } else {
        return ImageIO.read(imageSource);
    }
}
 
开发者ID:actframework,项目名称:actframework,代码行数:9,代码来源:Image2ascii.java


示例4: main

import net.sf.image4j.codec.ico.ICODecoder; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    Image2ascii convert = new Image2ascii();
    java.util.List<BufferedImage> images = ICODecoder.read(new File("/home/luog/favicon.ico"));
    String s = convert.convert(images.get(0), true);
    if (images.size() > 0) {
        for (int i = 0; i < images.size(); ++i) {
            ImageIO.write(images.get(i), "png", new File("/home/luog/f" + i + ".png"));
        }
    }
    IO.writeContent(s, new File("/home/luog/a.txt"));
}
 
开发者ID:actframework,项目名称:actframework,代码行数:12,代码来源:Image2ascii.java


示例5: fetchFavIcon

import net.sf.image4j.codec.ico.ICODecoder; //导入依赖的package包/类
/**
 * Fetch a favicon for a given location.
 *
 * @param browserLoc the location of a browser for which a favicon is to be fetched.
 * @return the favicon for the browser location or null if no such favicon could be determined.
 */
public ImageView fetchFavIcon(final String browserLoc) {
    // fetch the favicon from cache if it is there.
    final String serverRoot = findRootLoc(browserLoc);
    ImageView cachedFavicon = faviconCache.get(serverRoot);
    if (cachedFavicon != null) return cachedFavicon;

    // ok, it wasn't in the cache, create a placeholder, to be used if the site doesn't have a favicon.
    final ImageView favicon = new ImageView();

    // if the serverRoot of the location cannot be determined, just return the placeholder.
    if (serverRoot == null) return favicon;

    // store the new favicon placeholder in the cache.
    faviconCache.put(serverRoot, favicon);

    // lazily fetch the real favicon.
    final Task<Image> task = new Task<Image>() {
        @Override
        protected Image call() throws Exception {
            // fetch the favicon from the server if we can.
            URL url = new URL(serverRoot + "/favicon.ico");

            // decode the favicon into an awt image.
            List<BufferedImage> imgs = ICODecoder.read(url.openStream());

            // if the decoding was successful convert to a JavaFX image and return it.
            if (imgs.size() > 0) {
                return ResourceUtil.bufferedImageToFXImage(imgs.get(0), 0, 16, true, true);
            } else {
                return null;
            }
        }
    };

    // replace the placeholder in a favicon whenever the lazy fetch completes.
    task.valueProperty().addListener((observableValue, oldImage, newImage) -> {
        if (newImage != null) {
            favicon.setImage(newImage);
        }
    });

    threadpool.execute(task);

    return favicon;
}
 
开发者ID:proofy,项目名称:willow-browser,代码行数:52,代码来源:FavIconHandler.java


示例6: getIconImage

import net.sf.image4j.codec.ico.ICODecoder; //导入依赖的package包/类
private static Image getIconImage(InputStream in) throws IOException {
    List<BufferedImage> images = ICODecoder.read(in);
    BufferedImage image = Collections.max(images, Comparator.comparingInt(BufferedImage::getWidth));
    return SwingFXUtils.toFXImage(image, null);
}
 
开发者ID:hsiafan,项目名称:byproxy,代码行数:6,代码来源:UIUtils.java


示例7: fetchFavIcon

import net.sf.image4j.codec.ico.ICODecoder; //导入依赖的package包/类
/**
 * Fetch a favicon for a given location.
 *
 * @param browserLoc the location of a browser for which a favicon is to be fetched.
 * @return the favicon for the browser location or null if no such favicon could be determined.
 */
public ImageView fetchFavIcon(final String browserLoc) {
    // fetch the favicon from cache if it is there.
    final String serverRoot = findRootLoc(browserLoc);
    
    
    ImageView cachedFavicon = faviconCache.get(serverRoot);
    if (cachedFavicon != null) return cachedFavicon;

    // ok, it wasn't in the cache, create a placeholder, to be used if the site doesn't have a favicon.
    final ImageView favicon = new ImageView();

    // if the serverRoot of the location cannot be determined, just return the placeholder.
    if (serverRoot == null) return favicon;

    // store the new favicon placeholder in the cache.
    faviconCache.put(serverRoot, favicon);

    // lazily fetch the real favicon.
    final Task<Image> task = new Task<Image>() {
        @Override
        protected Image call() throws Exception {
            // fetch the favicon from the server if we can.
            URL url = new URL(serverRoot + "/favicon.ico");

            // decode the favicon into an awt image.
            List<BufferedImage> imgs = ICODecoder.read(url.openStream());

            // if the decoding was successful convert to a JavaFX image and return it.
            if (imgs.size() > 0) {
                return ResourceUtil.bufferedImageToFXImage(imgs.get(0), 0, 16, true, true);
            } else {
                return null;
            }
        }
    };

    // replace the placeholder in a favicon whenever the lazy fetch completes.
    task.valueProperty().addListener((observableValue, oldImage, newImage) -> {
        if (newImage != null) {
            favicon.setImage(newImage);
        }
    });

    threadpool.execute(task);

    return favicon;
}
 
开发者ID:automenta,项目名称:netentionj-desktop,代码行数:54,代码来源:FavIconHandler.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java VKUIHelper类代码示例发布时间:2022-05-22
下一篇:
Java Operator类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap