本文整理匯總了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;
}