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


Java IIORegistry类代码示例

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


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

示例1: writeTiff

import javax.imageio.spi.IIORegistry; //导入依赖的package包/类
/**
 * Writes a buffered image to a TIFF output stream.
 * @param image buffered image to write out as a TIFF
 * @param output output stream to write to
 * @throws IOException If there is an error writing to
 * <code>output</code>.
 */
private void writeTiff(BufferedImage image, OutputStream output)
        throws IOException {
    try (ImageOutputStream ios =
            ImageIO.createImageOutputStream(output)) {
        IIORegistry registry = IIORegistry.getDefaultInstance();
        registry.registerServiceProviders(
                ServiceRegistry.lookupProviders(
                        TIFFImageWriterSpi.class));
        TIFFImageWriterSpi spi = registry.getServiceProviderByClass(
                TIFFImageWriterSpi.class);
        TIFFImageWriter writer = new TIFFImageWriter(spi);
        writer.setOutput(ios);
        writer.write(null, new IIOImage(image, null, null), null);
    }
}
 
开发者ID:glencoesoftware,项目名称:omero-ms-pixel-buffer,代码行数:23,代码来源:TileRequestHandler.java

示例2: getJPEGTablesReader

import javax.imageio.spi.IIORegistry; //导入依赖的package包/类
/**
 * Retrieves a JPEG reader which supports native JPEG stream metadata.
 */
