本文整理汇总了Java中org.apache.sanselan.ImageFormat.IMAGE_FORMAT_GIF属性的典型用法代码示例。如果您正苦于以下问题:Java ImageFormat.IMAGE_FORMAT_GIF属性的具体用法?Java ImageFormat.IMAGE_FORMAT_GIF怎么用?Java ImageFormat.IMAGE_FORMAT_GIF使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.sanselan.ImageFormat
的用法示例。
在下文中一共展示了ImageFormat.IMAGE_FORMAT_GIF属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getImageFormat
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;
}
示例2: toSanselanFormat
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;
}
}
示例3: getOptimizer
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;
}
示例4: readImage
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);
}
}
示例5: getAcceptedTypes
protected ImageFormat[] getAcceptedTypes()
{
return new ImageFormat[] { ImageFormat.IMAGE_FORMAT_GIF, //
};
}
示例6: getImageInfo
public ImageInfo getImageInfo(ByteSource byteSource, Map params)
throws ImageReadException, IOException
{
ImageContents blocks = readFile(byteSource, false);
if (blocks == null)
throw new ImageReadException("GIF: Couldn't read blocks");
GIFHeaderInfo bhi = blocks.gifHeaderInfo;
if (bhi == null)
throw new ImageReadException("GIF: Couldn't read Header");
ImageDescriptor id = (ImageDescriptor) findBlock(blocks.blocks,
IMAGE_SEPARATOR);
if (id == null)
throw new ImageReadException("GIF: Couldn't read ImageDescriptor");
GraphicControlExtension gce = (GraphicControlExtension) findBlock(
blocks.blocks, GRAPHIC_CONTROL_EXTENSION);
// Prefer the size information in the ImageDescriptor; it is more reliable
// than the size information in the header.
int height = id.imageWidth;
int width = id.imageHeight;
ArrayList Comments;
Comments = getComments(blocks.blocks);
int BitsPerPixel = (bhi.colorResolution + 1) * 3;
ImageFormat Format = ImageFormat.IMAGE_FORMAT_GIF;
String FormatName = "GIF Graphics Interchange Format";
String MimeType = "image/gif";
// we ought to count images, but don't yet.
int NumberOfImages = -1;
boolean isProgressive = id.interlaceFlag;
int PhysicalWidthDpi = 72;
float PhysicalWidthInch = (float) ((double) width / (double) PhysicalWidthDpi);
int PhysicalHeightDpi = 72;
float PhysicalHeightInch = (float) ((double) height / (double) PhysicalHeightDpi);
String FormatDetails = "Gif " + ((char) blocks.gifHeaderInfo.version1)
+ ((char) blocks.gifHeaderInfo.version2)
+ ((char) blocks.gifHeaderInfo.version3);
boolean isTransparent = false;
if (gce != null && gce.transparency)
isTransparent = true;
boolean usesPalette = true;
int colorType = ImageInfo.COLOR_TYPE_RGB;
String compressionAlgorithm = ImageInfo.COMPRESSION_ALGORITHM_LZW;
ImageInfo result = new ImageInfo(FormatDetails, BitsPerPixel, Comments,
Format, FormatName, height, MimeType, NumberOfImages,
PhysicalHeightDpi, PhysicalHeightInch, PhysicalWidthDpi,
PhysicalWidthInch, width, isProgressive, isTransparent,
usesPalette, colorType, compressionAlgorithm);
return result;
}