• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ImageFormat类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.sanselan.ImageFormat的典型用法代码示例。如果您正苦于以下问题:Java ImageFormat类的具体用法?Java ImageFormat怎么用?Java ImageFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ImageFormat类属于org.apache.sanselan包,在下文中一共展示了ImageFormat类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: canDecodeInput

import org.apache.sanselan.ImageFormat; //导入依赖的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: getImageFormat

import org.apache.sanselan.ImageFormat; //导入依赖的package包/类
private static ImageFormat getImageFormat(String ext){
    ImageFormat format = ImageFormat.IMAGE_FORMAT_PNG;
    switch(ext.toLowerCase()){
        case "gif":
            format = ImageFormat.IMAGE_FORMAT_GIF;
            break;
        case "jpeg":
        case "jpg":
            format = ImageFormat.IMAGE_FORMAT_JPEG;
            break;
        case "bmp":
            format = ImageFormat.IMAGE_FORMAT_BMP;
            break;
        case "tif":
        case "tiff":
            format = ImageFormat.IMAGE_FORMAT_TIFF;
            break;
    }
    return format;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:21,代码来源:ImageUtil.java


示例3: toSanselanFormat

import org.apache.sanselan.ImageFormat; //导入依赖的package包/类
public static ImageFormat toSanselanFormat(ImageInfo.Format format) {
	switch (format) {
	case BMP:
		return ImageFormat.IMAGE_FORMAT_BMP;
	case GIF: return ImageFormat.IMAGE_FORMAT_GIF;
	case ICO: return ImageFormat.IMAGE_FORMAT_ICO;
	case IFF: return null;
	case JPEG: return ImageFormat.IMAGE_FORMAT_JPEG;
	case PBM: return ImageFormat.IMAGE_FORMAT_PBM;
	case PPM: return ImageFormat.IMAGE_FORMAT_PPM;
	case PGM: return ImageFormat.IMAGE_FORMAT_PGM;
	case PCX: return null;
	case PNG: return ImageFormat.IMAGE_FORMAT_PNG;
	case PSD: return ImageFormat.IMAGE_FORMAT_PSD;
	case RAS: return null;
	case TIFF: return ImageFormat.IMAGE_FORMAT_TIFF;
	case WEBP: return null;
	default: return null;
	}
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:21,代码来源:ServiceImageIO.java


示例4: readIconData

import org.apache.sanselan.ImageFormat; //导入依赖的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


示例5: PngImageInfo

import org.apache.sanselan.ImageFormat; //导入依赖的package包/类
public PngImageInfo(String formatDetails, int bitsPerPixel,
        ArrayList comments, ImageFormat format, String formatName,
        int height, String mimeType, int numberOfImages,
        int physicalHeightDpi, float physicalHeightInch,
        int physicalWidthDpi, float physicalWidthInch, int width,
        boolean isProgressive, boolean isTransparent, boolean usesPalette,
        int colorType, String compressionAlgorithm, final List textChunks)
{
    super(formatDetails, bitsPerPixel, comments, format, formatName,
            height, mimeType, numberOfImages, physicalHeightDpi,
            physicalHeightInch, physicalWidthDpi, physicalWidthInch, width,
            isProgressive, isTransparent, usesPalette, colorType,
            compressionAlgorithm);

    this.textChunks = textChunks;
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:17,代码来源:PngImageInfo.java


示例6: getOptimizer

import org.apache.sanselan.ImageFormat; //导入依赖的package包/类
private HttpResponse getOptimizer(HttpResponse response, ImageFormat imageFormat,
    BufferedImage image) throws IOException {

  if (imageFormat == ImageFormat.IMAGE_FORMAT_GIF) {
    // Detecting the existence of the NETSCAPE2.0 extension by string comparison
    // is not exactly clean but is good enough to determine if a GIF is animated
    // Remove once Sanselan returns image count
    if (!response.getResponseAsString().contains("NETSCAPE2.0")) {
      response = new GIFOptimizer(config, response).rewrite(image);
    }
  } else if (imageFormat == ImageFormat.IMAGE_FORMAT_PNG) {
    response = new PNGOptimizer(config, response).rewrite(image);
  } else if (imageFormat == ImageFormat.IMAGE_FORMAT_JPEG) {
    response = new JPEGOptimizer(config, response).rewrite(image);
  } else if (imageFormat == ImageFormat.IMAGE_FORMAT_BMP) {
    response = new BMPOptimizer(config, response).rewrite(image);
  }
  return response;
}
 
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:20,代码来源:BasicImageRewriter.java


示例7: SanselanImageReaderSpi

import org.apache.sanselan.ImageFormat; //导入依赖的package包/类
public SanselanImageReaderSpi() {
  super();
  vendorName = "JetBrains, s.r.o.";
  version = "1.0";

  // todo standard GIF/BMP formats can be optionally skipped as well
  // JPEG is skipped due to Exception: Sanselan cannot read or write JPEG images. (JpegImageParser.java:92)
  // tiff reader seems to be broken
  // PNG reader has bugs with well-compressed PNG images, use standard one instead
  myFormats = new ArrayList<ImageFormat>(Arrays.asList(ImageFormat.getAllFormats()));
  myFormats.removeAll(Arrays.asList(ImageFormat.IMAGE_FORMAT_UNKNOWN,
                                       ImageFormat.IMAGE_FORMAT_JPEG,
                                       ImageFormat.IMAGE_FORMAT_TIFF,
                                       ImageFormat.IMAGE_FORMAT_PNG));

  names = new String[myFormats.size() * 2];
  suffixes = new String[myFormats.size()];
  MIMETypes = new String[myFormats.size()];
  pluginClassName = MyImageReader.class.getName();
  inputTypes = new Class[] {ImageInputStream.class};
  for (int i = 0, allFormatsLength = myFormats.size(); i < allFormatsLength; i++) {
    final ImageFormat format = myFormats.get(i);
    names[2 * i] = format.extension.toLowerCase();
    names[2 * i + 1] = format.extension.toUpperCase();
    suffixes[i] = names[2 * i];
    MIMETypes[i] = "image/" + names[2 * i];
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:SanselanImageReaderSpi.java


示例8: imageSave

import org.apache.sanselan.ImageFormat; //导入依赖的package包/类
/**
 * Save image into a file
 * @param data RGB(A) data array
 * @param fileName Output image file name
 * @throws IOException 
 * @throws org.apache.sanselan.ImageWriteException 
 */
public static void imageSave(Array data, String fileName) throws IOException, ImageWriteException{
    String extension = fileName.substring(fileName.lastIndexOf('.') + 1);
    BufferedImage image = createImage(data);  
    ImageFormat format = getImageFormat(extension);
    if (format == ImageFormat.IMAGE_FORMAT_JPEG){
        ImageIO.write(image, extension, new File(fileName));
    } else {
        Sanselan.writeImage(image, new File(fileName), format, null);       
    }
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:18,代码来源:ImageUtil.java


示例9: imageWriteExample

import org.apache.sanselan.ImageFormat; //导入依赖的package包/类
public static byte[] imageWriteExample(final File file)
		throws ImageReadException, ImageWriteException, IOException {
	// read image
	final BufferedImage image = Sanselan.getBufferedImage(file);
	final ImageFormat format = ImageFormat.IMAGE_FORMAT_TIFF;
	final Map<String, Object> params = new HashMap<String, Object>();

	// set optional parameters if you like
	params.put(SanselanConstants.PARAM_KEY_COMPRESSION, new Integer(
			TiffConstants.TIFF_COMPRESSION_UNCOMPRESSED));

	final byte[] bytes = Sanselan.writeImageToBytes(image, format, params);
	return bytes;
}
 
开发者ID:shaolinwu,项目名称:uimaster,代码行数:15,代码来源:ImageUtil.java


示例10: canRead

import org.apache.sanselan.ImageFormat; //导入依赖的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


示例11: write

import org.apache.sanselan.ImageFormat; //导入依赖的package包/类
@Override
  public void write(IIOMetadata iioMetadata, IIOImage iioImage, ImageWriteParam param)
          throws IOException {

      if (ios == null) {
          throw new IllegalArgumentException(Messages.getString("imageio.7F"));
      }

      RenderedImage img = null;
      if (!iioImage.hasRaster()) {
          img = iioImage.getRenderedImage();
          if (img instanceof BufferedImage) {
              sourceRaster = ((BufferedImage) img).getRaster();
          } else {
              sourceRaster = img.getData();
          }
      } else {
          sourceRaster = iioImage.getRaster();
      }

      Map params = new HashMap();
      try {
	Sanselan.writeImage((BufferedImage)img,
			(OutputStream)ios,
			ImageFormat.IMAGE_FORMAT_JPEG,
			params);
} catch (ImageWriteException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}
  }
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:32,代码来源:JPEGImageWriter.java


示例12: write

import org.apache.sanselan.ImageFormat; //导入依赖的package包/类
@Override
public byte[] write(BufferedImage image, ImageInfo.Format format) throws IOException {
	ImageFormat imageFormat = toSanselanFormat(format);
	if (imageFormat == null) {
		throw new IOException("no sanselan support for writing " + format + " format");
	}
	try {
		return Sanselan.writeImageToBytes(image, imageFormat, new TreeMap());
	} catch (ImageWriteException e) {
		throw new IOException(e);
	}
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:13,代码来源:ServiceImageIO.java


示例13: getImageInfo

import org.apache.sanselan.ImageFormat; //导入依赖的package包/类
public ImageInfo getImageInfo(ByteSource byteSource, Map params)
		throws ImageReadException, IOException
{
	// make copy of params; we'll clear keys as we consume them.
	params = (params == null) ? new HashMap() : new HashMap(params);
	
	boolean verbose = ParamMap.getParamBoolean(params, PARAM_KEY_VERBOSE,
			false);

	if (params.containsKey(PARAM_KEY_VERBOSE))
		params.remove(PARAM_KEY_VERBOSE);

	if (params.size() > 0)
	{
		Object firstKey = params.keySet().iterator().next();
		throw new ImageReadException("Unknown parameter: " + firstKey);
	}

	IcnsContents contents = readImage(byteSource);
	ArrayList images = IcnsDecoder.decodeAllImages(contents.icnsElements);
	if (images.isEmpty())
		throw new ImageReadException("No icons in ICNS file");
	BufferedImage image0 = (BufferedImage) images.get(0);
	return new ImageInfo("Icns", 32, new ArrayList(), ImageFormat.IMAGE_FORMAT_ICNS,
			"ICNS Apple Icon Image", image0.getHeight(), "image/x-icns", images.size(),
			0, 0, 0, 0, image0.getWidth(), false, true, false, ImageInfo.COLOR_TYPE_RGB,
			ImageInfo.COMPRESSION_ALGORITHM_UNKNOWN);
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:29,代码来源:IcnsImageParser.java


示例14: getAcceptedTypes

import org.apache.sanselan.ImageFormat; //导入依赖的package包/类
protected ImageFormat[] getAcceptedTypes()
{
    return new ImageFormat[] { ImageFormat.IMAGE_FORMAT_PBM, //
            ImageFormat.IMAGE_FORMAT_PGM, //
            ImageFormat.IMAGE_FORMAT_PPM, //
            ImageFormat.IMAGE_FORMAT_PNM, };
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:8,代码来源:PNMImageParser.java


示例15: getImageInfo

import org.apache.sanselan.ImageFormat; //导入依赖的package包/类
public ImageInfo getImageInfo(ByteSource byteSource, Map params)
        throws ImageReadException, IOException
{
    FileInfo info = readHeader(byteSource);

    if (info == null)
        throw new ImageReadException("PNM: Couldn't read Header");

    ArrayList Comments = new ArrayList();

    int BitsPerPixel = info.getBitDepth() * info.getNumComponents();
    ImageFormat Format = info.getImageType();
    String FormatName = info.getImageTypeDescription();
    String MimeType = info.getMIMEType();
    int NumberOfImages = 1;
    boolean isProgressive = false;

    // boolean isProgressive = (fPNGChunkIHDR.InterlaceMethod != 0);
    //
    int PhysicalWidthDpi = 72;
    float PhysicalWidthInch = (float) ((double) info.width / (double) PhysicalWidthDpi);
    int PhysicalHeightDpi = 72;
    float PhysicalHeightInch = (float) ((double) info.height / (double) PhysicalHeightDpi);

    String FormatDetails = info.getImageTypeDescription();

    boolean isTransparent = false;
    boolean usesPalette = false;

    int ColorType = info.getColorType();
    String compressionAlgorithm = ImageInfo.COMPRESSION_ALGORITHM_NONE;

    ImageInfo result = new ImageInfo(FormatDetails, BitsPerPixel, Comments,
            Format, FormatName, info.height, MimeType, NumberOfImages,
            PhysicalHeightDpi, PhysicalHeightInch, PhysicalWidthDpi,
            PhysicalWidthInch, info.width, isProgressive, isTransparent,
            usesPalette, ColorType, compressionAlgorithm);

    return result;
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:41,代码来源:PNMImageParser.java


示例16: getRandomImage

import org.apache.sanselan.ImageFormat; //导入依赖的package包/类
private byte[] getRandomImage() throws IOException, ImageWriteException {
    int width = randomIntBetween(100, 1000);
    int height = randomIntBetween(100, 1000);
    BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    for (int j = 0; j < width; j ++) {
        for (int k = 0; k < height; k ++) {
            image.setRGB(j, k, randomInt(512));
        }
    }
    ImageFormat format = ImageFormat.IMAGE_FORMAT_TIFF;
    byte[] bytes = Sanselan.writeImageToBytes(image, format, Maps.newHashMap());
    return bytes;
}
 
开发者ID:kzwang,项目名称:elasticsearch-image,代码行数:14,代码来源:ImageIntegrationTests.java


示例17: process

import org.apache.sanselan.ImageFormat; //导入依赖的package包/类
@Override
protected boolean process(ChannelHandlerContext context, HttpRequest request, QueryStringDecoder urlDecoder) throws IOException, ImageWriteException {
  HttpRequestHandler connectedHandler = (HttpRequestHandler)context.getAttachment();
  if (connectedHandler != null) {
    if (connectedHandler.isSupported(request) && connectedHandler.process(urlDecoder, request, context)) {
      return true;
    }
    // prev cached connectedHandler is not suitable for this request, so, let's find it again
    context.setAttachment(null);
  }

  if (urlDecoder.getPath().equals("/favicon.ico")) {
    Icon icon = IconLoader.findIcon(ApplicationInfoEx.getInstanceEx().getSmallIconUrl());
    if (icon != null) {
      BufferedImage image = UIUtil.createImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
      icon.paintIcon(null, image.getGraphics(), 0, 0);
      byte[] icoBytes = Sanselan.writeImageToBytes(image, ImageFormat.IMAGE_FORMAT_ICO, null);
      Responses.send(icoBytes, FileResponses.createResponse(urlDecoder.getPath()), request, context);
      return true;
    }
  }

  for (HttpRequestHandler handler : BuiltInServerManager.EP_NAME.getExtensions()) {
    try {
      if (handler.isSupported(request) && handler.process(urlDecoder, request, context)) {
        if (context.getAttachment() == null) {
          context.setAttachment(handler);
        }
        return true;
      }
    }
    catch (Throwable e) {
      BuiltInServer.LOG.error(e);
    }
  }
  return false;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:38,代码来源:DelegatingHttpRequestHandler.java


示例18: readImage

import org.apache.sanselan.ImageFormat; //导入依赖的package包/类
protected BufferedImage readImage(ImageFormat imageFormat, HttpResponse response)
    throws ImageReadException, IOException{
  if (imageFormat == ImageFormat.IMAGE_FORMAT_GIF) {
    return readGif(response);
  } else if (imageFormat == ImageFormat.IMAGE_FORMAT_PNG) {
    return readPng(response);
  } else if (imageFormat == ImageFormat.IMAGE_FORMAT_JPEG) {
    return readJpeg(response);
  } else if (imageFormat == ImageFormat.IMAGE_FORMAT_BMP) {
    return readBmp(response);
  } else {
    throw new ImageReadException("Unsupported format " + imageFormat.name);
  }
}
 
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:15,代码来源:BasicImageRewriter.java


示例19: rewriteProxiedImage

import org.apache.sanselan.ImageFormat; //导入依赖的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


示例20: getAcceptedTypes

import org.apache.sanselan.ImageFormat; //导入依赖的package包/类
protected ImageFormat[] getAcceptedTypes()
{
	return new ImageFormat[] { ImageFormat.IMAGE_FORMAT_JPEG //
	};
}
 
开发者ID:fulcrumapp,项目名称:sanselan-android,代码行数:6,代码来源:JpegImageParser.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SimpleFacets类代码示例发布时间:2022-05-22
下一篇:
Java DERBoolean类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap