Package com.sun.image.codec.jpeg

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


            // null image (length 0)
            if (jpegData.length == 0)
                return null;

            ByteArrayInputStream bais = new ByteArrayInputStream(jpegData);
            JPEGImageDecoder jid = JPEGCodec.createJPEGDecoder(bais);

            BufferedImage bi = jid.decodeAsBufferedImage();
            int height = bi.getHeight();
            int width = bi.getWidth();
            int[] pixels = bi.getRGB(0, 0, width, height, null, 0, width);
            return pixels;
        } catch (IOException ioe) {
View Full Code Here


     
      byte[] payload = out.toByteArray();
     
     
      ByteArrayInputStream in = new ByteArrayInputStream(payload);
      JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(in);
      //JPEGDecodeParam decpar = decoder.getJPEGDecodeParam();
     
      BufferedImage decodedImage = decoder.decodeAsBufferedImage();
     
      log.debug("decodedImage W: "+decodedImage.getWidth());
      log.debug("decodedImage H: "+decodedImage.getHeight());
     
      //log.debug("decodedImage "+);
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

  finally {
            ois.close();
  }

  ByteArrayInputStream bais = new ByteArrayInputStream(data);
        JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(bais);

        Raster ras = decoder.decodeAsRaster()
      .createTranslatedChild(location.x, location.y);
  extractParameters(decoder.getJPEGDecodeParam(),
        ras.getSampleModel().getNumBands());

  // set the original sample model to the decoded raster
  if (sm != null) {
      int minX = ras.getMinX();
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 = null;
        try {
            jpegRaster = colorConvert ?
                decoder.decodeAsBufferedImage().getWritableTile(0, 0) :
                decoder.decodeAsRaster();
        } catch (IOException ioe) {
            String message = JaiI18N.getString("TIFFImage13");
            ImagingListenerProxy.errorOccurred(message,
                                   new ImagingException(message, ioe),
                                   TIFFImage.class, false);
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(JaiI18N.getString("TIFFImage10"));
View Full Code Here

        if(tableIndex != 0) {
            decodeParam = getJPEGDecodeParam(tableIndex);
        }

        ByteArrayInputStream byteStream = new ByteArrayInputStream(data);
        JPEGImageDecoder decoder = decodeParam == null ?
            JPEGCodec.createJPEGDecoder(byteStream) :
            JPEGCodec.createJPEGDecoder(byteStream, decodeParam);

        Raster raster = null;
        try {
            raster = decoder.decodeAsRaster().createTranslatedChild(tx, ty);
        } catch(Exception e) {

            ImagingListener listener =
                ImageUtil.getImagingListener(renderHints);
            listener.errorOccurred(JaiI18N.getString("IIPResolutionOpImage3"),
View Full Code Here

            while((label = getLabel(stream)) != null) {
                if(label.startsWith("comp-group")) {
                    byte[] table = getDataAsByteArray(stream);
                    ByteArrayInputStream tableStream =
                        new ByteArrayInputStream(table);
                    JPEGImageDecoder decoder =
                        JPEGCodec.createJPEGDecoder(tableStream);
                    try {
                        // This call is necessary.
                        decoder.decodeAsRaster();
                    } catch(Exception e) {
                        // Ignore.
                    }
                    decodeParam = decoder.getJPEGDecodeParam();
                } else {
                    checkError(label, stream, true);
                }
            }
View Full Code Here

             * UPDATE (SM):
             * This appears to be fixed on JDK 1.4
             */

            try {
                JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(inputStream);
                Raster original = decoder.decodeAsRaster();
                JPEGDecodeParam decodeParam = decoder.getJPEGDecodeParam();
                double ow = (double) decodeParam.getWidth();
                double oh = (double) decodeParam.getHeight();
                AffineTransformOp filter = new AffineTransformOp(getTransform(ow, oh, width, height), AffineTransformOp.TYPE_BILINEAR);
                WritableRaster scaled = filter.createCompatibleDestRaster(original);
                filter.filter(original, scaled);
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

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.