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


Java ImageFormats.GIF属性代码示例

本文整理汇总了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, //
    };
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:5,代码来源:GifImageParser.java

示例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);
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:62,代码来源:GifImageParser.java

示例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);
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:62,代码来源:GifImageParser.java

示例4: isGif

private static boolean isGif(final File file) throws IOException,
        ImageReadException {
    final ImageFormat format = Imaging.guessFormat(file);
    return format == ImageFormats.GIF;
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:5,代码来源:GifBaseTest.java


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