ImageIO.java 文件源码

java
阅读 30 收藏 0 点赞 0 评论 0

项目:Java8CN 作者:
/**
 * Returns an <code>Iterator</code> containing all currently
 * registered <code>ImageWriter</code>s that claim to be able to
 * encode images of the given layout (specified using an
 * <code>ImageTypeSpecifier</code>) in the given format.
 *
 * @param type an <code>ImageTypeSpecifier</code> indicating the
 * layout of the image to be written.
 * @param formatName the informal name of the <code>format</code>.
 *
 * @return an <code>Iterator</code> containing <code>ImageWriter</code>s.
 *
 * @exception IllegalArgumentException if any parameter is
 * <code>null</code>.
 *
 * @see javax.imageio.spi.ImageWriterSpi#canEncodeImage(ImageTypeSpecifier)
 */
public static Iterator<ImageWriter>
    getImageWriters(ImageTypeSpecifier type, String formatName)
{
    if (type == null) {
        throw new IllegalArgumentException("type == null!");
    }
    if (formatName == null) {
        throw new IllegalArgumentException("formatName == null!");
    }

    Iterator iter;
    // Ensure category is present
    try {
        iter = theRegistry.getServiceProviders(ImageWriterSpi.class,
                             new CanEncodeImageAndFormatFilter(type,
                                                               formatName),
                                        true);
    } catch (IllegalArgumentException e) {
        return Collections.emptyIterator();
    }

    return new ImageWriterIterator(iter);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号