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


Java Sanselan.guessFormat方法代码示例

本文整理汇总了Java中org.apache.sanselan.Sanselan.guessFormat方法的典型用法代码示例。如果您正苦于以下问题:Java Sanselan.guessFormat方法的具体用法?Java Sanselan.guessFormat怎么用?Java Sanselan.guessFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.sanselan.Sanselan的用法示例。


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

示例1: canDecodeInput

import org.apache.sanselan.Sanselan; //导入方法依赖的package包/类
public boolean canDecodeInput(Object input) throws IOException {
  if (!(input instanceof ImageInputStream)) {
    return false;
  }
  final ImageInputStream stream = (ImageInputStream)input;
  try {
    final ImageFormat imageFormat = Sanselan.guessFormat(new MyByteSource(stream));
    if (myFormats.contains(imageFormat)) {
      myFormat.set(imageFormat);
      return true;
    }
    return false;
  }
  catch (ImageReadException e) {
    throw new IOException(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:SanselanImageReaderSpi.java

示例2: readIconData

import org.apache.sanselan.Sanselan; //导入方法依赖的package包/类
private IconData readIconData(byte[] iconData, IconInfo fIconInfo)
        throws ImageReadException, IOException
{
    ImageFormat imageFormat = Sanselan.guessFormat(iconData);
    if (imageFormat.equals(ImageFormat.IMAGE_FORMAT_PNG))
    {
        BufferedImage bufferedImage = Sanselan.getBufferedImage(iconData);
        PNGIconData pngIconData = new PNGIconData(fIconInfo, bufferedImage);
        return pngIconData;
    }
    else
    {
        try
        {
            return readBitmapIconData(iconData, fIconInfo);
        }
        catch (ImageWriteException imageWriteException)
        {
            IOException ioe = new IOException();
            ioe.initCause(imageWriteException);
            throw ioe;
        }
    }
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:25,代码来源:IcoImageParser.java

示例3: canRead

import org.apache.sanselan.Sanselan; //导入方法依赖的package包/类
@Override
public boolean canRead(final InputStream stream, final String name) {
	try {
		final ByteSource src = new ByteSourceInputStream(stream, name);

		return Sanselan.guessFormat(src) != ImageFormat.IMAGE_FORMAT_UNKNOWN;
	} catch (final Exception e) {
		return false;
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:11,代码来源:ImageUtilities.java

示例4: rewriteProxiedImage

import org.apache.sanselan.Sanselan; //导入方法依赖的package包/类
/**
 * We don't actually rewrite the image we just ensure that it is in fact a valid
 * and known image type.
 */
private boolean rewriteProxiedImage(HttpRequest request, HttpResponse resp,
    MutableContent content) {
  boolean imageIsSafe = false;
  try {
    String contentType = resp.getHeader("Content-Type");
    if (contentType == null || contentType.toLowerCase().startsWith("image/")) {
      // Unspecified or unknown image mime type.
      try {
        ImageFormat imageFormat = Sanselan
        .guessFormat(new ByteSourceInputStream(resp.getResponse(),
            request.getUri().getPath()));
        if (imageFormat == ImageFormat.IMAGE_FORMAT_UNKNOWN) {
          logger.log(Level.INFO, "Unable to sanitize unknown image type "
              + request.getUri().toString());
          return true;
        }
        imageIsSafe = true;
        // Return false to indicate that no rewriting occurred
        return false;
      } catch (IOException ioe) {
        throw new RuntimeException(ioe);
      } catch (ImageReadException ire) {
        // Unable to read the image so its not safe
        logger.log(Level.INFO, "Unable to detect image type for " +request.getUri().toString() +
            " for sanitized content", ire);
        return true;
      }
    } else {
      return true;
    }
  } finally {
    if (!imageIsSafe) {
      content.setContent("");
    }
  }
}
 
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:41,代码来源:SanitizingRequestRewriter.java


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