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


Java ImageWriterSpi类代码示例

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


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

示例1: getImageWritersByFormatName

import javax.imageio.spi.ImageWriterSpi; //导入依赖的package包/类
/**
 * Returns an <code>Iterator</code> containing all currently
 * registered <code>ImageWriter</code>s that claim to be able to
 * encode the named format.
 *
 * @param formatName a <code>String</code> containing the informal
 * name of a format (<i>e.g.</i>, "jpeg" or "tiff".
 *
 * @return an <code>Iterator</code> containing
 * <code>ImageWriter</code>s.
 *
 * @exception IllegalArgumentException if <code>formatName</code> is
 * <code>null</code>.
 *
 * @see javax.imageio.spi.ImageWriterSpi#getFormatNames
 */
public static Iterator<ImageWriter>
    getImageWritersByFormatName(String formatName)
{
    if (formatName == null) {
        throw new IllegalArgumentException("formatName == null!");
    }
    Iterator iter;
    // Ensure category is present
    try {
        iter = theRegistry.getServiceProviders(ImageWriterSpi.class,
                                new ContainsFilter(writerFormatNamesMethod,
                                                   formatName),
                                        true);
    } catch (IllegalArgumentException e) {
        return Collections.emptyIterator();
    }
    return new ImageWriterIterator(iter);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:35,代码来源:ImageIO.java

示例2: getImageWritersBySuffix

import javax.imageio.spi.ImageWriterSpi; //导入依赖的package包/类
/**
 * Returns an <code>Iterator</code> containing all currently
 * registered <code>ImageWriter</code>s that claim to be able to
 * encode files with the given suffix.
 *
 * @param fileSuffix a <code>String</code> containing a file
 * suffix (<i>e.g.</i>, "jpg" or "tiff").
 *
 * @return an <code>Iterator</code> containing <code>ImageWriter</code>s.
 *
 * @exception IllegalArgumentException if <code>fileSuffix</code> is
 * <code>null</code>.
 *
 * @see javax.imageio.spi.ImageWriterSpi#getFileSuffixes
 */
public static Iterator<ImageWriter>
    getImageWritersBySuffix(String fileSuffix)
{
    if (fileSuffix == null) {
        throw new IllegalArgumentException("fileSuffix == null!");
    }
    Iterator iter;
    // Ensure category is present
    try {
        iter = theRegistry.getServiceProviders(ImageWriterSpi.class,
                               new ContainsFilter(writerFileSuffixesMethod,
                                                  fileSuffix),
                                        true);
    } catch (IllegalArgumentException e) {
        return Collections.emptyIterator();
    }
    return new ImageWriterIterator(iter);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:ImageIO.java

示例3: getImageWritersByMIMEType

import javax.imageio.spi.ImageWriterSpi; //导入依赖的package包/类
/**
 * Returns an <code>Iterator</code> containing all currently
 * registered <code>ImageWriter</code>s that claim to be able to
 * encode files with the given MIME type.
 *
 * @param MIMEType a <code>String</code> containing a file
 * suffix (<i>e.g.</i>, "image/jpeg" or "image/x-bmp").
 *
 * @return an <code>Iterator</code> containing <code>ImageWriter</code>s.
 *
 * @exception IllegalArgumentException if <code>MIMEType</code> is
 * <code>null</code>.
 *
 * @see javax.imageio.spi.ImageWriterSpi#getMIMETypes
 */
public static Iterator<ImageWriter>
    getImageWritersByMIMEType(String MIMEType)
{
    if (MIMEType == null) {
        throw new IllegalArgumentException("MIMEType == null!");
    }
    Iterator iter;
    // Ensure category is present
    try {
        iter = theRegistry.getServiceProviders(ImageWriterSpi.class,
                                  new ContainsFilter(writerMIMETypesMethod,
                                                     MIMEType),
                                        true);
    } catch (IllegalArgumentException e) {
        return Collections.emptyIterator();
    }
    return new ImageWriterIterator(iter);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:ImageIO.java

示例4: getImageWriters

import javax.imageio.spi.ImageWriterSpi; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:41,代码来源:ImageIO.java

示例5: getImageTranscoders

import javax.imageio.spi.ImageWriterSpi; //导入依赖的package包/类
/**
 * Returns an <code>Iterator</code> containing all currently
 * registered <code>ImageTranscoder</code>s that claim to be
 * able to transcode between the metadata of the given
 * <code>ImageReader</code> and <code>ImageWriter</code>.
 *
 * @param reader an <code>ImageReader</code>.
 * @param writer an <code>ImageWriter</code>.
 *
 * @return an <code>Iterator</code> containing
 * <code>ImageTranscoder</code>s.
 *
 * @exception IllegalArgumentException if <code>reader</code> or
 * <code>writer</code> is <code>null</code>.
 */
public static Iterator<ImageTranscoder>
    getImageTranscoders(ImageReader reader, ImageWriter writer)
{
    if (reader == null) {
        throw new IllegalArgumentException("reader == null!");
    }
    if (writer == null) {
        throw new IllegalArgumentException("writer == null!");
    }
    ImageReaderSpi readerSpi = reader.getOriginatingProvider();
    ImageWriterSpi writerSpi = writer.getOriginatingProvider();
    ServiceRegistry.Filter filter =
        new TranscoderFilter(readerSpi, writerSpi);

    Iterator iter;
    // Ensure category is present
    try {
        iter = theRegistry.getServiceProviders(ImageTranscoderSpi.class,
                                        filter, true);
    } catch (IllegalArgumentException e) {
        return Collections.emptyIterator();
    }
    return new ImageTranscoderIterator(iter);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:40,代码来源:ImageIO.java

示例6: doTest

import javax.imageio.spi.ImageWriterSpi; //导入依赖的package包/类
public void doTest() {
    File pwd = new File(".");
    try {
        File f = File.createTempFile("transparency_test_", ".gif", pwd);
        System.out.println("file: " + f.getCanonicalPath());

        ImageWriter w = ImageIO.getImageWritersByFormatName("GIF").next();

        ImageWriterSpi spi = w.getOriginatingProvider();

        boolean succeed_write = ImageIO.write(src, "gif", f);

        if (!succeed_write) {
            throw new RuntimeException("Test failed: failed to write src.");
        }

        dst = ImageIO.read(f);

        checkResult(src, dst);

    } catch (IOException e) {
        throw new RuntimeException("Test failed.", e);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:GifTransparencyTest.java

示例7: getImageWritersByFormatName

import javax.imageio.spi.ImageWriterSpi; //导入依赖的package包/类
/**
 * Returns an {@code Iterator} containing all currently
 * registered {@code ImageWriter}s that claim to be able to
 * encode the named format.
 *
 * @param formatName a {@code String} containing the informal
 * name of a format (<i>e.g.</i>, "jpeg" or "tiff".
 *
 * @return an {@code Iterator} containing
 * {@code ImageWriter}s.
 *
 * @exception IllegalArgumentException if {@code formatName} is
 * {@code null}.
 *
 * @see javax.imageio.spi.ImageWriterSpi#getFormatNames
 */
public static Iterator<ImageWriter>
    getImageWritersByFormatName(String formatName)
{
    if (formatName == null) {
        throw new IllegalArgumentException("formatName == null!");
    }
    Iterator<ImageWriterSpi> iter;
    // Ensure category is present
    try {
        iter = theRegistry.getServiceProviders(ImageWriterSpi.class,
                                new ContainsFilter(writerFormatNamesMethod,
                                                   formatName),
                                        true);
    } catch (IllegalArgumentException e) {
        return Collections.emptyIterator();
    }
    return new ImageWriterIterator(iter);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:ImageIO.java

示例8: getImageWritersBySuffix

import javax.imageio.spi.ImageWriterSpi; //导入依赖的package包/类
/**
 * Returns an {@code Iterator} containing all currently
 * registered {@code ImageWriter}s that claim to be able to
 * encode files with the given suffix.
 *
 * @param fileSuffix a {@code String} containing a file
 * suffix (<i>e.g.</i>, "jpg" or "tiff").
 *
 * @return an {@code Iterator} containing {@code ImageWriter}s.
 *
 * @exception IllegalArgumentException if {@code fileSuffix} is
 * {@code null}.
 *
 * @see javax.imageio.spi.ImageWriterSpi#getFileSuffixes
 */
public static Iterator<ImageWriter>
    getImageWritersBySuffix(String fileSuffix)
{
    if (fileSuffix == null) {
        throw new IllegalArgumentException("fileSuffix == null!");
    }
    Iterator<ImageWriterSpi> iter;
    // Ensure category is present
    try {
        iter = theRegistry.getServiceProviders(ImageWriterSpi.class,
                               new ContainsFilter(writerFileSuffixesMethod,
                                                  fileSuffix),
                                        true);
    } catch (IllegalArgumentException e) {
        return Collections.emptyIterator();
    }
    return new ImageWriterIterator(iter);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:ImageIO.java

示例9: getImageWritersByMIMEType

import javax.imageio.spi.ImageWriterSpi; //导入依赖的package包/类
/**
 * Returns an {@code Iterator} containing all currently
 * registered {@code ImageWriter}s that claim to be able to
 * encode files with the given MIME type.
 *
 * @param MIMEType a {@code String} containing a file
 * suffix (<i>e.g.</i>, "image/jpeg" or "image/x-bmp").
 *
 * @return an {@code Iterator} containing {@code ImageWriter}s.
 *
 * @exception IllegalArgumentException if {@code MIMEType} is
 * {@code null}.
 *
 * @see javax.imageio.spi.ImageWriterSpi#getMIMETypes
 */
public static Iterator<ImageWriter>
    getImageWritersByMIMEType(String MIMEType)
{
    if (MIMEType == null) {
        throw new IllegalArgumentException("MIMEType == null!");
    }
    Iterator<ImageWriterSpi> iter;
    // Ensure category is present
    try {
        iter = theRegistry.getServiceProviders(ImageWriterSpi.class,
                                  new ContainsFilter(writerMIMETypesMethod,
                                                     MIMEType),
                                        true);
    } catch (IllegalArgumentException e) {
        return Collections.emptyIterator();
    }
    return new ImageWriterIterator(iter);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:ImageIO.java

示例10: getImageWriters

import javax.imageio.spi.ImageWriterSpi; //导入依赖的package包/类
/**
 * Returns an {@code Iterator} containing all currently
 * registered {@code ImageWriter}s that claim to be able to
 * encode images of the given layout (specified using an
 * {@code ImageTypeSpecifier}) in the given format.
 *
 * @param type an {@code ImageTypeSpecifier} indicating the
 * layout of the image to be written.
 * @param formatName the informal name of the {@code format}.
 *
 * @return an {@code Iterator} containing {@code ImageWriter}s.
 *
 * @exception IllegalArgumentException if any parameter is
 * {@code null}.
 *
 * @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<ImageWriterSpi> 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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:41,代码来源:ImageIO.java

示例11: getImageTranscoders

import javax.imageio.spi.ImageWriterSpi; //导入依赖的package包/类
/**
 * Returns an {@code Iterator} containing all currently
 * registered {@code ImageTranscoder}s that claim to be
 * able to transcode between the metadata of the given
 * {@code ImageReader} and {@code ImageWriter}.
 *
 * @param reader an {@code ImageReader}.
 * @param writer an {@code ImageWriter}.
 *
 * @return an {@code Iterator} containing
 * {@code ImageTranscoder}s.
 *
 * @exception IllegalArgumentException if {@code reader} or
 * {@code writer} is {@code null}.
 */
public static Iterator<ImageTranscoder>
    getImageTranscoders(ImageReader reader, ImageWriter writer)
{
    if (reader == null) {
        throw new IllegalArgumentException("reader == null!");
    }
    if (writer == null) {
        throw new IllegalArgumentException("writer == null!");
    }
    ImageReaderSpi readerSpi = reader.getOriginatingProvider();
    ImageWriterSpi writerSpi = writer.getOriginatingProvider();
    ServiceRegistry.Filter filter =
        new TranscoderFilter(readerSpi, writerSpi);

    Iterator<ImageTranscoderSpi> iter;
    // Ensure category is present
    try {
        iter = theRegistry.getServiceProviders(ImageTranscoderSpi.class,
                                        filter, true);
    } catch (IllegalArgumentException e) {
        return Collections.emptyIterator();
    }
    return new ImageTranscoderIterator(iter);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:40,代码来源:ImageIO.java

示例12: SpiTest

import javax.imageio.spi.ImageWriterSpi; //导入依赖的package包/类
public SpiTest() {
    testImageReaderSpiConstructor();
    testImageWriterSpiConstructor();

    ServiceRegistry registry = IIORegistry.getDefaultInstance();
    Iterator readers = registry.getServiceProviders(ImageReaderSpi.class,
                                                    false);
    while (readers.hasNext()) {
        ImageReaderSpi rspi = (ImageReaderSpi)readers.next();
        System.out.println("*** Testing " + rspi.getClass().getName());
        testSpi(rspi);
    }

    Iterator writers = registry.getServiceProviders(ImageWriterSpi.class,
                                                    false);
    while (writers.hasNext()) {
        ImageWriterSpi wspi = (ImageWriterSpi)writers.next();
        System.out.println("*** Testing " + wspi.getClass().getName());
        testSpi(wspi);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:SpiTest.java

示例13: main

import javax.imageio.spi.ImageWriterSpi; //导入依赖的package包/类
public static void main(String[] args) {
    ImageReaderSpi rspi = new PNGImageReaderSpi();
    if (rspi.getNativeStreamMetadataFormatName() != null) {
        fatal();
    }
    if (rspi.isStandardStreamMetadataFormatSupported() != false) {
        fatal();
    }
    if (rspi.getExtraStreamMetadataFormatNames() != null) {
        fatal();
    }

    ImageWriterSpi wspi = new PNGImageWriterSpi();
    if (wspi.getNativeStreamMetadataFormatName() != null) {
        fatal();
    }
    if (wspi.isStandardStreamMetadataFormatSupported() != false) {
        fatal();
    }
    if (wspi.getExtraStreamMetadataFormatNames() != null) {
        fatal();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:PNGSpiStreamMetadata.java

示例14: main

import javax.imageio.spi.ImageWriterSpi; //导入依赖的package包/类
public static void main(final String[] args) throws IOException {
    final IIORegistry registry = IIORegistry.getDefaultInstance();
    final Iterator<ImageWriterSpi> iter = registry.getServiceProviders(
            ImageWriterSpi.class, provider -> true, true);

    // Validates all supported ImageWriters
    int numFailures = 0;
    while (iter.hasNext()) {
        final WriteAfterAbort writeAfterAbort = new WriteAfterAbort();
        final ImageWriter writer = iter.next().createWriterInstance();
        System.out.println("ImageWriter = " + writer);
        try {
            writeAfterAbort.test(writer);
        } catch (Exception e) {
            System.err.println("Test failed for \""
                + writer.getOriginatingProvider().getFormatNames()[0]
                + "\" format.");
            numFailures++;
        }
    }
    if (numFailures == 0) {
        System.out.println("Test passed.");
    } else {
        throw new RuntimeException("Test failed.");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:WriteAfterAbort.java

示例15: getWriterMIMETypes

import javax.imageio.spi.ImageWriterSpi; //导入依赖的package包/类
/**
 * Retrieve all the MIME types supported by the collection of
 * registered image writers.
 *
 * @return an array of MIME types
 */
public static String[] getWriterMIMETypes()
{
  try
    {
      Iterator it =
        getRegistry().getServiceProviders(ImageWriterSpi.class, true);
      ArrayList result = new ArrayList();

      while (it.hasNext())
        {
          ImageWriterSpi spi = (ImageWriterSpi) it.next();
          String[] names = spi.getMIMETypes();

          for (int i = names.length - 1; i >= 0; --i)
            result.add(names[i]);
        }

      return (String[]) result.toArray(new String[result.size()]);
    }
  catch (IllegalArgumentException e)
    {
      return new String[0];
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:31,代码来源:ImageIO.java


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