Package com.sun.image.codec.jpeg

Examples of com.sun.image.codec.jpeg.JPEGImageDecoder


  public static BufferedImage readJPEGImage(String filename)
  {
    try {
      InputStream imageIn = new FileInputStream(new File(filename));
      // 得到输入的编码器,将文件流进行jpg格式编码
      JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(imageIn);
      // 得到编码后的图片对象
      BufferedImage sourceImage = decoder.decodeAsBufferedImage();
     
      return sourceImage;
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (ImageFormatException e) {
View Full Code Here


                                           int minY) {
        // Create an InputStream from the compressed data array.
        ByteArrayInputStream jpegStream = new ByteArrayInputStream(data);

        // Create a decoder.
        JPEGImageDecoder decoder = decodeParam == null ?
            JPEGCodec.createJPEGDecoder(jpegStream) :
            JPEGCodec.createJPEGDecoder(jpegStream,
                                        decodeParam);

        // Decode the compressed data into a Raster.
        Raster jpegRaster;
        try {
            jpegRaster = colorConvert ?
                decoder.decodeAsBufferedImage().getWritableTile(0, 0) :
                decoder.decodeAsRaster();
        } catch (IOException ioe) {
            throw new RuntimeException("TIFFImage13");
        }

        // Translate the decoded Raster to the specified location and return.
View Full Code Here

                if(dir.isTagPresent(TIFF_JPEG_TABLES)) {
                    TIFFField jpegTableField = dir.getField(TIFF_JPEG_TABLES);
                    byte[] jpegTable = jpegTableField.getAsBytes();
                    ByteArrayInputStream tableStream =
                        new ByteArrayInputStream(jpegTable);
                    JPEGImageDecoder decoder =
                        JPEGCodec.createJPEGDecoder(tableStream);
                    decoder.decodeAsRaster();
                    decodeParam = decoder.getJPEGDecodeParam();
                }

                break;
            default:
                throw new RuntimeException("TIFFImage10");
View Full Code Here

        Thread t = new Thread() {
                public void run() {
                    Filter filt;
                    try{
                        JPEGImageDecoder decoder;
                        decoder = JPEGCodec.createJPEGDecoder(is);
                        BufferedImage image;
                        try {
                            image   = decoder.decodeAsBufferedImage();
                        } catch (TruncatedFileException tfe) {
                            image = tfe.getBufferedImage();
                            // Should probably draw some indication
                            // that this is a partial image....
                            if (image == null)
View Full Code Here

        int interleave = (subtype >> 0) & 0xff;
        int chroma = (subtype >> 8) & 0xff;
        int conversion = (subtype >> 16) & 0xff;
        int table = (subtype >> 24) & 0xff;

        JPEGImageDecoder dec;
        JPEGDecodeParam param = null;

        if (table != 0) {
            InputStream tableStream =
                new ByteArrayInputStream(JPEGTable[table]);
            dec = JPEGCodec.createJPEGDecoder(tableStream);
            Raster junk = dec.decodeAsRaster();
            param = dec.getJPEGDecodeParam();
        }

        subimageDataStream.seek(getTileOffset(tileIndex));
        if (param != null) {
            dec = JPEGCodec.createJPEGDecoder(subimageDataStream, param);
        } else {
            dec = JPEGCodec.createJPEGDecoder(subimageDataStream);
        }
        Raster ras = dec.decodeAsRaster().createTranslatedChild(tx, ty);

        DataBufferByte dataBuffer = (DataBufferByte)ras.getDataBuffer();
        byte[] data = dataBuffer.getData();

        int subimageColorType = subimageColor[resolution][0] >> 16;
View Full Code Here

/*     */     public Object readFrom(InputStream in)
/*     */     {
/* 224 */       Object converted = null;
/*     */       try
/*     */       {
/* 227 */         JPEGImageDecoder dec = JPEGCodec.createJPEGDecoder(in);
/* 228 */         BufferedImage bim = dec.decodeAsBufferedImage();
/* 229 */         converted = bim;
/*     */       }
/*     */       catch (Exception e)
/*     */       {
/*     */       }
View Full Code Here

   {
      public Object readFrom(InputStream in) {
         Object converted = null;
         try
         {
            JPEGImageDecoder dec = JPEGCodec.createJPEGDecoder(in);
            BufferedImage bim = dec.decodeAsBufferedImage();
            converted = bim;
         }
         catch (Exception e)
         {
            // ignore
View Full Code Here

        Thread t = new Thread() {
                public void run() {
                    Filter filt;
                    try{
                        JPEGImageDecoder decoder;
                        decoder = JPEGCodec.createJPEGDecoder(is);
                        BufferedImage image;
                        image   = decoder.decodeAsBufferedImage();
                        CachableRed cr;
                        cr = GraphicsUtil.wrap(image);
                        cr = new Any2sRGBRed(cr);
                        filt = new RedRable(cr);
                    } catch (IOException ioe) {
View Full Code Here

    {
        boolean emptyBackground = true;
        if (config.isUseImageBackground() && background != null)
        {
            ByteArrayInputStream is = new ByteArrayInputStream(background);
            JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(is);
            try
            {
                this.image = decoder.decodeAsBufferedImage();
                this.width = image.getWidth();
                this.height = image.getHeight();
                emptyBackground = false;
            }
            catch (Exception e)
View Full Code Here

    private final ShortSample2D[][] signal_;

    public JPEGImageReader(final String resource) throws FileNotFoundException,
            IOException {
        super();
        JPEGImageDecoder decoder = JPEGCodec
                .createJPEGDecoder(new BufferedInputStream(
                        JPEGImageReader.class.getResourceAsStream(resource)));
        bufferedImage_ = decoder.decodeAsBufferedImage();
        width_ = bufferedImage_.getWidth();
        height_ = bufferedImage_.getHeight();
        signal_ = getAsSample2DSignal();

    }
View Full Code Here

TOP

Related Classes of com.sun.image.codec.jpeg.JPEGImageDecoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.