本文整理汇总了Java中org.apache.commons.imaging.ImageFormats.GIF属性的典型用法代码示例。如果您正苦于以下问题:Java ImageFormats.GIF属性的具体用法?Java ImageFormats.GIF怎么用?Java ImageFormats.GIF使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.imaging.ImageFormats
的用法示例。
在下文中一共展示了ImageFormats.GIF属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAcceptedTypes
@Override
protected ImageFormat[] getAcceptedTypes() {
return new ImageFormat[] { ImageFormats.GIF, //
};
}
示例2: getImageInfo
@Override
public ImageInfo getImageInfo(final ByteSource byteSource, final Map<String, Object> params)
throws ImageReadException, IOException {
final ImageContents blocks = readFile(byteSource, false);
if (blocks == null) {
throw new ImageReadException("GIF: Couldn't read blocks");
}
final GifHeaderInfo bhi = blocks.gifHeaderInfo;
if (bhi == null) {
throw new ImageReadException("GIF: Couldn't read Header");
}
final ImageDescriptor id = (ImageDescriptor) findBlock(blocks.blocks,
IMAGE_SEPARATOR);
if (id == null) {
throw new ImageReadException("GIF: Couldn't read ImageDescriptor");
}
final 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.
final int height = id.imageHeight;
final int width = id.imageWidth;
final List<String> comments = getComments(blocks.blocks);
final int bitsPerPixel = (bhi.colorResolution + 1);
final ImageFormat format = ImageFormats.GIF;
final String formatName = "GIF Graphics Interchange Format";
final String mimeType = "image/gif";
// we ought to count images, but don't yet.
final int numberOfImages = -1;
final boolean progressive = id.interlaceFlag;
final int physicalWidthDpi = 72;
final float physicalWidthInch = (float) ((double) width / (double) physicalWidthDpi);
final int physicalHeightDpi = 72;
final float physicalHeightInch = (float) ((double) height / (double) physicalHeightDpi);
final String formatDetails = "Gif " + ((char) blocks.gifHeaderInfo.version1)
+ ((char) blocks.gifHeaderInfo.version2)
+ ((char) blocks.gifHeaderInfo.version3);
boolean transparent = false;
if (gce != null && gce.transparency) {
transparent = true;
}
final boolean usesPalette = true;
final int colorType = ImageInfo.COLOR_TYPE_RGB;
final String compressionAlgorithm = ImageInfo.COMPRESSION_ALGORITHM_LZW;
return new ImageInfo(formatDetails, bitsPerPixel, comments,
format, formatName, height, mimeType, numberOfImages,
physicalHeightDpi, physicalHeightInch, physicalWidthDpi,
physicalWidthInch, width, progressive, transparent,
usesPalette, colorType, compressionAlgorithm);
}
示例3: getImageInfo
@Override
public ImageInfo getImageInfo(final ByteSource byteSource, final Map<String, Object> params)
throws ImageReadException, IOException {
final GifImageContents blocks = readFile(byteSource, false);
if (blocks == null) {
throw new ImageReadException("GIF: Couldn't read blocks");
}
final GifHeaderInfo bhi = blocks.gifHeaderInfo;
if (bhi == null) {
throw new ImageReadException("GIF: Couldn't read Header");
}
final ImageDescriptor id = (ImageDescriptor) findBlock(blocks.blocks,
IMAGE_SEPARATOR);
if (id == null) {
throw new ImageReadException("GIF: Couldn't read ImageDescriptor");
}
final 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.
final int height = id.imageHeight;
final int width = id.imageWidth;
final List<String> comments = getComments(blocks.blocks);
final int bitsPerPixel = (bhi.colorResolution + 1);
final ImageFormat format = ImageFormats.GIF;
final String formatName = "GIF Graphics Interchange Format";
final String mimeType = "image/gif";
// we ought to count images, but don't yet.
final int numberOfImages = -1;
final boolean progressive = id.interlaceFlag;
final int physicalWidthDpi = 72;
final float physicalWidthInch = (float) ((double) width / (double) physicalWidthDpi);
final int physicalHeightDpi = 72;
final float physicalHeightInch = (float) ((double) height / (double) physicalHeightDpi);
final String formatDetails = "Gif " + ((char) blocks.gifHeaderInfo.version1)
+ ((char) blocks.gifHeaderInfo.version2)
+ ((char) blocks.gifHeaderInfo.version3);
boolean transparent = false;
if (gce != null && gce.transparency) {
transparent = true;
}
final boolean usesPalette = true;
final ImageInfo.ColorType colorType = ImageInfo.ColorType.RGB;
final ImageInfo.CompressionAlgorithm compressionAlgorithm = ImageInfo.CompressionAlgorithm.LZW;
return new ImageInfo(formatDetails, bitsPerPixel, comments,
format, formatName, height, mimeType, numberOfImages,
physicalHeightDpi, physicalHeightInch, physicalWidthDpi,
physicalWidthInch, width, progressive, transparent,
usesPalette, colorType, compressionAlgorithm);
}
示例4: isGif
private static boolean isGif(final File file) throws IOException,
ImageReadException {
final ImageFormat format = Imaging.guessFormat(file);
return format == ImageFormats.GIF;
}