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


Java Imaging.guessFormat方法代码示例

本文整理汇总了Java中org.apache.commons.imaging.Imaging.guessFormat方法的典型用法代码示例。如果您正苦于以下问题:Java Imaging.guessFormat方法的具体用法?Java Imaging.guessFormat怎么用?Java Imaging.guessFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.imaging.Imaging的用法示例。


在下文中一共展示了Imaging.guessFormat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readIconData

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
private IconData readIconData(final byte[] iconData, final IconInfo fIconInfo)
        throws ImageReadException, IOException {
    final ImageFormat imageFormat = Imaging.guessFormat(iconData);
    if (imageFormat.equals(ImageFormats.PNG)) {
        final BufferedImage bufferedImage = Imaging.getBufferedImage(iconData);
        return new PNGIconData(fIconInfo, bufferedImage);
    }
    return readBitmapIconData(iconData, fIconInfo);
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:10,代码来源:IcoImageParser.java

示例2: checkGuessFormat

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
public void checkGuessFormat(final File imageFile, final byte[] imageFileBytes)
        throws Exception {
    // check guessFormat()
    final ImageFormat imageFormatFile = Imaging.guessFormat(imageFile);
    assertNotNull(imageFormatFile);
    assertTrue(imageFormatFile != ImageFormats.UNKNOWN);
    // Debug.debug("imageFormatFile", imageFormatFile);

    final ImageFormat imageFormatBytes = Imaging.guessFormat(imageFileBytes);
    assertNotNull(imageFormatBytes);
    assertTrue(imageFormatBytes != ImageFormats.UNKNOWN);
    // Debug.debug("imageFormatBytes", imageFormatBytes);

    assertTrue(imageFormatBytes == imageFormatFile);
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:16,代码来源:ByteSourceImageTest.java

示例3: isDcx

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
private static boolean isDcx(final File file) throws IOException,
        ImageReadException {
    final ImageFormat format = Imaging.guessFormat(file);
    return format == ImageFormats.DCX;
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:6,代码来源:DcxBaseTest.java

示例4: isIcns

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
private static boolean isIcns(final File file) throws IOException,
        ImageReadException {
    final ImageFormat format = Imaging.guessFormat(file);
    return format == ImageFormats.ICNS;
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:6,代码来源:IcnsBaseTest.java

示例5: isJpeg

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
protected static boolean isJpeg(final File file) throws IOException,
        ImageReadException {
    final ImageFormat format = Imaging.guessFormat(file);
    return format == ImageFormats.JPEG;
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:6,代码来源:JpegBaseTest.java

示例6: isGif

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
private static boolean isGif(final File file) throws IOException,
        ImageReadException {
    final ImageFormat format = Imaging.guessFormat(file);
    return format == ImageFormats.GIF;
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:6,代码来源:GifBaseTest.java

示例7: isBmp

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
private static boolean isBmp(final File file) throws IOException,
        ImageReadException {
    final ImageFormat format = Imaging.guessFormat(file);
    return format == ImageFormats.BMP;
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:6,代码来源:BmpBaseTest.java

示例8: test

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    final List<File> images = getTestImages();
    for (final File imageFile : images) {

        if (imageFile.getName().toLowerCase().endsWith(".png")
                && isInvalidPNGTestFile(imageFile)) {
            continue;
        }

        Debug.debug("imageFile", imageFile);
        Debug.debug();

        final ImageFormat imageFormat = Imaging.guessFormat(imageFile);

        String xmpXml = Imaging.getXmpXml(imageFile);
        if (null == xmpXml
                && imageFormat.equals(ImageFormats.GIF)) {
            xmpXml = "temporary test until I can locate a GIF with XMP in the wild.";
        }
        if (null == xmpXml) {
            continue;
        }

        assertNotNull(xmpXml);

        if (imageFormat.equals(ImageFormats.PNG)) { /*
                                                                 * do
                                                                 * nothing
                                                                 */
        } else if (imageFormat.equals(ImageFormats.TIFF)) { /*
                                                                         * do
                                                                         * nothing
                                                                         */
        } else if (imageFormat.equals(ImageFormats.GIF)) { /*
                                                                        * do
                                                                        * nothing
                                                                        */
        } else {
            continue;
        }

        final File tempFile = this.createTempFile(imageFile.getName() + ".", "."
                + imageFormat.getExtension());
        final BufferedImage image = Imaging.getBufferedImage(imageFile);

        // ----

        final Map<String, Object> params = new HashMap<>();
        params.put(ImagingConstants.PARAM_KEY_XMP_XML, xmpXml);
        Imaging.writeImage(image, tempFile, imageFormat, params);

        final String xmpXmlOut = Imaging.getXmpXml(tempFile);

        assertNotNull(xmpXmlOut);

        assertEquals(xmpXmlOut, xmpXml);

        // Debug.debug("xmpXmlOut", xmpXmlOut.length());
        // Debug.debug("xmpXml", xmpXml);
        // Debug.debug();
    }
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:64,代码来源:XmpUpdateTest.java

示例9: isPsd

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
private static boolean isPsd(final File file) throws IOException,
        ImageReadException {
    final ImageFormat format = Imaging.guessFormat(file);
    return format == ImageFormats.PSD;
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:6,代码来源:PsdBaseTest.java

示例10: isRgbe

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
private static boolean isRgbe(final File file) throws IOException,
        ImageReadException {
    final ImageFormat format = Imaging.guessFormat(file);
    return format == ImageFormats.RGBE;
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:6,代码来源:RgbeBaseTest.java

示例11: isPam

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
private static boolean isPam(final File file) throws IOException,
        ImageReadException {
    final ImageFormat format = Imaging.guessFormat(file);
    return format == ImageFormats.PAM;
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:6,代码来源:PamBaseTest.java

示例12: isTiff

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
private static boolean isTiff(final File file) throws IOException,
        ImageReadException {
    final ImageFormat format = Imaging.guessFormat(file);
    return format == ImageFormats.TIFF;
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:6,代码来源:TiffBaseTest.java

示例13: isPng

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
private static boolean isPng(final File file) throws IOException,
        ImageReadException {
    final ImageFormat format = Imaging.guessFormat(file);
    return format == ImageFormats.PNG;
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:6,代码来源:PngBaseTest.java

示例14: SampleUsage

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@SuppressWarnings("unused")
public SampleUsage() {

    try {
        // <b>Code won't work unless these variables are properly
        // initialized.
        // Imaging works equally well with File, byte array or InputStream
        // inputs.</b>
        final BufferedImage someImage = null;
        final byte someBytes[] = null;
        final File someFile = null;
        final InputStream someInputStream = null;
        final OutputStream someOutputStream = null;

        // <b>The Imaging class provides a simple interface to the library.
        // </b>

        // <b>how to read an image: </b>
        final byte imageBytes[] = someBytes;
        final BufferedImage image_1 = Imaging.getBufferedImage(imageBytes);

        // <b>methods of Imaging usually accept files, byte arrays, or
        // inputstreams as arguments. </b>
        final BufferedImage image_2 = Imaging.getBufferedImage(imageBytes);
        final File file = someFile;
        final BufferedImage image_3 = Imaging.getBufferedImage(file);
        final InputStream is = someInputStream;
        final BufferedImage image_4 = Imaging.getBufferedImage(is);

        // <b>Write an image. </b>
        final BufferedImage image = someImage;
        final File dst = someFile;
        final ImageFormat format = ImageFormats.PNG;
        final Map<String, Object> optionalParams = new HashMap<>();
        Imaging.writeImage(image, dst, format, optionalParams);

        final OutputStream os = someOutputStream;
        Imaging.writeImage(image, os, format, optionalParams);

        // <b>get the image's embedded ICC Profile, if it has one. </b>
        final byte iccProfileBytes[] = Imaging.getICCProfileBytes(imageBytes);

        final ICC_Profile iccProfile = Imaging.getICCProfile(imageBytes);

        // <b>get the image's width and height. </b>
        final Dimension d = Imaging.getImageSize(imageBytes);

        // <b>get all of the image's info (ie. bits per pixel, size,
        // transparency, etc.) </b>
        final ImageInfo imageInfo = Imaging.getImageInfo(imageBytes);

        if (imageInfo.getColorType() == ImageInfo.ColorType.GRAYSCALE) {
            System.out.println("Grayscale image.");
        }
        if (imageInfo.getHeight() > 1000) {
            System.out.println("Large image.");
        }

        // <b>try to guess the image's format. </b>
        final ImageFormat imageFormat = Imaging.guessFormat(imageBytes);
        imageFormat.equals(ImageFormats.PNG);

        // <b>get all metadata stored in EXIF format (ie. from JPEG or
        // TIFF). </b>
        final ImageMetadata metadata = Imaging.getMetadata(imageBytes);

        // <b>print a dump of information about an image to stdout. </b>
        Imaging.dumpImageFile(imageBytes);

        // <b>get a summary of format errors. </b>
        final FormatCompliance formatCompliance = Imaging.getFormatCompliance(imageBytes);

    } catch (final Exception e) {

    }
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:77,代码来源:SampleUsage.java

示例15: test

import org.apache.commons.imaging.Imaging; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    Debug.debug("imageFile", imageFile);
    assertNotNull(imageFile);

    final byte imageFileBytes[] = FileUtils.readFileToByteArray(imageFile);
    assertNotNull(imageFileBytes);
    assertTrue(imageFileBytes.length == imageFile.length());

    if (imageFile.getName().toLowerCase().endsWith(".ico")
            || imageFile.getName().toLowerCase().endsWith(".tga")
            || imageFile.getName().toLowerCase().endsWith(".jb2")
            || imageFile.getName().toLowerCase().endsWith(".pcx")
            || imageFile.getName().toLowerCase().endsWith(".dcx")
            || imageFile.getName().toLowerCase().endsWith(".psd")
            || imageFile.getName().toLowerCase().endsWith(".wbmp")
            || imageFile.getName().toLowerCase().endsWith(".xbm")
            || imageFile.getName().toLowerCase().endsWith(".xpm")) {
        // these formats can't be parsed without a filename hint.
        // they have ambiguous "magic number" signatures.
        return;
    }

    checkGuessFormat(imageFile, imageFileBytes);

    if (imageFile.getName().toLowerCase().endsWith(".png")
            && imageFile.getParentFile().getName().equalsIgnoreCase("pngsuite")
            && imageFile.getName().toLowerCase().startsWith("x")) {
        return;
    }

    checkGetICCProfileBytes(imageFile, imageFileBytes);

    if (!imageFile.getParentFile().getName().toLowerCase().equals("@broken")) {
        checkGetImageInfo(imageFile, imageFileBytes);
    }

    checkGetImageSize(imageFile, imageFileBytes);

    final ImageFormat imageFormat = Imaging.guessFormat(imageFile);
    if (ImageFormats.JPEG != imageFormat
            && ImageFormats.UNKNOWN != imageFormat) {
        checkGetBufferedImage(imageFile, imageFileBytes);
    }
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:46,代码来源:ByteSourceImageTest.java


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