Package com.volantis.map.ics.imageprocessor.impl

Examples of com.volantis.map.ics.imageprocessor.impl.GenericCollectionImage


                                                    "inputData");
            throw new IllegalArgumentException(msg);
        }

        CollectionImage input = null;
        CollectionImage translated = new GenericCollectionImage();

        try {
            for (InputImageConditioner c : conditioners) {
                inputData = c.process(inputData);
            }

            input = (CollectionImage)
                ImageReadDescriptor.createCollection(
                    inputData,
                    null,
                    Boolean.TRUE,
                    Boolean.FALSE,
                    Boolean.FALSE,
                    null,
                    null,
                    null,
                    null,
                    null);

            Iterator it = input.iterator();

            while(it.hasNext()) {
                int minX = 0;
                int minY = 0;
                RenderedOp op = (RenderedOp) it.next();
                // for some reason this method occasinally returns an Object
                // i.e. not an IIOMetadata instance
                Object imageMetaObj = op.getProperty("JAI.ImageMetadata");
                if (imageMetaObj instanceof IIOMetadata) {
                    IIOMetadata imageMeta =  (IIOMetadata) imageMetaObj;
                    if (imageMeta != null && imageMeta.isStandardMetadataFormatSupported()) {
                        Node root = imageMeta.getAsTree("javax_imageio_1.0");
                        Node dimension = getChildByLocalName(root, "Dimension");
                        Node minXNode = null;
                        Node minYNode = null;
                        if (dimension != null) {
                            minXNode = getChildByLocalName(
                                dimension, "HorizontalPixelOffset");
                            minYNode = getChildByLocalName(
                                dimension, "VerticalPixelOffset");
                        }
                        if (minXNode != null) {
                            minX = Integer.parseInt(minXNode.
                                getAttributes().getNamedItem("value").getNodeValue());
                        }
                        if (minYNode != null) {
                            minY = Integer.parseInt(minYNode.
                                getAttributes().getNamedItem("value").getNodeValue());
                        }
                    }
                }
                if (minX != 0 || minY != 0) {
                    translated.add(TranslateDescriptor.create(op, (float) minX, (float) minY, null, null));
                } else {
                    translated.add(op);
                }
            }         
        } catch (Exception e) {
            LOGGER.error("jai-operation-failure", new String[]{ "ImageRead", e.toString() });
            throw new RuntimeException(e);
        }

        final RenderedOp[] result = new RenderedOp[input.size()];
        int i = 0;
        for (Iterator iter = translated.iterator(); iter.hasNext(); i++) {
            RenderedOp op = (RenderedOp) iter.next();
            final int dataType = op.getSampleModel().getDataType();
            if (dataType != DataBuffer.TYPE_BYTE) {
                op = changeDataTypeToByte(op);
            }
View Full Code Here


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

TOP

Related Classes of com.volantis.map.ics.imageprocessor.impl.GenericCollectionImage

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.