當前位置: 首頁>>代碼示例>>Java>>正文


Java ImageWriteParam.setProgressiveMode方法代碼示例

本文整理匯總了Java中javax.imageio.ImageWriteParam.setProgressiveMode方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageWriteParam.setProgressiveMode方法的具體用法?Java ImageWriteParam.setProgressiveMode怎麽用?Java ImageWriteParam.setProgressiveMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.imageio.ImageWriteParam的用法示例。


在下文中一共展示了ImageWriteParam.setProgressiveMode方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createAnimatedImage

import javax.imageio.ImageWriteParam; //導入方法依賴的package包/類
public void createAnimatedImage(BufferedImage bi, IIOMetadata metadata,
        ImageWriter writer, File outputFile) {
    try {

        fos = new FileOutputStream(outputFile);
        ImageOutputStream ios = ImageIO.createImageOutputStream(fos);
        System.out.println(ios);
        writer.setOutput(ios);

        ImageWriteParam param = writer.getDefaultWriteParam();
        IIOMetadata streamData = writer.getDefaultStreamMetadata(param);

        writer.prepareWriteSequence(streamData);
        ImageTypeSpecifier specify = new ImageTypeSpecifier(bi);
        IIOMetadata imgData = writer.convertImageMetadata(
                (IIOMetadata) metadata, specify, param);
        GIFImageMetadata gifData = setAnimationProperties(imgData);
        IIOImage iim = new IIOImage(bi, null, gifData);
        param.setProgressiveMode(param.MODE_DISABLED);
        writer.writeToSequence(iim, param);
        writer.endWriteSequence();
        ios.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:OpaquePNGToGIFTest.java

示例2: main

import javax.imageio.ImageWriteParam; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
    Iterator witer = ImageIO.getImageWritersByFormatName("png");
    ImageWriter w = (ImageWriter)witer.next();

    File f = File.createTempFile("WriteProgressive", ".png");
    ImageOutputStream ios = ImageIO.createImageOutputStream(f);
    w.setOutput(ios);

    BufferedImage bi = new BufferedImage(100, 100,
                                         BufferedImage.TYPE_3BYTE_BGR);
    Graphics2D g = bi.createGraphics();
    Random r = new Random(10);
    for (int i = 0; i < 10000; i++) {
        Color c =
            new Color(r.nextInt(256), r.nextInt(256), r.nextInt(256));
        g.setColor(c);
        g.fillRect(r.nextInt(100), r.nextInt(100), 1, 1);
    }

    IIOImage iioimage = new IIOImage(bi, null, null);

    ImageWriteParam param = w.getDefaultWriteParam();
    param.setProgressiveMode(ImageWriteParam.MODE_DEFAULT);

    try {
        w.write(null, iioimage, param);
    } catch (NullPointerException npe) {
        throw new RuntimeException("Got NPE during write!");
    }

    ios.close();

    BufferedImage bi2 = ImageIO.read(f);
    f.delete();

    ImageCompare.compare(bi, bi2);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:38,代碼來源:WriteProgressive.java

示例3: test4441315

import javax.imageio.ImageWriteParam; //導入方法依賴的package包/類
private static void test4441315() {
    ImageWriteParam iwp = new ImageWriteParam4441315();
    try {
        iwp.setProgressiveMode(ImageWriteParam.MODE_EXPLICIT);
        throw new RuntimeException("Failed to get IAE!");
    } catch (IllegalArgumentException e) {
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:ImageWriteParamMisc.java


注:本文中的javax.imageio.ImageWriteParam.setProgressiveMode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。