Package java.awt.image.renderable

Examples of java.awt.image.renderable.ParameterBlock


     * a remote Renderable operation. This method examines the operation's
     * sources recursively and creates them as needed.
     */
    private RenderableRMIServerProxy createProxy(RemoteRenderableOp rop) {

  ParameterBlock oldPB = rop.getParameterBlock();
  ParameterBlock newPB = (ParameterBlock)oldPB.clone();
  Vector sources = oldPB.getSources();
  newPB.removeSources();

  // Create a new RenderableOp on the server
  ImageServer remoteImage = getImageServer(rop.getServerName());
        ImagingListener listener =
                ImageUtil.getImagingListener(rop.getRenderingHints());
  Long opID = new Long(0L);
  try {
      opID = remoteImage.getRemoteID();
      remoteImage.createRenderableOp(opID,
             rop.getOperationName(),
             newPB);
  } catch (RemoteException e){
            String message = JaiI18N.getString("RMIServerProxy8");
            listener.errorOccurred(message,
                                   new RemoteImagingException(message, e),
                                   this, false);
//      throw new RemoteImagingException(ImageUtil.getStackTraceString(e));
  }

  // Now look at the sources of the RenderableOp
  if (sources != null) {

      for (int i = 0; i < sources.size(); i++) {

    Object source = sources.elementAt(i);

    if (source instanceof RemoteRenderedOp) {

        // If source is a RenderedOp on a remote machine, create
        // it on the remote machine.
        RMIServerProxy rmisp =
    (RMIServerProxy)(((RemoteRenderedOp)source).getRendering());

        try {
      if (rmisp.getServerName().equalsIgnoreCase(
              rop.getServerName())) {

          // Both the RenderableOp and this source are on
          // the same server.
          remoteImage.setRenderedSource(opID,
                rmisp.getRMIID(),
                i);
          newPB.setSource(rmisp, i);
      } else {

          // The RenderableOp and this source are on
          // different servers.
          remoteImage.setRenderedSource(
               opID,
               rmisp.getRMIID(),
               rmisp.getServerName(),
               rmisp.getOperationName(),
               i);
          newPB.setSource(rmisp, i);
      }
        } catch (RemoteException e) {
                        String message = JaiI18N.getString("RMIServerProxy6");
                        listener.errorOccurred(message,
                                               new RemoteImagingException(message, e),
                                               this, false);
//      throw new RemoteImagingException(ImageUtil.getStackTraceString(e));
        }

    } else if (source instanceof RenderedOp) {

        // If the source is a local RenderedOp, then the only way
        // to access it from a remote machine is to render it and
        // create a SerializableRenderedImage wrapping the
        // rendering, which is set as the source of the remote op.
        RenderedImage ri = ((RenderedOp)source).getRendering();
        try {
      SerializableRenderedImage sri =
          new SerializableRenderedImage(ri);
      remoteImage.setRenderedSource(opID, sri, i);
      newPB.setSource(sri, i);
        } catch (RemoteException e) {
                        String message = JaiI18N.getString("RMIServerProxy6");
                        listener.errorOccurred(message,
                                               new RemoteImagingException(message, e),
                                               this, false);
//      throw new RemoteImagingException(ImageUtil.getStackTraceString(e));
        }

    } else if (source instanceof RenderedImage) {

        // If the source is a local RenderedImage, then the only
        // way to access it from a remote machine is by wrapping
        // it in SerializableRenderedImage and then setting the
        // SRI as the source.
        RenderedImage ri = (RenderedImage)source;
        try {
      SerializableRenderedImage sri =
          new SerializableRenderedImage(ri);
      remoteImage.setRenderedSource(opID, sri, i);
      newPB.setSource(sri, i);
        } catch (RemoteException e) {
                        String message = JaiI18N.getString("RMIServerProxy6");
                        listener.errorOccurred(message,
                                               new RemoteImagingException(message, e),
                                               this, false);
//      throw new RemoteImagingException(ImageUtil.getStackTraceString(e));
        }

    } else if (source instanceof RemoteRenderableOp) {

        // If the source is a RenderableOp on a remote machine,
        // cause the RenderableOp to be created on the remote
        // machine.
        RenderableRMIServerProxy rrmisp =
      createProxy((RemoteRenderableOp)source);

        try {

      // If the source RenderableOp is on the same server
      // as the RenderableOp that represents the operation
      if (rrmisp.getServerName().equalsIgnoreCase(
              rop.getServerName())) {
          remoteImage.setRenderableSource(opID,
                  rrmisp.getRMIID(),
                  i);
          newPB.setSource(rrmisp, i);
      } else {
          // If the source RenderableOp is on a different
          // server than the RenderableOp that represents
          // the operation
          remoteImage.setRenderableRMIServerProxyAsSource(
                opID,
                rrmisp.getRMIID(),
                rrmisp.getServerName(),
                rrmisp.getOperationName(),
                i);
          newPB.setSource(rrmisp, i);
      }
        } catch (RemoteException e) {
                        String message = JaiI18N.getString("RMIServerProxy6");
                        listener.errorOccurred(message,
                                               new RemoteImagingException(message, e),
                                               this, false);
//      throw new RemoteImagingException(ImageUtil.getStackTraceString(e));
        }

    } else if (source instanceof RenderableImage) {

        // If the source is a local RenderableImage, the only way
        // to access it from a remote machine is to wrap it in
        // a SerializableRenderableImage and then set the SRI as
        // the source on the remote operation.
        RenderableImage ri = (RenderableImage)source;
        try {
      SerializableRenderableImage sri =
          new SerializableRenderableImage(ri);
      remoteImage.setRenderableSource(opID, sri, i);
      newPB.setSource(sri, i);
        } catch (RemoteException e) {
                        String message = JaiI18N.getString("RMIServerProxy6");
                        listener.errorOccurred(message,
                                               new RemoteImagingException(message, e),
                                               this, false);
View Full Code Here


                                RenderingHints hints) {
        /* Get ImageLayout and TileCache from RenderingHints. */
        ImageLayout layout = RIFUtil.getImageLayoutHint(hints);
       

        if (!MediaLibAccessor.isMediaLibCompatible(new ParameterBlock())) {
            return null;
        }

        RenderedImage source = args.getRenderedSource(0);
        EnumeratedParameter scalingType =
            (EnumeratedParameter)args.getObjectParameter(0);
        EnumeratedParameter dataNature =
            (EnumeratedParameter)args.getObjectParameter(1);

        boolean isComplexSource =
            !dataNature.equals(DFTDescriptor.REAL_TO_COMPLEX);
        int numSourceBands = source.getSampleModel().getNumBands();

        // Use the two-dimensional mediaLib DFT if possible: it supports
        // only data which have a single component (real or complex)
        // per pixel and which have dimensions which are equal to a positive
        // power of 2.
        if(((isComplexSource && numSourceBands == 2) ||
            (!isComplexSource && numSourceBands == 1)) &&
           MlibDFTOpImage.isAcceptableSampleModel(source.getSampleModel())) {
            // If necessary, pad the source to ensure that
            // both dimensions are positive powers of 2.
            int sourceWidth = source.getWidth();
            int sourceHeight = source.getHeight();
            if(!MathJAI.isPositivePowerOf2(sourceWidth) ||
               !MathJAI.isPositivePowerOf2(sourceHeight)) {
                ParameterBlock pb = new ParameterBlock();
                pb.addSource(source);
                pb.add(0);
                pb.add(MathJAI.nextPositivePowerOf2(sourceWidth) -
                       sourceWidth);
                pb.add(0);
                pb.add(MathJAI.nextPositivePowerOf2(sourceHeight) -
                       sourceHeight);
                pb.add(BorderExtender.createInstance(BorderExtender.BORDER_ZERO));
                source = JAI.create("border", pb, null);
            }

            return new MlibDFTOpImage(source, hints, layout, dataNature,
                                      true, scalingType);
View Full Code Here

        validate(name, opNode);

        if (name.equalsIgnoreCase("complex")) {
            if(opNode instanceof RenderedOp) {
                RenderedOp op = (RenderedOp)opNode;
                ParameterBlock pb = op.getParameterBlock();
                ImageFunction imFunc = (ImageFunction)pb.getObjectParameter(0);
                return imFunc.isComplex() ? Boolean.TRUE : Boolean.FALSE;
            } else if(opNode instanceof RenderableOp) {
                RenderableOp op = (RenderableOp)opNode;
                ParameterBlock pb = op.getParameterBlock();
                ImageFunction imFunc = (ImageFunction)pb.getObjectParameter(0);
                return imFunc.isComplex() ? Boolean.TRUE : Boolean.FALSE;
            }
        }

        return java.awt.Image.UndefinedProperty;
View Full Code Here

            AffineTransform xform = AffineTransform.getScaleInstance(xMagnification, yMagnification);

            RenderingHints formatHints = new RenderingHints(JAI.KEY_BORDER_EXTENDER, BorderExtender.createInstance(BorderExtender.BORDER_COPY));

            Interpolation interp = Interpolation.getInstance(Interpolation.INTERP_BICUBIC_2);
            ParameterBlock params = new ParameterBlock();
            params.addSource(printImage);
            params.add(xform);
            params.add(interp);
            printImage = JAI.create("Affine", params, formatHints);
        }

        Point location = new Point((int) (settings.getX() * resolution.getWidth() / 72.0),
                                   (int) (settings.getY() * resolution.getHeight() / 72.0));
View Full Code Here

        ScaledImage contourImage = new ScaledImage();

        if (contourWidth > 1) {
            KernelJAI kernel = Functions.getGaussKernel(contourWidth/4);
            ParameterBlock pb = new ParameterBlock();
            pb.addSource(supportImage);
            pb.add(kernel);
            RenderingHints hints = new RenderingHints(JAI.KEY_BORDER_EXTENDER, extender);

            contourImage.image = JAI.create("LCSeparableConvolve", pb, hints);
        } else
            contourImage.image = (PlanarImage) supportImage;
View Full Code Here

                        if (affinedImage == null) {
                            RenderingHints hints = new RenderingHints(JAI.KEY_BORDER_EXTENDER,
                                                                      BorderExtender.createInstance(BorderExtender.BORDER_COPY));
                            // hints.add(JAIContext.noCacheHint);
                            Interpolation interp = Interpolation.getInstance(Interpolation.INTERP_BILINEAR);
                            ParameterBlock params = new ParameterBlock();
                            params.addSource(maskImage);
                            params.add(transform);
                            params.add(interp);
                            maskImage = JAI.create("Affine", params, hints);
                            expandedMasks.put(key, maskImage);
                        } else {
                            maskImage = affinedImage;
                        }
View Full Code Here

                                                                             rgbImage.getWidth() / 2,
                                                                             rgbImage.getHeight() / 2);

                SampleModel sm = colorModel.createCompatibleSampleModel(JAIContext.TILE_WIDTH, JAIContext.TILE_HEIGHT);

                final ParameterBlock pb2 = new ParameterBlock();
                pb2.addSource(rgbImage);
                pb2.add(rotation);
                pb2.add(interp);
                RenderedOp rotated = JAI.create("Affine", pb2, null);

                ImageLayout rotatedLayout = new ImageLayout(rotated.getBounds().x, rotated.getBounds().y,
                                                            rotated.getBounds().width, rotated.getBounds().height,
                                                            rotated.getBounds().x, rotated.getBounds().y,
                                                            JAIContext.TILE_WIDTH, JAIContext.TILE_HEIGHT,
                                                            sm, colorModel);

                final RenderingHints hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, rotatedLayout);

                rotated = JAI.create("Affine", pb2, hints);

                int width = dcRaw.getImageWidth();
                int height = dcRaw.getImageHeight();

                rgbImage = Functions.crop(rotated,
                                          rotated.getMinX() + (rotated.getWidth() - width) / 2 + 2,
                                          rotated.getMinY() + (rotated.getHeight() - height) / 2 + 2,
                                          width - 4, height - 4, JAIContext.noCacheHint);
            } else if (dcRaw.getMake().equals("NIKON") && dcRaw.getModel().equals("D1X")) {
//                rgbImage = Functions.crop(rgbImage,
//                                          rgbImage.getMinX() + 2,
//                                          rgbImage.getMinY() + 2,
//                                          rgbImage.getWidth() - 6,
//                                          rgbImage.getHeight() - 6, null);
                rgbImage = new TiledImage(rgbImage, true).getSubImage(
                        rgbImage.getMinX() + 5,
                        rgbImage.getMinY() + 5,
                        rgbImage.getWidth() - 10,
                        rgbImage.getHeight() - 10);

                final RenderingHints hints = new RenderingHints(JAI.KEY_BORDER_EXTENDER,
                                                                BorderExtender.createInstance(BorderExtender.BORDER_COPY));
                final Interpolation interp =
                        Interpolation.getInstance(Interpolation.INTERP_BILINEAR);

                SampleModel sm = colorModel.createCompatibleSampleModel(JAIContext.TILE_WIDTH, JAIContext.TILE_HEIGHT);

                ImageLayout newLayout = new ImageLayout(0, 0, 3 * rgbImage.getWidth() / 4, 3 * rgbImage.getHeight() / 2,
                                                        0, 0, JAIContext.TILE_WIDTH, JAIContext.TILE_HEIGHT,
                                                        sm, colorModel);

                hints.add(new RenderingHints(JAI.KEY_IMAGE_LAYOUT, newLayout));

                final ParameterBlock pb2 = new ParameterBlock();
                pb2.addSource(rgbImage);
                pb2.add(AffineTransform.getScaleInstance(3.0 / 4.0, 3.0 / 2.0));
                pb2.add(interp);
                rgbImage = JAI.create("Affine", pb2, hints);
            } else {
                rgbImage = Functions.crop(rgbImage,
                                          rgbImage.getMinX() + 5,
                                          rgbImage.getMinY() + 5,
View Full Code Here

        }

        Vector parameters = pb.getParameters();
        Vector paramEval = evaluateParameters(parameters);
        return paramEval == parameters ?
            pb : new ParameterBlock(pb.getSources(), paramEval);
    }
View Full Code Here

*/
public class Functions {
    public static boolean DEBUG = false;

    static public RenderedOp crop(RenderedImage image, float x, float y, float width, float height, RenderingHints hints) {
        ParameterBlock pb = new ParameterBlock();
        pb.addSource(image);
        pb.add(x);
        pb.add(y);
        pb.add(width);
        pb.add(height);
        return JAI.create("Crop", pb, hints);
    }
View Full Code Here

                scaleDown = processor.process(scaleDown);
        } else
            scaleDown = processor != null ? processor.process(image) : image;

        KernelJAI kernel = Functions.getGaussKernel(newRadius);
        ParameterBlock pb = new ParameterBlock();
        pb.addSource(scaleDown);
        pb.add(kernel);
        RenderedOp blur = JAI.create("LCSeparableConvolve", pb, extenderHints);

        if (rescale != 1) {
            pb = new ParameterBlock();
            pb.addSource(blur);
            pb.add(AffineTransform.getScaleInstance(image.getWidth() / (double) blur.getWidth(),
                                                    image.getHeight() / (double) blur.getHeight()));
            pb.add(interp);
            RenderingHints sourceLayoutHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT,
                                                                  new ImageLayout(0, 0,
                                                                                  JAIContext.TILE_WIDTH,
                                                                                  JAIContext.TILE_HEIGHT,
                                                                                  null, null));
View Full Code Here

TOP

Related Classes of java.awt.image.renderable.ParameterBlock

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.