Java Code Examples for javax.imageio.spi.ImageWriterSpi#createWriterInstance()

The following examples show how to use javax.imageio.spi.ImageWriterSpi#createWriterInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageIO.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public ImageWriter next() {
    ImageWriterSpi spi = null;
    try {
        spi = iter.next();
        return spi.createWriterInstance();
    } catch (IOException e) {
        // Deregister the spi in this case, but only as a writerSpi
        theRegistry.deregisterServiceProvider(spi, ImageWriterSpi.class);
    }
    return null;
}
 
Example 2
Source File: ImageIO.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public ImageWriter next() {
    ImageWriterSpi spi = null;
    try {
        spi = iter.next();
        return spi.createWriterInstance();
    } catch (IOException e) {
        // Deregister the spi in this case, but only as a writerSpi
        theRegistry.deregisterServiceProvider(spi, ImageWriterSpi.class);
    }
    return null;
}
 
Example 3
Source File: OutputImageTests.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
Context(TestEnvironment env, Result result, int testType) {
    super(env, result);

    String content = (String)env.getModifier(contentList);
    if (content == null) {
        content = CONTENT_BLANK;
    }
    // REMIND: add option for non-opaque images
    image = createBufferedImage(size, size, content, false);

    result.setUnits(size*size);
    result.setUnitName("pixel");

    if (testType == TEST_IMAGEIO || testType == TEST_IMAGEWRITER) {
        ImageWriterSpi writerspi =
            (ImageWriterSpi)env.getModifier(imageioWriteFormatList);
        format = writerspi.getFileSuffixes()[0].toLowerCase();
        if (testType == TEST_IMAGEWRITER) {
            try {
                writer = writerspi.createWriterInstance();
            } catch (IOException e) {
                System.err.println("error creating writer");
                e.printStackTrace();
            }
            if (env.isEnabled(installListenerTog)) {
                writer.addIIOWriteProgressListener(
                    new WriteProgressListener());
            }
        }
        if (format.equals("wbmp")) {
            // REMIND: this is a hack to create an image that the
            //         WBMPImageWriter can handle (a better approach
            //         would involve checking the ImageTypeSpecifier
            //         of the writer's default image param)
            BufferedImage newimg =
                new BufferedImage(size, size,
                                  BufferedImage.TYPE_BYTE_BINARY);
            Graphics g = newimg.createGraphics();
            g.drawImage(image, 0, 0, null);
            g.dispose();
            image = newimg;
        }
    } else { // testType == TEST_JPEGCODEC
        format = "jpeg";
    }

    initOutput();
}
 
Example 4
Source File: OutputImageTests.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
Context(TestEnvironment env, Result result, int testType) {
    super(env, result);

    String content = (String)env.getModifier(contentList);
    if (content == null) {
        content = CONTENT_BLANK;
    }
    // REMIND: add option for non-opaque images
    image = createBufferedImage(size, size, content, false);

    result.setUnits(size*size);
    result.setUnitName("pixel");

    if (testType == TEST_IMAGEIO || testType == TEST_IMAGEWRITER) {
        ImageWriterSpi writerspi =
            (ImageWriterSpi)env.getModifier(imageioWriteFormatList);
        format = writerspi.getFileSuffixes()[0].toLowerCase();
        if (testType == TEST_IMAGEWRITER) {
            try {
                writer = writerspi.createWriterInstance();
            } catch (IOException e) {
                System.err.println("error creating writer");
                e.printStackTrace();
            }
            if (env.isEnabled(installListenerTog)) {
                writer.addIIOWriteProgressListener(
                    new WriteProgressListener());
            }
        }
        if (format.equals("wbmp")) {
            // REMIND: this is a hack to create an image that the
            //         WBMPImageWriter can handle (a better approach
            //         would involve checking the ImageTypeSpecifier
            //         of the writer's default image param)
            BufferedImage newimg =
                new BufferedImage(size, size,
                                  BufferedImage.TYPE_BYTE_BINARY);
            Graphics g = newimg.createGraphics();
            g.drawImage(image, 0, 0, null);
            g.dispose();
            image = newimg;
        }
    } else { // testType == TEST_JPEGCODEC
        format = "jpeg";
    }

    initOutput();
}
 
