Package javax.media.jai

Examples of javax.media.jai.RenderedOp


          ParameterBlock pbMosaic = new ParameterBlock();
          pbMosaic.add(MosaicDescriptor.MOSAIC_TYPE_OVERLAY);
          for (RenderedImage renderedImage : images) {
            pbMosaic.addSource(renderedImage);
          }
          RenderedOp mosaic = JAI.create("mosaic", pbMosaic, new RenderingHints(JAI.KEY_IMAGE_LAYOUT,
              imageLayout));
          try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            log.debug("rendering to buffer...");
            ImageIO.write(mosaic, "png", baos);
View Full Code Here


            ParameterBlock pbMosaic = new ParameterBlock();
            pbMosaic.add(MosaicDescriptor.MOSAIC_TYPE_OVERLAY);
            for (RenderedImage renderedImage : images) {
              pbMosaic.addSource(renderedImage);
            }
            RenderedOp mosaic = JAI.create("mosaic", pbMosaic, new RenderingHints(JAI.KEY_IMAGE_LAYOUT,
                imageLayout));
            try {
              ByteArrayOutputStream baos = new ByteArrayOutputStream();
              log.debug("rendering to buffer...");
              ImageIO.write(mosaic, "png", baos);
View Full Code Here

    BufferedImage retVal = null;
    RenderedImage ri = JAI.create("awtImage", inputImage);
    ParameterBlock pb = new ParameterBlock();
    pb.addSource(ri);
    TransposeType rotOp = null;
    RenderedOp op = null;
    if (degrees == 90) {
      rotOp = TransposeDescriptor.ROTATE_90;
    } else if (degrees == 180) {
      rotOp = TransposeDescriptor.ROTATE_180;
    } else if (degrees == 270) {
      rotOp = TransposeDescriptor.ROTATE_270;
    }
    if (rotOp != null) {
      // use Transpose operation
      pb.add(rotOp);
      op = JAI.create("transpose", pb);
    } else {
      // setup "normal" rotation
      pb.add(ri.getWidth() / 2.0f);
      pb.add(ri.getHeight() / 2.0f);
      pb.add((float) Math.toRadians(degrees));
      pb.add(new InterpolationNearest());
      op = JAI.create("Rotate", pb, null);
    }
    PlanarImage myPlanar = op.createInstance();
    retVal = myPlanar.getAsBufferedImage();
    return retVal;
  }
View Full Code Here

             * BufferedInputStream inputStream = this.m_imageReader.getInputStream();
             * inputStream.reset();
             */
            com.sun.media.jai.codec.FileCacheSeekableStream seekableInput =
                new FileCacheSeekableStream(inputStream);
            RenderedOp imageOp = JAI.create("stream", seekableInput);

            this.m_height = imageOp.getHeight();
            this.m_width = imageOp.getWidth();

            ColorModel cm = imageOp.getColorModel();
            this.m_bitsPerPixel = 8;
            // this.m_bitsPerPixel = cm.getPixelSize();
            this.m_colorSpace = new ColorSpace(ColorSpace.DEVICE_RGB);

            BufferedImage imageData = imageOp.getAsBufferedImage();
            int[] tmpMap = imageData.getRGB(0, 0, this.m_width,
                                            this.m_height, null, 0,
                                            this.m_width);

            if (cm.hasAlpha()) {
View Full Code Here

     */
    public static byte[] resizeImageAsJPG(byte[] pImageData, int pMaxWidth, int pMaxHeight) throws IOException {
    InputStream imageInputStream = new ByteArrayInputStream(pImageData);
    // read in the original image from an input stream
    SeekableStream seekableImageStream = SeekableStream.wrapInputStream(imageInputStream, true);
    RenderedOp originalImage = JAI.create(JAI_STREAM_ACTION, seekableImageStream);
    ((OpImage) originalImage.getRendering()).setTileCache(null);
    int origImageWidth = originalImage.getWidth();
    int origImageHeight = originalImage.getHeight();
    // now resize the image
    double scale = 1.0, scale1 = 1.0, scale2 = 1.0;
    if (pMaxWidth > 0 && origImageWidth > pMaxWidth) {
        scale1 = (double) pMaxWidth / origImageWidth;
    }
    if (pMaxHeight > 0 && origImageHeight > pMaxHeight){
      scale2 = (double) pMaxHeight / origImageHeight;
    }
    scale = scale1 > scale2 ? scale2 : scale1;
    ParameterBlock paramBlock = new ParameterBlock();
    paramBlock.addSource(originalImage); // The source image
    paramBlock.add(scale); // The xScale
    paramBlock.add(scale); // The yScale
    paramBlock.add(0.0); // The x translation
    paramBlock.add(0.0); // The y translation
 
    RenderingHints qualityHints = new RenderingHints(RenderingHints.KEY_RENDERING,
      RenderingHints.VALUE_RENDER_QUALITY);
 
    RenderedOp resizedImage = JAI.create(JAI_SUBSAMPLE_AVERAGE_ACTION, paramBlock, qualityHints);
 
    // lastly, write the newly-resized image to an output stream, in a specific encoding
    ByteArrayOutputStream encoderOutputStream = new ByteArrayOutputStream();
    JAI.create(JAI_ENCODE_ACTION, resizedImage, encoderOutputStream, JAI_ENCODE_FORMAT_JPEG, null);
    // Export to Byte Array
View Full Code Here

           
            /*
             * Perform format conversion
             * Operator is not created if no conversion is necessary
             */
            RenderedOp formcov = null;
            if((bilEncoding.equals("application/bil32"))&&(dtype!=DataBuffer.TYPE_FLOAT))            {
              formcov = FormatDescriptor.create(image,DataBuffer.TYPE_FLOAT ,null);
            }
            if((bilEncoding.equals("application/bil16"))&&(dtype!=DataBuffer.TYPE_SHORT))            {
              formcov = FormatDescriptor.create(image,DataBuffer.TYPE_SHORT ,null);
View Full Code Here

    }

    public void testClipLargerDisabledGreyGIF8Bit()
        throws Throwable, IOException, MalformedURLException {

        RenderedOp image = doClip(OutputImageRules.GREYSCALEGIF8, 700, "left");
        assertEquals("Image is not greyscale", true,
                     TestUtilities.isGreyscale(image));
    }
View Full Code Here

    }

    public void testClipLargerDisabledGreyJPEG8Bit()
        throws Throwable, IOException, MalformedURLException {

        RenderedOp image = doClip(OutputImageRules.GREYSCALEJPEG8, 700, "left");
        assertEquals("Image is not greyscale", true,
                     TestUtilities.isGreyscale(image));
    }
View Full Code Here

    }

    public void testClipLargerDisabledGreyPNG4Bit()
        throws Throwable, IOException, MalformedURLException {

        RenderedOp image = doClip(OutputImageRules.GRAYSCALEPNG4, 700, "left");
        assertEquals("Image is not greyscale", true,
                     TestUtilities.isGreyscale(image));
    }
View Full Code Here

    }

    public void testClipLargerDisabledGreyGIF4Bit()
        throws Throwable, IOException, MalformedURLException {

        RenderedOp image = doClip(OutputImageRules.GREYSCALEGIF4, 700, "left");
        assertEquals("Image is not greyscale4", true,
                     TestUtilities.isGreyscale4(image));
    }
View Full Code Here

TOP

Related Classes of javax.media.jai.RenderedOp

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.