Package com.sun.image.codec.jpeg

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


        } else {
            //TODO Is this the right way?
            bi = GraphicsUtil.makeLinearBufferedImage(
                    image.getWidth(), image.getHeight(), false);
        }
        JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
        if (params != null) {
            JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
            if (params.getJPEGQuality() != null) {
                param.setQuality(
                        params.getJPEGQuality().floatValue(),
                        params.getJPEGForceBaseline().booleanValue());
            }
            encoder.encode(bi, param);
        } else {
            encoder.encode(bi);
        }
    }
View Full Code Here


                if (!handleJVMBug()) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug( "No need to handle JVM bug" );
                    }
                    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
                    encoder.encode(scaled);
                } else {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug( "Need to handle JVM bug" );
                    }
                    ByteArrayOutputStream bstream = new ByteArrayOutputStream();
                    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bstream);
                    encoder.encode(scaled);
                    out.write(bstream.toByteArray());
                }

                out.flush();
            } catch (ImageFormatException e) {
View Full Code Here

            handler.error(new TranscoderException(
                Messages.formatMessage("jpeg.unspecifiedQuality", null)));
            quality = 1f;
        }
        try {
            JPEGImageEncoder jpegEncoder = JPEGCodec.createJPEGEncoder(ostream);
            JPEGEncodeParam params = JPEGCodec.getDefaultJPEGEncodeParam(img);
            params.setQuality(quality, true);
            jpegEncoder.encode(img, params);
        } catch (IOException ex) {
            throw new TranscoderException(ex);
        }
    }
View Full Code Here

        } else {
            //TODO Is this the right way?
            bi = GraphicsUtil.makeLinearBufferedImage(
                    image.getWidth(), image.getHeight(), false);
        }
        JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
        if (params != null) {
            JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
            if (params.getJPEGQuality() != null) {
                param.setQuality(
                        params.getJPEGQuality().floatValue(),
                        params.getJPEGForceBaseline().booleanValue());
            }
            encoder.encode(bi, param);
        } else {
            encoder.encode(bi);
        }
    }
View Full Code Here

        } else {
            //TODO Is this the right way?
            bi = GraphicsUtil.makeLinearBufferedImage(
                    image.getWidth(), image.getHeight(), false);
        }
        JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
        if (params != null) {
            JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
            if (params.getJPEGQuality() != null) {
                param.setQuality(
                        params.getJPEGQuality().floatValue(),
                        params.getJPEGForceBaseline().booleanValue());
            }
            encoder.encode(bi, param);
        } else {
            encoder.encode(bi);
        }
    }
View Full Code Here

     */
    public void encodeImage(BufferedImage buf, File imageFile)
        throws SVGGraphics2DIOException {
        try{
            OutputStream os = new FileOutputStream(imageFile);
            JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(os);
            JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(buf);
            param.setQuality(1, false);
            encoder.encode(buf, param);
            os.flush();
            os.close();
        } catch(IOException e) {
            throw new SVGGraphics2DIOException(ERR_WRITE+imageFile.getName());
        }
View Full Code Here

    /**
     * Uses JPEG encoding.
     */
    public void encodeImage(BufferedImage buf, OutputStream os)
        throws IOException {
        JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(os);
        JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(buf);
        param.setQuality(1, false);
        encoder.encode(buf, param);
    }
View Full Code Here

                    (Messages.formatMessage("jpeg.unspecifiedQuality", null));
                handler.error(te);
                quality = .75f;
            }

            JPEGImageEncoder jpegEncoder;
            JPEGEncodeParam params;
            jpegEncoder = JPEGCodec.createJPEGEncoder(ostream);
            params      = JPEGCodec.getDefaultJPEGEncodeParam(img);
            params.setQuality(quality, true);

            float PixSzMM = userAgent.getPixelUnitToMillimeter();
            int PixSzInch = (int)(25.4/PixSzMM+0.5);
            params.setDensityUnit(JPEGEncodeParam.DENSITY_UNIT_DOTS_INCH);
            params.setXDensity(PixSzInch);
            params.setYDensity(PixSzInch);
            jpegEncoder.encode(img, params);
            ostream.flush();
        } catch (IOException ex) {
            throw new TranscoderException(ex);
        }
    }
View Full Code Here

        File tempdir = new File (Constants.TEMP_DIR);
        if (!tempdir.exists()){
          tempdir.mkdirs();
        }
        out = new BufferedOutputStream(new FileOutputStream(Constants.TEMP_DIR + imageName));
        JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
        JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(thumbImage);
        quality = Math.max(0, Math.min(quality, 100));
        param.setQuality((float) quality / 100.0f, false);
        encoder.setJPEGEncodeParam(param);
        encoder.encode(thumbImage);

      } catch (FileNotFoundException e) {
        System.out.println("FileNotFoundException " + e.getMessage());
      } catch (ImageFormatException e) {
        System.out.println("ImageFormatException " + e.getMessage());
View Full Code Here

        } else {
            //TODO Is this the right way?
            bi = GraphicsUtil.makeLinearBufferedImage(
                    image.getWidth(), image.getHeight(), false);
        }
        JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
        if (params != null) {
            JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
            if (params.getJPEGQuality() != null) {
                param.setQuality(
                        params.getJPEGQuality().floatValue(),
                        params.getJPEGForceBaseline().booleanValue());
            }
            encoder.encode(bi, param);
        } else {
            encoder.encode(bi);
        }
    }
View Full Code Here

TOP

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

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.