Example 5
Source File: OutputImageTests.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
Context(TestEnvironment env, Result result, int testType) {
    super(env, result);

    String content = (String)env.getModifier(contentList);
    if (content == null) {
        content = CONTENT_BLANK;
    }
    // REMIND: add option for non-opaque images
    image = createBufferedImage(size, size, content, false);

    result.setUnits(size*size);
    result.setUnitName("pixel");

    if (testType == TEST_IMAGEIO || testType == TEST_IMAGEWRITER) {
        ImageWriterSpi writerspi =
            (ImageWriterSpi)env.getModifier(imageioWriteFormatList);
        format = writerspi.getFileSuffixes()[0].toLowerCase();
        if (testType == TEST_IMAGEWRITER) {
            try {
                writer = writerspi.createWriterInstance();
            } catch (IOException e) {
                System.err.println("error creating writer");
                e.printStackTrace();
            }
            if (env.isEnabled(installListenerTog)) {
                writer.addIIOWriteProgressListener(
                    new WriteProgressListener());
            }
        }
        if (format.equals("wbmp")) {
            // REMIND: this is a hack to create an image that the
            //         WBMPImageWriter can handle (a better approach
            //         would involve checking the ImageTypeSpecifier
            //         of the writer's default image param)
            BufferedImage newimg =
                new BufferedImage(size, size,
                                  BufferedImage.TYPE_BYTE_BINARY);
            Graphics g = newimg.createGraphics();
            g.drawImage(image, 0, 0, null);
            g.dispose();
            image = newimg;
        }
    } else { // testType == TEST_JPEGCODEC
        format = "jpeg";
    }

    initOutput();
}
 
Example 6
Source File: OutputImageTests.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
Context(TestEnvironment env, Result result, int testType) {
    super(env, result);

    String content = (String)env.getModifier(contentList);
    if (content == null) {
        content = CONTENT_BLANK;
    }
    // REMIND: add option for non-opaque images
    image = createBufferedImage(size, size, content, false);

    result.setUnits(size*size);
    result.setUnitName("pixel");

    if (testType == TEST_IMAGEIO || testType == TEST_IMAGEWRITER) {
        ImageWriterSpi writerspi =
            (ImageWriterSpi)env.getModifier(imageioWriteFormatList);
        format = writerspi.getFileSuffixes()[0].toLowerCase();
        if (testType == TEST_IMAGEWRITER) {
            try {
                writer = writerspi.createWriterInstance();
            } catch (IOException e) {
                System.err.println("error creating writer");
                e.printStackTrace();
            }
            if (env.isEnabled(installListenerTog)) {
                writer.addIIOWriteProgressListener(
                    new WriteProgressListener());
            }
        }
        if (format.equals("wbmp")) {
            // REMIND: this is a hack to create an image that the
            //         WBMPImageWriter can handle (a better approach
            //         would involve checking the ImageTypeSpecifier
            //         of the writer's default image param)
            BufferedImage newimg =
                new BufferedImage(size, size,
                                  BufferedImage.TYPE_BYTE_BINARY);
            Graphics g = newimg.createGraphics();
            g.drawImage(image, 0, 0, null);
            g.dispose();
            image = newimg;
        }
    } else { // testType == TEST_JPEGCODEC
        format = "jpeg";
    }

    initOutput();
}
 
Example 7
Source File: OutputImageTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
Context(TestEnvironment env, Result result, int testType) {
    super(env, result);

    String content = (String)env.getModifier(contentList);
    if (content == null) {
        content = CONTENT_BLANK;
    }
    // REMIND: add option for non-opaque images
    image = createBufferedImage(size, size, content, false);

    result.setUnits(size*size);
    result.setUnitName("pixel");

    if (testType == TEST_IMAGEIO || testType == TEST_IMAGEWRITER) {
        ImageWriterSpi writerspi =
            (ImageWriterSpi)env.getModifier(imageioWriteFormatList);
        format = writerspi.getFileSuffixes()[0].toLowerCase();
        if (testType == TEST_IMAGEWRITER) {
            try {
                writer = writerspi.createWriterInstance();
            } catch (IOException e) {
                System.err.println("error creating writer");
                e.printStackTrace();
            }
            if (env.isEnabled(installListenerTog)) {
                writer.addIIOWriteProgressListener(
                    new WriteProgressListener());
            }
        }
        if (format.equals("wbmp")) {
            // REMIND: this is a hack to create an image that the
            //         WBMPImageWriter can handle (a better approach
            //         would involve checking the ImageTypeSpecifier
            //         of the writer's default image param)
            BufferedImage newimg =
                new BufferedImage(size, size,
                                  BufferedImage.TYPE_BYTE_BINARY);
            Graphics g = newimg.createGraphics();
            g.drawImage(image, 0, 0, null);
            g.dispose();
            image = newimg;
        }
    } else { // testType == TEST_JPEGCODEC
        format = "jpeg";
    }

    initOutput();
}
 
