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


Java CMYKJPEGImageReader类代码示例

本文整理汇总了Java中org.monte.media.jpeg.CMYKJPEGImageReader的典型用法代码示例。如果您正苦于以下问题:Java CMYKJPEGImageReader类的具体用法?Java CMYKJPEGImageReader怎么用?Java CMYKJPEGImageReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: read

import org.monte.media.jpeg.CMYKJPEGImageReader; //导入依赖的package包/类
@Override
public BufferedImage read(int imageIndex, ImageReadParam param)
        throws IOException {
    readHeader();

    ImageInputStream in = (ImageInputStream) getInput();
    SubImageInputStream sin = new SubImageInputStream(in, imageOffsets[imageIndex], imageLengths[imageIndex]);
    sin.seek(0);

    ImageReader ir = new CMYKJPEGImageReader(getOriginatingProvider());
    ir.setInput(sin);

    BufferedImage img = ir.read(0);
    ir.dispose();
    return img;
}
 
开发者ID:pojosontheweb,项目名称:selenium-utils,代码行数:17,代码来源:MPOImageReader.java

示例2: read

import org.monte.media.jpeg.CMYKJPEGImageReader; //导入依赖的package包/类
public static BufferedImage read(InputStream input) throws IOException {
    BufferedImage in;
    byte[] data = Helper.readStream(input);
    try (ImageInputStream iis = ImageIO.createImageInputStream(new ByteArrayInputStream(data))) {
        CMYKJPEGImageReader r = new CMYKJPEGImageReader(new CMYKJPEGImageReaderSpi());
        r.setInput(iis);
        in = r.read(0);
    } catch (IOException | ArrayIndexOutOfBoundsException ex) {
        try {
            in = ImageIO.read(ImageIO.createImageInputStream(new ByteArrayInputStream(data)));
        } catch (IOException ex1) {
            return null;
        }
    }

    int type = in.getType();
    if (type != BufferedImage.TYPE_INT_ARGB_PRE && type != BufferedImage.TYPE_INT_RGB) {
        // convert to ARGB
        int width = in.getWidth();
        int height = in.getHeight();
        int[] imgData = in.getRGB(0, 0, width, height, null, 0, width);
        BufferedImage newImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB_PRE);
        newImage.getRaster().setDataElements(0, 0, width, height, imgData);
        return newImage;
    }

    return in;
}
 
开发者ID:jindrapetrik,项目名称:jpexs-decompiler,代码行数:29,代码来源:ImageHelper.java

示例3: setFile

import org.monte.media.jpeg.CMYKJPEGImageReader; //导入依赖的package包/类
/**
 * This method asynchronously loads an image file.
 */
public void setFile(final File file) {
    imageLabel.setIcon(null);
    imageLabel.setText("Loading image...");

    new SwingWorker<BufferedImage, BufferedImage>() {
        @Override
        protected BufferedImage doInBackground() throws Exception {
            // Loads a JPEG image using the Java ImageIO API
            // ---------------------------------------------

            // The ImageIO API may provide many ImageReaders which
            // claim to be able to read the file. We try them all
            // out until we succeed.

            BufferedImage img = null;
            ImageInputStream iis = new FileImageInputStream(file);
            try {
                CMYKJPEGImageReader r = new CMYKJPEGImageReader(new CMYKJPEGImageReaderSpi());
                r.setInput(iis);
                img = r.read(0);
            } finally {
                iis.close();
            }
            return img;
        }

        @Override
        protected void done() {
            // Show the image or apologize in case of failure
            // -----------------------------------------------
            try {
                BufferedImage image = get();
                if (image == null) {
                    imageLabel.setText("Sorry. Couldn't load image.");
                    infoLabel.setText(null);
                } else {
                    imageLabel.setIcon(new ImageIcon(image));
                    imageLabel.setText(null);
                    infoLabel.setText("<html>Image Dimension: "+image.getWidth()+" x "+image.getHeight()
                    +"<br>Color Model: "+image.getColorModel()
                    +"<br>has alpha: "+image.getColorModel().hasAlpha()+" is alpha premultiplied:"+image.getColorModel().isAlphaPremultiplied()
                            );
                }
            } catch (Exception ex) {
                imageLabel.setText("Sorry. Couldn't load image.");
                ex.printStackTrace();
            }
            super.done();
        }
    }.execute();
}
 
开发者ID:sebkur,项目名称:montemedia,代码行数:55,代码来源:Main.java


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