本文整理汇总了Java中javax.imageio.spi.ImageWriterSpi.getFormatNames方法的典型用法代码示例。如果您正苦于以下问题:Java ImageWriterSpi.getFormatNames方法的具体用法?Java ImageWriterSpi.getFormatNames怎么用?Java ImageWriterSpi.getFormatNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.imageio.spi.ImageWriterSpi
的用法示例。
在下文中一共展示了ImageWriterSpi.getFormatNames方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filter
import javax.imageio.spi.ImageWriterSpi; //导入方法依赖的package包/类
public boolean filter(Object provider)
{
if (provider instanceof ImageWriterSpi)
{
ImageWriterSpi spi = (ImageWriterSpi) provider;
if (spi.canEncodeImage(type))
{
String[] formatNames = spi.getFormatNames();
for (int i = formatNames.length - 1; i >= 0; --i)
if (formatName.equals(formatNames[i]))
return true;
}
}
return false;
}
示例2: getWriterFormatNames
import javax.imageio.spi.ImageWriterSpi; //导入方法依赖的package包/类
/**
* Retrieve all the informal format names supported by the
* collection of registered image writers.
*
* @return an array of format names
*/
public static String[] getWriterFormatNames()
{
try
{
Iterator it =
getRegistry().getServiceProviders(ImageWriterSpi.class, true);
ArrayList result = new ArrayList();
while (it.hasNext())
{
ImageWriterSpi spi = (ImageWriterSpi) it.next();
String[] names = spi.getFormatNames();
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];
}
}
示例3: onRegistration
import javax.imageio.spi.ImageWriterSpi; //导入方法依赖的package包/类
@Override
public void onRegistration(ServiceRegistry registry, Class< ? > category) {
Iterator< ImageWriterSpi > others = registry.getServiceProviders(ImageWriterSpi.class, false);
while (others.hasNext()) {
ImageWriterSpi other = others.next();
if (other != this) {
for (String formatName : other.getFormatNames()) {
if ("png".equals(formatName)) {
registry.setOrdering(ImageWriterSpi.class, this, other);
break;
}
}
}
}
}