Example 8
Source File: OutputImageTests.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
Context(TestEnvironment env, Result result, int testType) {
    super(env, result);

    String content = (String)env.getModifier(contentList);
    if (content == null) {
        content = CONTENT_BLANK;
    }
    // REMIND: add option for non-opaque images
    image = createBufferedImage(size, size, content, false);

    result.setUnits(size*size);
    result.setUnitName("pixel");

    if (testType == TEST_IMAGEIO || testType == TEST_IMAGEWRITER) {
        ImageWriterSpi writerspi =
            (ImageWriterSpi)env.getModifier(imageioWriteFormatList);
        format = writerspi.getFileSuffixes()[0].toLowerCase();
        if (testType == TEST_IMAGEWRITER) {
            try {
                writer = writerspi.createWriterInstance();
            } catch (IOException e) {
                System.err.println("error creating writer");
                e.printStackTrace();
            }
            if (env.isEnabled(installListenerTog)) {
                writer.addIIOWriteProgressListener(
                    new WriteProgressListener());
            }
        }
        if (format.equals("wbmp")) {
            // REMIND: this is a hack to create an image that the
            //         WBMPImageWriter can handle (a better approach
            //         would involve checking the ImageTypeSpecifier
            //         of the writer's default image param)
            BufferedImage newimg =
                new BufferedImage(size, size,
                                  BufferedImage.TYPE_BYTE_BINARY);
            Graphics g = newimg.createGraphics();
            g.drawImage(image, 0, 0, null);
            g.dispose();
            image = newimg;
        }
    } else { // testType == TEST_JPEGCODEC
        format = "jpeg";
    }

    initOutput();
}
 
Example 9
Source File: OutputImageTests.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
Context(TestEnvironment env, Result result, int testType) {
    super(env, result);

    String content = (String)env.getModifier(contentList);
    if (content == null) {
        content = CONTENT_BLANK;
    }
    // REMIND: add option for non-opaque images
    image = createBufferedImage(size, size, content, false);

    result.setUnits(size*size);
    result.setUnitName("pixel");

    if (testType == TEST_IMAGEIO || testType == TEST_IMAGEWRITER) {
        ImageWriterSpi writerspi =
            (ImageWriterSpi)env.getModifier(imageioWriteFormatList);
        format = writerspi.getFileSuffixes()[0].toLowerCase();
        if (testType == TEST_IMAGEWRITER) {
            try {
                writer = writerspi.createWriterInstance();
            } catch (IOException e) {
                System.err.println("error creating writer");
                e.printStackTrace();
            }
            if (env.isEnabled(installListenerTog)) {
                writer.addIIOWriteProgressListener(
                    new WriteProgressListener());
            }
        }
        if (format.equals("wbmp")) {
            // REMIND: this is a hack to create an image that the
            //         WBMPImageWriter can handle (a better approach
            //         would involve checking the ImageTypeSpecifier
            //         of the writer's default image param)
            BufferedImage newimg =
                new BufferedImage(size, size,
                                  BufferedImage.TYPE_BYTE_BINARY);
            Graphics g = newimg.createGraphics();
            g.drawImage(image, 0, 0, null);
            g.dispose();
            image = newimg;
        }
    } else { // testType == TEST_JPEGCODEC
        format = "jpeg";
    }

    initOutput();
}
 
Example 10
Source File: OutputImageTests.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
Context(TestEnvironment env, Result result, int testType) {
    super(env, result);

    String content = (String)env.getModifier(contentList);
    if (content == null) {
        content = CONTENT_BLANK;
    }
    // REMIND: add option for non-opaque images
    image = createBufferedImage(size, size, content, false);

    result.setUnits(size*size);
    result.setUnitName("pixel");

    if (testType == TEST_IMAGEIO || testType == TEST_IMAGEWRITER) {
        ImageWriterSpi writerspi =
            (ImageWriterSpi)env.getModifier(imageioWriteFormatList);
        format = writerspi.getFileSuffixes()[0].toLowerCase();
        if (testType == TEST_IMAGEWRITER) {
            try {
                writer = writerspi.createWriterInstance();
            } catch (IOException e) {
                System.err.println("error creating writer");
                e.printStackTrace();
            }
            if (env.isEnabled(installListenerTog)) {
                writer.addIIOWriteProgressListener(
                    new WriteProgressListener());
            }
        }
        if (format.equals("wbmp")) {
            // REMIND: this is a hack to create an image that the
            //         WBMPImageWriter can handle (a better approach
            //         would involve checking the ImageTypeSpecifier
            //         of the writer's default image param)
            BufferedImage newimg =
                new BufferedImage(size, size,
                                  BufferedImage.TYPE_BYTE_BINARY);
            Graphics g = newimg.createGraphics();
            g.drawImage(image, 0, 0, null);
            g.dispose();
            image = newimg;
        }
    } else { // testType == TEST_JPEGCODEC
        format = "jpeg";
    }

    initOutput();
}
 
