Java Code Examples for javax.imageio.ImageIO.getReaderFormatNames()

The following are Jave code examples for showing how to use getReaderFormatNames() of the javax.imageio.ImageIO class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: CacheWriter.java   View Source Code Vote up 5 votes
private String[] findImageFiles (File root) {
    String[] formats = ImageIO.getReaderFormatNames();
    Set set = new HashSet();
    findImageFiles (root, set);
    String[] result = new String[set.size()];
    result = (String[]) set.toArray(result);
    return result;
}
 
Example 2
Project: incubator-netbeans   File: CacheWriter.java   View Source Code Vote up 5 votes
public FormatFilenameFilter () {
    formats = ImageIO.getReaderFormatNames();
    String[] s = new String[formats.length + 2];
    System.arraycopy (formats, 0, s, 2, formats.length);
    s[0] = "GIF";
    s[1] = "gif";
    formats = s;
}
 
Example 3
Project: educational-plugin   File: EduUtils.java   View Source Code Vote up 5 votes
public static boolean isImage(String fileName) {
  final String[] readerFormatNames = ImageIO.getReaderFormatNames();
  for (@NonNls String format : readerFormatNames) {
    final String ext = format.toLowerCase();
    if (fileName.endsWith(ext)) {
      return true;
    }
  }
  return false;
}
 
Example 4
Project: openjdk-jdk10   File: DeregisterAllSpiTest.java   View Source Code Vote up 5 votes
public DeregisterAllSpiTest() throws Exception {
    ImageReaderSpi BMPSpi = new BMPImageReaderSPI();
    IIORegistry.getDefaultInstance().registerServiceProvider(BMPSpi);

    System.out.println("Reader Format Names available in the registry");
    String formatNames[] = ImageIO.getReaderFormatNames();
    if( formatNames == null || formatNames.length <= 0) {
        throw new RuntimeException("No registered ImageReaders!");
    }
    for (int x=0; x < formatNames.length; x++) {
        System.out.println("format "+formatNames[x]);
    }

    IIORegistry.getDefaultInstance().deregisterAll();

    System.out.println("\nReader Format Names after deregistering all SPIs");
    formatNames = ImageIO.getReaderFormatNames();
    if(formatNames.length == 0) {
        System.out.println("No readers available\n");
    } else {
        throw new RuntimeException("Some providers was not deregistered!");
    }

    IIORegistry.getDefaultInstance().registerServiceProvider(BMPSpi);
    System.out.println("Reader Format Names after re-register of BMP Plugin");
    formatNames = ImageIO.getReaderFormatNames();
    if(formatNames.length == 0) {
        throw new RuntimeException("Unable to register new SPI after deregisterAll()!");
    }
}
 
Example 5
Project: openjdk-jdk10   File: IIOPluginTest.java   View Source Code Vote up 5 votes
public static void main(String[] args) {
    SecurityManager sm = System.getSecurityManager();
    System.out.println("Sm is " + sm);

    String formatNames[] = ImageIO.getReaderFormatNames();
    String readerMimeTypes[] = ImageIO.getReaderMIMETypes();

    if (!isPresent(dummyformatNames, formatNames) ||
        !isPresent(dummymimeType, readerMimeTypes)) {
        throw new RuntimeException("No test plugin available!");
    }
}
 
Example 6
Project: openjdk-jdk10   File: GetReaderWriterInfo.java   View Source Code Vote up 5 votes
private static void testGetReaderFormatNames() {
    String[] names = ImageIO.getReaderFormatNames();
    for (String n : names) {
        Iterator<ImageReader> it = ImageIO.getImageReadersByFormatName(n);
        if (!it.hasNext()) {
            throw new RuntimeException("getReaderFormatNames returned " +
                                       "an unknown name: " + n);
        }
    }
}
 
Example 7
Project: geomapapp   File: ImportImage.java   View Source Code Vote up 5 votes
public boolean accept(File pathname) {
	if (pathname.isDirectory()) return true;
	for (String imageType : ImageIO.getReaderFormatNames() ) {
		if (pathname.getName().endsWith(imageType))
			return true;
	}
	return false;
}