Package javax.media.jai

Examples of javax.media.jai.CollectionImage


     * @param images the images to composit
     * @return
     */
    public Collection removeAlphaByCompositing(Collection images, int size) {

        CollectionImage result = new GenericCollectionImage();
        Iterator it = images.iterator();
        RenderedOp previous = (RenderedOp) it.next();
        // this removes the alpha channel if there is one
        previous = ImageUtils.applyAlphaChannel(previous, size);
        // previous.removeProperty("JAI.ImageMetadata");
        result.add(previous);
        int i = 0;
        RenderedOp overlay = previous;
        while(it.hasNext()) {

            RenderedOp next = (RenderedOp) it.next();
            // extract the alpha channel on its own
            RenderedOp alphaNext = ImageUtils.extractAlphaChannel(next);
            // extract the non-aplha channels
            next = ImageUtils.removeAlphaChannel(next);

            // previous will be treated as opaque as no alpha is supplied.
            RenderedOp composite = CompositeDescriptor.create(next, overlay, alphaNext, null, Boolean.FALSE, CompositeDescriptor.NO_DESTINATION_ALPHA, null);

            composite.removeProperty("JAI.ImageMetadata");
            result.add(composite);

            // composite image with have dimensions/origin the same as the
            // "next" image. Therefore we overlay on the "previous image to
            // get our next
            overlay = OverlayDescriptor.create(overlay, composite, null);
View Full Code Here


                                  RenderingHints oldHints,
                                  ParameterBlock newParamBlock,
                                  RenderingHints newHints,
                                  CollectionImage oldRendering,
                                  CollectionOp op) {
        CollectionImage updatedCollection = null;

        if(oldParamBlock.getObjectParameter(0).equals(newParamBlock.getObjectParameter(0)) &&
           (oldHints == null ? newHints == null : oldHints.equals(newHints))) {

            // Retrieve the old and new sources and the parameters.
            Collection oldSource = (Collection)oldParamBlock.getSource(0);
            Collection newSource = (Collection)newParamBlock.getSource(0);
            double[] constants = (double[])oldParamBlock.getObjectParameter(0);

            // Construct a Collection of common sources.
            Collection commonSources = new ArrayList();
            Iterator it = oldSource.iterator();
            while(it.hasNext()) {
                Object oldElement = it.next();
                if(newSource.contains(oldElement)) {
                    commonSources.add(oldElement);
                }
            }

            if(commonSources.size() != 0) {
                // Construct a Collection of the RenderedOp nodes that
                // will be retained in the new CollectionImage.
                ArrayList commonNodes = new ArrayList(commonSources.size());
                it = oldRendering.iterator();
                while(it.hasNext()) {
                    RenderedOp node = (RenderedOp)it.next();
                    PlanarImage source = (PlanarImage)node.getSourceImage(0);
                    if(commonSources.contains(source)) {
                        commonNodes.add(node);
                    }
                }

                // Create a new CollectionImage.
                updatedCollection =
                    new AddConstToCollectionOpImage(newSource, newHints,
                                                    constants);

                // Remove from the new CollectionImage all nodes that
                // are common with the old CollectionImage.
                ArrayList newNodes = new ArrayList(oldRendering.size() -
                                                   commonSources.size());
                it = updatedCollection.iterator();
                while(it.hasNext()) {
                    RenderedOp node = (RenderedOp)it.next();
                    PlanarImage source = (PlanarImage)node.getSourceImage(0);
                    if(commonSources.contains(source)) {
                        it.remove();
                    }
                }

                // Add all the common nodes to the new CollectionImage.
                it = commonNodes.iterator();
                while(it.hasNext()) {
                    updatedCollection.add(it.next());
                }
            }
        }

        return updatedCollection;
View Full Code Here

/*  57 */     return new AddConstToCollectionOpImage((Collection)args.getSource(0), hints, (double[])args.getObjectParameter(0));
/*     */   }
/*     */
/*     */   public CollectionImage update(ParameterBlock oldParamBlock, RenderingHints oldHints, ParameterBlock newParamBlock, RenderingHints newHints, CollectionImage oldRendering, CollectionOp op)
/*     */   {
/*  72 */     CollectionImage updatedCollection = null;
/*     */
/*  74 */     if ((oldParamBlock.getObjectParameter(0).equals(newParamBlock.getObjectParameter(0))) && (oldHints == null ? newHints == null : oldHints.equals(newHints)))
/*     */     {
/*  78 */       Collection oldSource = (Collection)oldParamBlock.getSource(0);
/*  79 */       Collection newSource = (Collection)newParamBlock.getSource(0);
/*  80 */       double[] constants = (double[])oldParamBlock.getObjectParameter(0);
/*     */
/*  83 */       Collection commonSources = new ArrayList();
/*  84 */       Iterator it = oldSource.iterator();
/*  85 */       while (it.hasNext()) {
/*  86 */         Object oldElement = it.next();
/*  87 */         if (newSource.contains(oldElement)) {
/*  88 */           commonSources.add(oldElement);
/*     */         }
/*     */       }
/*     */
/*  92 */       if (commonSources.size() != 0)
/*     */       {
/*  95 */         ArrayList commonNodes = new ArrayList(commonSources.size());
/*  96 */         it = oldRendering.iterator();
/*  97 */         while (it.hasNext()) {
/*  98 */           RenderedOp node = (RenderedOp)it.next();
/*  99 */           PlanarImage source = node.getSourceImage(0);
/* 100 */           if (commonSources.contains(source)) {
/* 101 */             commonNodes.add(node);
/*     */           }
/*     */
/*     */         }
/*     */
/* 106 */         updatedCollection = new AddConstToCollectionOpImage(newSource, newHints, constants);
/*     */
/* 112 */         ArrayList newNodes = new ArrayList(oldRendering.size() - commonSources.size());
/*     */
/* 114 */         it = updatedCollection.iterator();
/* 115 */         while (it.hasNext()) {
/* 116 */           RenderedOp node = (RenderedOp)it.next();
/* 117 */           PlanarImage source = node.getSourceImage(0);
/* 118 */           if (commonSources.contains(source)) {
/* 119 */             it.remove();
/*     */           }
/*     */
/*     */         }
/*     */
/* 124 */         it = commonNodes.iterator();
/* 125 */         while (it.hasNext()) {
/* 126 */           updatedCollection.add(it.next());
/*     */         }
/*     */       }
/*     */     }
/*     */
/* 131 */     return updatedCollection;
View Full Code Here

TOP

Related Classes of javax.media.jai.CollectionImage

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.