Example 11
Source File: OutputImageTests.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
Context(TestEnvironment env, Result result, int testType) {
    super(env, result);

    String content = (String)env.getModifier(contentList);
    if (content == null) {
        content = CONTENT_BLANK;
    }
    // REMIND: add option for non-opaque images
    image = createBufferedImage(size, size, content, false);

    result.setUnits(size*size);
    result.setUnitName("pixel");

    if (testType == TEST_IMAGEIO || testType == TEST_IMAGEWRITER) {
        ImageWriterSpi writerspi =
            (ImageWriterSpi)env.getModifier(imageioWriteFormatList);
        format = writerspi.getFileSuffixes()[0].toLowerCase();
        if (testType == TEST_IMAGEWRITER) {
            try {
                writer = writerspi.createWriterInstance();
            } catch (IOException e) {
                System.err.println("error creating writer");
                e.printStackTrace();
            }
            if (env.isEnabled(installListenerTog)) {
                writer.addIIOWriteProgressListener(
                    new WriteProgressListener());
            }
        }
        if (format.equals("wbmp")) {
            // REMIND: this is a hack to create an image that the
            //         WBMPImageWriter can handle (a better approach
            //         would involve checking the ImageTypeSpecifier
            //         of the writer's default image param)
            BufferedImage newimg =
                new BufferedImage(size, size,
                                  BufferedImage.TYPE_BYTE_BINARY);
            Graphics g = newimg.createGraphics();
            g.drawImage(image, 0, 0, null);
            g.dispose();
            image = newimg;
        }
    } else { // testType == TEST_JPEGCODEC
        format = "jpeg";
    }

    initOutput();
}
 
Example 12
Source File: OutputImageTests.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
Context(TestEnvironment env, Result result, int testType) {
    super(env, result);

    String content = (String)env.getModifier(contentList);
    if (content == null) {
        content = CONTENT_BLANK;
    }
    // REMIND: add option for non-opaque images
    image = createBufferedImage(size, size, content, false);

    result.setUnits(size*size);
    result.setUnitName("pixel");

    if (testType == TEST_IMAGEIO || testType == TEST_IMAGEWRITER) {
        ImageWriterSpi writerspi =
            (ImageWriterSpi)env.getModifier(imageioWriteFormatList);
        format = writerspi.getFileSuffixes()[0].toLowerCase();
        if (testType == TEST_IMAGEWRITER) {
            try {
                writer = writerspi.createWriterInstance();
            } catch (IOException e) {
                System.err.println("error creating writer");
                e.printStackTrace();
            }
            if (env.isEnabled(installListenerTog)) {
                writer.addIIOWriteProgressListener(
                    new WriteProgressListener());
            }
        }
        if (format.equals("wbmp")) {
            // REMIND: this is a hack to create an image that the
            //         WBMPImageWriter can handle (a better approach
            //         would involve checking the ImageTypeSpecifier
            //         of the writer's default image param)
            BufferedImage newimg =
                new BufferedImage(size, size,
                                  BufferedImage.TYPE_BYTE_BINARY);
            Graphics g = newimg.createGraphics();
            g.drawImage(image, 0, 0, null);
            g.dispose();
            image = newimg;
        }
    } else { // testType == TEST_JPEGCODEC
        format = "jpeg";
    }

    initOutput();
}
 
