Package com.sun.image.codec.jpeg

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


    g2d.dispose();

    // In JPG konvertieren und ausgeben
    res.setContentType("image/jpeg");
    res.setHeader("Cache-Control", "no-cache");
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
    encoder.encode(bImage);
  }
View Full Code Here


        gfx.fillRect(0, 0, 32, 32);
        gfx.dispose();

        // Write it into a byte array as a JPEG.
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(baos);
        try
        {
          encoder.encode(image);
        }
        catch (Exception e)
        {
          throw new WicketRuntimeException(e);
        }
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

     */
    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

                    (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

    //---create an encoder object for the BufferedImage.
    JPEGEncodeParam jpegParam = JPEGCodec.getDefaultJPEGEncodeParam( sharp );
    jpegParam.setQuality( quality, false );

    JPEGImageEncoder jpeg = JPEGCodec.createJPEGEncoder( outputStream, jpegParam );

    //---encode the BufferedImage.
    jpeg.encode( bufferedImage );

  }
View Full Code Here

     * @param os
     * @throws IOException
     */
    public void prepareImage(BufferedImage img, OutputStream out)
            throws IOException {
        JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);

        int h = img.getHeight();
        int w = img.getWidth();

        if (h > this.maxH || w > this.maxW) {
View Full Code Here

     * @param out
     * @throws IOException
     */
    public void prepareImageThumbnail(BufferedImage img, ServletOutputStream out)
            throws IOException {
        JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);

        int h = img.getHeight();
        int w = img.getWidth();

        int fullH = h;
View Full Code Here

    g.fillRect(0, 0, width, height);
    g.drawImage(small, 0, 0, null);
    g.dispose();

    FileOutputStream out = new FileOutputStream(file);
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
    JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(image);
    param.setQuality(1, true);
    encoder.setJPEGEncodeParam(param);
    encoder.encode(image);
    out.flush();
    out.close();
  }
View Full Code Here

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

                out.flush();
            } catch (ImageFormatException e) {
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.