當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。