Example 13
Source File: OutputImageTests.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
Context(TestEnvironment env, Result result, int testType) {
    super(env, result);

    String content = (String)env.getModifier(contentList);
    if (content == null) {
        content = CONTENT_BLANK;
    }
    // REMIND: add option for non-opaque images
    image = createBufferedImage(size, size, content, false);

    result.setUnits(size*size);
    result.setUnitName("pixel");

    if (testType == TEST_IMAGEIO || testType == TEST_IMAGEWRITER) {
        ImageWriterSpi writerspi =
            (ImageWriterSpi)env.getModifier(imageioWriteFormatList);
        format = writerspi.getFileSuffixes()[0].toLowerCase();
        if (testType == TEST_IMAGEWRITER) {
            try {
                writer = writerspi.createWriterInstance();
            } catch (IOException e) {
                System.err.println("error creating writer");
                e.printStackTrace();
            }
            if (env.isEnabled(installListenerTog)) {
                writer.addIIOWriteProgressListener(
                    new WriteProgressListener());
            }
        }
        if (format.equals("wbmp")) {
            // REMIND: this is a hack to create an image that the
            //         WBMPImageWriter can handle (a better approach
            //         would involve checking the ImageTypeSpecifier
            //         of the writer's default image param)
            BufferedImage newimg =
                new BufferedImage(size, size,
                                  BufferedImage.TYPE_BYTE_BINARY);
            Graphics g = newimg.createGraphics();
            g.drawImage(image, 0, 0, null);
            g.dispose();
            image = newimg;
        }
    } else { // testType == TEST_JPEGCODEC
        format = "jpeg";
    }

    initOutput();
}
 
Example 14
Source File: OutputImageTests.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
Context(TestEnvironment env, Result result, int testType) {
    super(env, result);

    String content = (String)env.getModifier(contentList);
    if (content == null) {
        content = CONTENT_BLANK;
    }
    // REMIND: add option for non-opaque images
    image = createBufferedImage(size, size, content, false);

    result.setUnits(size*size);
    result.setUnitName("pixel");

    if (testType == TEST_IMAGEIO || testType == TEST_IMAGEWRITER) {
        ImageWriterSpi writerspi =
            (ImageWriterSpi)env.getModifier(imageioWriteFormatList);
        format = writerspi.getFileSuffixes()[0].toLowerCase();
        if (testType == TEST_IMAGEWRITER) {
            try {
                writer = writerspi.createWriterInstance();
            } catch (IOException e) {
                System.err.println("error creating writer");
                e.printStackTrace();
            }
            if (env.isEnabled(installListenerTog)) {
                writer.addIIOWriteProgressListener(
                    new WriteProgressListener());
            }
        }
        if (format.equals("wbmp")) {
            // REMIND: this is a hack to create an image that the
            //         WBMPImageWriter can handle (a better approach
            //         would involve checking the ImageTypeSpecifier
            //         of the writer's default image param)
            BufferedImage newimg =
                new BufferedImage(size, size,
                                  BufferedImage.TYPE_BYTE_BINARY);
            Graphics g = newimg.createGraphics();
            g.drawImage(image, 0, 0, null);
            g.dispose();
            image = newimg;
        }
    } else { // testType == TEST_JPEGCODEC
        format = "jpeg";
    }

    initOutput();
}
 
Example 15
Source File: OutputImageTests.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
Context(TestEnvironment env, Result result, int testType) {
    super(env, result);

    String content = (String)env.getModifier(contentList);
    if (content == null) {
        content = CONTENT_BLANK;
    }
    // REMIND: add option for non-opaque images
    image = createBufferedImage(size, size, content, false);

    result.setUnits(size*size);
    result.setUnitName("pixel");

    if (testType == TEST_IMAGEIO || testType == TEST_IMAGEWRITER) {
        ImageWriterSpi writerspi =
            (ImageWriterSpi)env.getModifier(imageioWriteFormatList);
        format = writerspi.getFileSuffixes()[0].toLowerCase();
        if (testType == TEST_IMAGEWRITER) {
            try {
                writer = writerspi.createWriterInstance();
            } catch (IOException e) {
                System.err.println("error creating writer");
                e.printStackTrace();
            }
            if (env.isEnabled(installListenerTog)) {
                writer.addIIOWriteProgressListener(
                    new WriteProgressListener());
            }
        }
        if (format.equals("wbmp")) {
            // REMIND: this is a hack to create an image that the
            //         WBMPImageWriter can handle (a better approach
            //         would involve checking the ImageTypeSpecifier
            //         of the writer's default image param)
            BufferedImage newimg =
                new BufferedImage(size, size,
                                  BufferedImage.TYPE_BYTE_BINARY);
            Graphics g = newimg.createGraphics();
            g.drawImage(image, 0, 0, null);
            g.dispose();
            image = newimg;
        }
    } else { // testType == TEST_JPEGCODEC
        format = "jpeg";
    }

    initOutput();
}