private static ImageReader getJPEGTablesReader() {
    ImageReader jpegReader = null;

    try {
        IIORegistry registry = IIORegistry.getDefaultInstance();
        Iterator<?> readerSPIs =
            registry.getServiceProviders(ImageReaderSpi.class,
                                         new JPEGSPIFilter(),
                                         true);
        if(readerSPIs.hasNext()) {
            ImageReaderSpi jpegReaderSPI =
                (ImageReaderSpi)readerSPIs.next();
            jpegReader = jpegReaderSPI.createReaderInstance();
        }
    } catch(Exception e) {
        // Ignore it ...
    }

    return jpegReader;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:TIFFJPEGCompressor.java

示例3: OrderingTest

import javax.imageio.spi.IIORegistry; //导入依赖的package包/类
public OrderingTest() {

         ServiceRegistry reg = IIORegistry.getDefaultInstance();
         ImageReaderSpi gifSpi = (ImageReaderSpi) reg.getServiceProviderByClass(com.sun.imageio.plugins.gif.GIFImageReaderSpi.class);
         ImageReaderSpi pngSpi = (ImageReaderSpi) reg.getServiceProviderByClass(com.sun.imageio.plugins.png.PNGImageReaderSpi.class);

         boolean ordered = reg.setOrdering(ImageReaderSpi.class, gifSpi, pngSpi);

         ordered = reg.setOrdering(ImageReaderSpi.class, pngSpi, gifSpi);

         boolean unordered = reg.unsetOrdering(ImageReaderSpi.class, gifSpi,
                                               pngSpi);
         boolean unordered1 = reg.unsetOrdering(ImageReaderSpi.class, gifSpi,
                                                pngSpi);

         if (unordered1) {
             throw new RuntimeException("FAIL: Ordering 2 spi objects in the  "
                                        + "reverse direction does not remove the previous ordering "
                                        + "set between the spi objects and hence unsetOrdering() "
                                        + "returns true for the same spi objects when called consecutively");
         } else {
             System.out.println("PASS");
         }

     }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:OrderingTest.java

示例4: SpiTest

import javax.imageio.spi.IIORegistry; //导入依赖的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

示例5: DeregisterOrderedSpiTest

import javax.imageio.spi.IIORegistry; //导入依赖的package包/类
public DeregisterOrderedSpiTest() {

         try {

             ServiceRegistry reg = IIORegistry.getDefaultInstance();
             ImageReaderSpi gifSpi = (ImageReaderSpi) reg.getServiceProviderByClass(com.sun.imageio.plugins.gif.GIFImageReaderSpi.class);
             ImageReaderSpi pngSpi = (ImageReaderSpi) reg.getServiceProviderByClass(com.sun.imageio.plugins.png.PNGImageReaderSpi.class);
             ImageReaderSpi jpgSpi = (ImageReaderSpi) reg.getServiceProviderByClass(com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi.class);
             ImageReaderSpi bmpSpi = (ImageReaderSpi) reg.getServiceProviderByClass(com.sun.imageio.plugins.bmp.BMPImageReaderSpi.class);

             boolean ordered = reg.setOrdering(ImageReaderSpi.class, pngSpi,
                                               gifSpi);

             ordered = reg.setOrdering(ImageReaderSpi.class, gifSpi, jpgSpi);
             ordered = reg.setOrdering(ImageReaderSpi.class, bmpSpi, gifSpi);
             reg.deregisterServiceProvider(gifSpi);
             System.out.println("PASS");

         } catch (Exception e) {
             System.out.println("FAIL");
             throw new RuntimeException("Deregistering a spi object involved in some "
                                        + "ordering throws the following exception: " + e.toString());
         }
     }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:DeregisterOrderedSpiTest.java

示例6: main

import javax.imageio.spi.IIORegistry; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
    MarkTryFinallyReproducerSpi spi = new MarkTryFinallyReproducerSpi();
    IIORegistry.getDefaultInstance().registerServiceProvider(spi);

    ImageInputStream iis1 =
      new NotClosingImageInputStream(ImageIO.createImageInputStream(new ByteArrayInputStream(bmp)));
    iis1.readByte();
    iis1.mark();
    long p1 = iis1.getStreamPosition();
    iis1.readByte();
    iis1.mark();
    long p2 = iis1.getStreamPosition();
    BufferedImage bi1 = ImageIO.read(iis1);
    iis1.reset();
    long pn2 = iis1.getStreamPosition();
    iis1.reset();
    long pn1 = iis1.getStreamPosition();
    if (p1 != pn1 || p2!= pn2) {
        throw new RuntimeException("Exception from call to canDecodeInput in ImageIO. " +
                                   "Corrupted stack in ImageInputStream");
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:MarkTryFinallyReproducer.java

示例7: main

import javax.imageio.spi.IIORegistry; //导入依赖的package包/类
public static void main (String[] args) throws IIOException {
    // Verify getReaderMIMETypes() behavior by keeping MIMEType as null.
    TestImageReaderSpi mimeNullReadSpi =
            new TestImageReaderSpi(FORMATNAMES, SUFFIXES, null);
    IIORegistry.getDefaultInstance().
            registerServiceProvider(mimeNullReadSpi);
    ImageIO.getReaderMIMETypes();
    IIORegistry.getDefaultInstance().
            deregisterServiceProvider(mimeNullReadSpi);

    /*
     * Verify getReaderFileSuffixes() behavior by keeping
     * file suffix as null.
     */
    TestImageReaderSpi suffixNullReadSpi =
            new TestImageReaderSpi(FORMATNAMES, null, MIMETYPES);
    IIORegistry.getDefaultInstance().
            registerServiceProvider(suffixNullReadSpi);
    ImageIO.getReaderFileSuffixes();
    IIORegistry.getDefaultInstance().
            deregisterServiceProvider(suffixNullReadSpi);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:GetReaderWriterInfoNullTest.java

示例8: main

import javax.imageio.spi.IIORegistry; //导入依赖的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

示例9: getJPEGTablesReader

import javax.imageio.spi.IIORegistry; //导入依赖的package包/类
/**
 * Retrieves a JPEG reader which supports native JPEG stream metadata.
 */
private static ImageReader getJPEGTablesReader() {
    ImageReader jpegReader = null;

    try {
        IIORegistry registry = IIORegistry.getDefaultInstance();
        Class<?> imageReaderClass =
            Class.forName("javax.imageio.spi.ImageReaderSpi");
        Iterator<?> readerSPIs =
            registry.getServiceProviders(imageReaderClass,
                                         new JPEGSPIFilter(),
                                         true);
        if(readerSPIs.hasNext()) {
            ImageReaderSpi jpegReaderSPI =
                (ImageReaderSpi)readerSPIs.next();
            jpegReader = jpegReaderSPI.createReaderInstance();
        }
    } catch(Exception e) {
        // Ignore it ...
    }

    return jpegReader;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:26,代码来源:TIFFJPEGCompressor.java

示例10: registerSpi

import javax.imageio.spi.IIORegistry; //导入依赖的package包/类
private void registerSpi() {
    // We will register a new Spi for creating NIO-based ImageInputStreams.
    final IIORegistry defaultInstance = IIORegistry.getDefaultInstance();
    Iterator<ImageInputStreamSpi> serviceProviders = defaultInstance.getServiceProviders(ImageInputStreamSpi.class, true);
    ImageInputStreamSpi toUnorder = null;
    if (defaultInstance.getServiceProviderByClass(FileImageInputStreamSpi.class) == null) {
        // register only if not already registered
        while (serviceProviders.hasNext()) {
            ImageInputStreamSpi current = serviceProviders.next();
            if (current.getInputClass() == File.class) {
                toUnorder = current;
                break;
            }
        }
        channelImageInputStreamSpi = new FileImageInputStreamSpi();
        defaultInstance.registerServiceProvider(channelImageInputStreamSpi);
        if (toUnorder != null) {
            // Make the custom Spi to be the first one to be used.
            defaultInstance.setOrdering(ImageInputStreamSpi.class, channelImageInputStreamSpi, toUnorder);
        }
    }
}
 
开发者ID:senbox-org,项目名称:s2tbx,代码行数:23,代码来源:RapidEyeReader.java

示例11: registerSpi

import javax.imageio.spi.IIORegistry; //导入依赖的package包/类
/**
 * Registers a file image input strwM SPI for image input stream, if none is yet registered.
 */
protected void registerSpi() {
    final IIORegistry defaultInstance = IIORegistry.getDefaultInstance();
    Iterator<ImageInputStreamSpi> serviceProviders = defaultInstance.getServiceProviders(ImageInputStreamSpi.class, true);
    ImageInputStreamSpi toUnorder = null;
    if (defaultInstance.getServiceProviderByClass(FileImageInputStreamSpi.class) == null) {
        // register only if not already registered
        while (serviceProviders.hasNext()) {
            ImageInputStreamSpi current = serviceProviders.next();
            if (current.getInputClass() == File.class) {
                toUnorder = current;
                break;
            }
        }
        imageInputStreamSpi = new FileImageInputStreamSpi();
        defaultInstance.registerServiceProvider(imageInputStreamSpi);
        if (toUnorder != null) {
            // Make the custom Spi to be the first one to be used.
            defaultInstance.setOrdering(ImageInputStreamSpi.class, imageInputStreamSpi, toUnorder);
        }
    }
}
 
开发者ID:senbox-org,项目名称:s2tbx,代码行数:25,代码来源:GeoTiffBasedReader.java

示例12: initImageIO

import javax.imageio.spi.IIORegistry; //导入依赖的package包/类
private static void initImageIO() {
    // todo - actually this should be done in the activator of ceres-jai which does not exist yet
    Lookup.Result<ModuleInfo> moduleInfos = Lookup.getDefault().lookupResult(ModuleInfo.class);
    String ceresJaiCodeName = "org.esa.snap.ceres.jai";
    Optional<? extends ModuleInfo> info = moduleInfos.allInstances().stream().filter(
            moduleInfo -> ceresJaiCodeName.equals(moduleInfo.getCodeName())).findFirst();

    if (info.isPresent()) {
        ClassLoader classLoader = info.get().getClassLoader();
        IIORegistry iioRegistry = IIORegistry.getDefaultInstance();
        iioRegistry.registerServiceProviders(IIORegistry.lookupProviders(ImageReaderSpi.class, classLoader));
        iioRegistry.registerServiceProviders(IIORegistry.lookupProviders(ImageWriterSpi.class, classLoader));
    } else {
        LOG.warning(String.format("Module '%s' not found. Not able to load image-IO services.", ceresJaiCodeName));
    }
}
 
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:17,代码来源:SnapApp.java

示例13: getJPEGTablesReader

import javax.imageio.spi.IIORegistry; //导入依赖的package包/类
/**
 * Retrieves a JPEG reader which supports native JPEG stream metadata.
 */
private static ImageReader getJPEGTablesReader() {
    ImageReader jpegReader = null;

    try {
        IIORegistry registry = IIORegistry.getDefaultInstance();
        Class imageReaderClass =
            Class.forName("javax.imageio.spi.ImageReaderSpi");
        Iterator readerSPIs =
            registry.getServiceProviders(imageReaderClass,
                                         new JPEGSPIFilter(),
                                         true);
        if(readerSPIs.hasNext()) {
            ImageReaderSpi jpegReaderSPI =
                (ImageReaderSpi)readerSPIs.next();
            jpegReader = jpegReaderSPI.createReaderInstance();
        }
    } catch(Exception e) {
        // Ignore it ...
    }

    return jpegReader;
}
 
开发者ID:scifio,项目名称:scifio-jai-imageio,代码行数:26,代码来源:TIFFJPEGCompressor.java

示例14: initIIOReadFormats

import javax.imageio.spi.IIORegistry; //导入依赖的package包/类
private static void initIIOReadFormats() {
    List spis = new ArrayList();
    List shortNames = new ArrayList();

    ImageIO.scanForPlugins();
    IIORegistry registry = IIORegistry.getDefaultInstance();
    java.util.Iterator readerspis =
        registry.getServiceProviders(ImageReaderSpi.class, false);
    while (readerspis.hasNext()) {
        // REMIND: there could be more than one non-core plugin for
        // a particular format, as is the case for JPEG2000 in the JAI
        // IIO Tools package, so we should support that somehow
        ImageReaderSpi spi = (ImageReaderSpi)readerspis.next();
        String klass = spi.getClass().getName();
        String format = spi.getFormatNames()[0].toLowerCase();
        String suffix = spi.getFileSuffixes()[0].toLowerCase();
        if (suffix == null || suffix.equals("")) {
            suffix = format;
        }
        String shortName;
        if (klass.startsWith("com.sun.imageio.plugins")) {
            shortName = "core-" + suffix;
        } else {
            shortName = "ext-" + suffix;
        }
        spis.add(spi);
        shortNames.add(shortName);
    }

    imageioReaderSpis = new ImageReaderSpi[spis.size()];
    imageioReaderSpis = (ImageReaderSpi[])spis.toArray(imageioReaderSpis);
    imageioReadFormatShortNames = new String[shortNames.size()];
    imageioReadFormatShortNames =
        (String[])shortNames.toArray(imageioReadFormatShortNames);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:InputImageTests.java

示例15: initIIOWriteFormats

import javax.imageio.spi.IIORegistry; //导入依赖的package包/类
private static void initIIOWriteFormats() {
    List spis = new ArrayList();
    List shortNames = new ArrayList();

    ImageIO.scanForPlugins();
    IIORegistry registry = IIORegistry.getDefaultInstance();
    java.util.Iterator writerspis =
        registry.getServiceProviders(ImageWriterSpi.class, false);
    while (writerspis.hasNext()) {
        // REMIND: there could be more than one non-core plugin for
        // a particular format, as is the case for JPEG2000 in the JAI
        // IIO Tools package, so we should support that somehow
        ImageWriterSpi spi = (ImageWriterSpi)writerspis.next();
        String klass = spi.getClass().getName();
        String format = spi.getFormatNames()[0].toLowerCase();
        String suffix = spi.getFileSuffixes()[0].toLowerCase();
        if (suffix == null || suffix.equals("")) {
            suffix = format;
        }
        String shortName;
        if (klass.startsWith("com.sun.imageio.plugins")) {
            shortName = "core-" + suffix;
        } else {
            shortName = "ext-" + suffix;
        }
        spis.add(spi);
        shortNames.add(shortName);
    }

    imageioWriterSpis = new ImageWriterSpi[spis.size()];
    imageioWriterSpis = (ImageWriterSpi[])spis.toArray(imageioWriterSpis);
    imageioWriteFormatShortNames = new String[shortNames.size()];
    imageioWriteFormatShortNames =
        (String[])shortNames.toArray(imageioWriteFormatShortNames);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:OutputImageTests.java


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