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


Java ImageFormat类代码示例

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


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


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