本文整理汇总了Java中javax.imageio.spi.ImageReaderSpi类的典型用法代码示例。如果您正苦于以下问题:Java ImageReaderSpi类的具体用法?Java ImageReaderSpi怎么用?Java ImageReaderSpi使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImageReaderSpi类属于javax.imageio.spi包,在下文中一共展示了ImageReaderSpi类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getImageReadersByFormatName
import javax.imageio.spi.ImageReaderSpi; //导入依赖的package包/类
getImageReadersByFormatName(String formatName)
{
if (formatName == null) {
throw new IllegalArgumentException("formatName == null!");
}
Iterator iter;
// Ensure category is present
try {
iter = theRegistry.getServiceProviders(ImageReaderSpi.class,
new ContainsFilter(readerFormatNamesMethod,
formatName),
true);
} catch (IllegalArgumentException e) {
return Collections.emptyIterator();
}
return new ImageReaderIterator(iter);
}
示例2: getImageReadersBySuffix
import javax.imageio.spi.ImageReaderSpi; //导入依赖的package包/类
/**
* Returns an <code>Iterator</code> containing all currently
* registered <code>ImageReader</code>s that claim to be able to
* decode 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>ImageReader</code>s.
*
* @exception IllegalArgumentException if <code>fileSuffix</code>
* is <code>null</code>.
*
* @see javax.imageio.spi.ImageReaderSpi#getFileSuffixes
*/
public static Iterator<ImageReader>
getImageReadersBySuffix(String fileSuffix)
{
if (fileSuffix == null) {
throw new IllegalArgumentException("fileSuffix == null!");
}
// Ensure category is present
Iterator iter;
try {
iter = theRegistry.getServiceProviders(ImageReaderSpi.class,
new ContainsFilter(readerFileSuffixesMethod,
fileSuffix),
true);
} catch (IllegalArgumentException e) {
return Collections.emptyIterator();
}
return new ImageReaderIterator(iter);
}
示例3: getImageReadersByMIMEType
import javax.imageio.spi.ImageReaderSpi; //导入依赖的package包/类
/**
* Returns an <code>Iterator</code> containing all currently
* registered <code>ImageReader</code>s that claim to be able to
* decode 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>ImageReader</code>s.
*
* @exception IllegalArgumentException if <code>MIMEType</code> is
* <code>null</code>.
*
* @see javax.imageio.spi.ImageReaderSpi#getMIMETypes
*/
public static Iterator<ImageReader>
getImageReadersByMIMEType(String MIMEType)
{
if (MIMEType == null) {
throw new IllegalArgumentException("MIMEType == null!");
}
// Ensure category is present
Iterator iter;
try {
iter = theRegistry.getServiceProviders(ImageReaderSpi.class,
new ContainsFilter(readerMIMETypesMethod,
MIMEType),
true);
} catch (IllegalArgumentException e) {
return Collections.emptyIterator();
}
return new ImageReaderIterator(iter);
}
示例4: getImageTranscoders
import javax.imageio.spi.ImageReaderSpi; //导入依赖的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);
}
示例5: doTest
import javax.imageio.spi.ImageReaderSpi; //导入依赖的package包/类
public void doTest(ImageReaderSpi spi) throws IOException {
System.out.println("Test for " + title +
(canDecode ? " (can decode)" : " (can't decode)"));
System.out.print("As a stream...");
ImageInputStream iis =
ImageIO.createImageInputStream(getDataStream());
if (spi.canDecodeInput(iis) != canDecode) {
throw new RuntimeException("Test failed: wrong decideion " +
"for stream data");
}
System.out.println("OK");
System.out.print("As a file...");
iis = ImageIO.createImageInputStream(getDataFile());
if (spi.canDecodeInput(iis) != canDecode) {
throw new RuntimeException("Test failed: wrong decideion " +
"for file data");
}
System.out.println("OK");
}
示例6: getJPEGTablesReader
import javax.imageio.spi.ImageReaderSpi; //导入依赖的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;
}
示例7: getImageReadersByFormatName
import javax.imageio.spi.ImageReaderSpi; //导入依赖的package包/类
getImageReadersByFormatName(String formatName)
{
if (formatName == null) {
throw new IllegalArgumentException("formatName == null!");
}
Iterator<ImageReaderSpi> iter;
// Ensure category is present
try {
iter = theRegistry.getServiceProviders(ImageReaderSpi.class,
new ContainsFilter(readerFormatNamesMethod,
formatName),
true);
} catch (IllegalArgumentException e) {
return Collections.emptyIterator();
}
return new ImageReaderIterator(iter);
}
示例8: getImageReadersBySuffix
import javax.imageio.spi.ImageReaderSpi; //导入依赖的package包/类
/**
* Returns an {@code Iterator} containing all currently
* registered {@code ImageReader}s that claim to be able to
* decode 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 ImageReader}s.
*
* @exception IllegalArgumentException if {@code fileSuffix}
* is {@code null}.
*
* @see javax.imageio.spi.ImageReaderSpi#getFileSuffixes
*/
public static Iterator<ImageReader>
getImageReadersBySuffix(String fileSuffix)
{
if (fileSuffix == null) {
throw new IllegalArgumentException("fileSuffix == null!");
}
// Ensure category is present
Iterator<ImageReaderSpi> iter;
try {
iter = theRegistry.getServiceProviders(ImageReaderSpi.class,
new ContainsFilter(readerFileSuffixesMethod,
fileSuffix),
true);
} catch (IllegalArgumentException e) {
return Collections.emptyIterator();
}
return new ImageReaderIterator(iter);
}
示例9: getImageReadersByMIMEType
import javax.imageio.spi.ImageReaderSpi; //导入依赖的package包/类
/**
* Returns an {@code Iterator} containing all currently
* registered {@code ImageReader}s that claim to be able to
* decode 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 ImageReader}s.
*
* @exception IllegalArgumentException if {@code MIMEType} is
* {@code null}.
*
* @see javax.imageio.spi.ImageReaderSpi#getMIMETypes
*/
public static Iterator<ImageReader>
getImageReadersByMIMEType(String MIMEType)
{
if (MIMEType == null) {
throw new IllegalArgumentException("MIMEType == null!");
}
// Ensure category is present
Iterator<ImageReaderSpi> iter;
try {
iter = theRegistry.getServiceProviders(ImageReaderSpi.class,
new ContainsFilter(readerMIMETypesMethod,
MIMEType),
true);
} catch (IllegalArgumentException e) {
return Collections.emptyIterator();
}
return new ImageReaderIterator(iter);
}
示例10: getImageTranscoders
import javax.imageio.spi.ImageReaderSpi; //导入依赖的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);
}
示例11: OrderingTest
import javax.imageio.spi.ImageReaderSpi; //导入依赖的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");
}
}
示例12: SpiTest
import javax.imageio.spi.ImageReaderSpi; //导入依赖的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);
}
}
示例13: DeregisterOrderedSpiTest
import javax.imageio.spi.ImageReaderSpi; //导入依赖的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());
}
}
示例14: main
import javax.imageio.spi.ImageReaderSpi; //导入依赖的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();
}
}
示例15: getJPEGTablesReader
import javax.imageio.spi.ImageReaderSpi; //导入依赖的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;
}