Package com.lightcrafts.mediax.jai

Examples of com.lightcrafts.mediax.jai.RasterAccessor


        // Retrieve format tags.
        RasterFormatTag[] formatTags = getFormatTags();

        Rectangle srcRect = mapDestRect(destRect, 0);

        RasterAccessor dst = new RasterAccessor(dest, destRect, 
                                                formatTags[1], getColorModel());
        RasterAccessor src = new RasterAccessor(sources[0], srcRect, 
                                                formatTags[0],
                                                getSourceImage(0).getColorModel());
        switch (dst.getDataType()) {
        case DataBuffer.TYPE_BYTE:
            computeRectByte(src, dst);
View Full Code Here


                               Rectangle destRect) {
        // Get RasterAccessor tags (initialized in OpImage superclass).
        RasterFormatTag[] formatTags = getFormatTags();

        // Get destination accessor.
        RasterAccessor dst = new RasterAccessor(dest, destRect, 
                                                formatTags[1],
                                                getColorModel());

        // Backward map destination rectangle to source and clip to the
        // source image bounds (mapDestRect() does not clip automatically).
        Rectangle srcRect =
            mapDestRect(destRect, 0).intersection(sources[0].getBounds());

        // Get source accessor.
        RasterAccessor src =
            new RasterAccessor(sources[0],
                               srcRect,
                               formatTags[0],
                               getSourceImage(0).getColorModel());

        switch(dst.getDataType()) {
View Full Code Here

        Raster source = sources[0];
        Rectangle srcRect = mapDestRect(destRect, 0);
        RasterAccessor srcAccessor =
            new RasterAccessor(source, srcRect,
                               formatTags[0],
                               getSourceImage(0).getColorModel());
        RasterAccessor dstAccessor =
            new RasterAccessor(dest, destRect, 
                               formatTags[1], getColorModel());
        switch (dstAccessor.getDataType()) {
        case DataBuffer.TYPE_BYTE:
            byteLoop(srcAccessor, dstAccessor, maskSize);
            break;
        case DataBuffer.TYPE_SHORT:
            shortLoop(srcAccessor, dstAccessor, maskSize);
            break;
        case DataBuffer.TYPE_USHORT:
            ushortLoop(srcAccessor, dstAccessor, maskSize);
            break;
        case DataBuffer.TYPE_INT:
            intLoop(srcAccessor, dstAccessor, maskSize);
            break;
        case DataBuffer.TYPE_FLOAT:
            floatLoop(srcAccessor, dstAccessor, maskSize);
            break;
        case DataBuffer.TYPE_DOUBLE:
            doubleLoop(srcAccessor, dstAccessor, maskSize);
            break;
        }
        // If the RasterAccessor object set up a temporary buffer for the
        // op to write to, tell the RasterAccessor to write that data
        // to the raster no that we're done with it.
        if (dstAccessor.isDataCopy()) {
            dstAccessor.clampDataArrays();
            dstAccessor.copyDataToRaster();
        }
    }
View Full Code Here

        int srcY = source.getMinY();

        // Retrieve format tags.
        RasterFormatTag[] formatTags = getFormatTags();

        RasterAccessor srcAccessor =
            new RasterAccessor(source,
                               new Rectangle(srcX, srcY,
                                             srcWidth, srcHeight),
                               formatTags[0],
                               getSourceImage(0).getColorModel());
        RasterAccessor dstAccessor =
            new RasterAccessor(dest, destRect, 
                               formatTags[1], getColorModel());

        // Set data type flags.
        int srcDataType = srcAccessor.getDataType();
        int dstDataType = dstAccessor.getDataType();

        // Set pixel and line strides.
        int srcPixelStride = srcAccessor.getPixelStride();
        int srcScanlineStride = srcAccessor.getScanlineStride();
        int dstPixelStride = dstAccessor.getPixelStride();
        int dstScanlineStride = dstAccessor.getScanlineStride();

        // Loop over the bands.
        int numBands = sampleModel.getNumBands();
        for(int band = 0; band < numBands; band++) {
            // Get the source and destination arrays for this band.
            Object srcData = srcAccessor.getDataArray(band);
            Object dstData = dstAccessor.getDataArray(band);

            if(destRect.width > 1) {
                // Set the FCT length.
                fct.setLength(getWidth());

                // Initialize the data offsets for this band.
                int srcOffset = srcAccessor.getBandOffset(band);
                int dstOffset = dstAccessor.getBandOffset(band);

                // Perform the row transforms.
                for(int row = 0; row < srcHeight; row++) {
                    // Set the input data of the FCT.
                    fct.setData(srcDataType, srcData,
                                srcOffset, srcPixelStride,
                                srcWidth);

                    // Calculate the DFT of the row.
                    fct.transform();

                    // Get the output data of the FCT.
                    fct.getData(dstDataType, dstData,
                                dstOffset, dstPixelStride);

                    // Increment the data offsets.
                    srcOffset += srcScanlineStride;
                    dstOffset += dstScanlineStride;
                }
            }

            if(destRect.width == 1) { // destRect.height > 1
                // Initialize the data offsets for this band.
                int srcOffset = srcAccessor.getBandOffset(band);
                int dstOffset = dstAccessor.getBandOffset(band);

                // Set the input data of the FCT.
                fct.setData(srcDataType, srcData,
                            srcOffset, srcScanlineStride,
                            srcHeight);

                // Calculate the DFT of the row.
                fct.transform();

                // Get the output data of the FCT.
                fct.getData(dstDataType, dstData,
                            dstOffset, dstScanlineStride);
            } else if(destRect.height > 1) { // destRect.width > 1
                // Reset the FCT length.
                fct.setLength(getHeight());

                // Initialize destination offset.
                int dstOffset = dstAccessor.getBandOffset(band);

                // Perform the column transforms.
                for(int col = 0; col < destRect.width; col++) {
                    // Set the input data of the FCT.
                    fct.setData(dstDataType, dstData,
                                dstOffset, dstScanlineStride,
                                destRect.height);

                    // Calculate the DFT of the column.
                    fct.transform();

                    // Get the output data of the FCT.
                    fct.getData(dstDataType, dstData,
                                dstOffset, dstScanlineStride);

                    // Increment the data offset.
                    dstOffset += dstPixelStride;
                }
            }
        }

        if (dstAccessor.needsClamping()) {
            dstAccessor.clampDataArrays();
        }

        // Make sure that the output data is copied to the destination.
        dstAccessor.copyDataToRaster();
    }
View Full Code Here

                               Rectangle destRect) {
        // Retrieve format tags.
        RasterFormatTag[] formatTags = getFormatTags();

        /* For PointOpImage, srcRect = destRect. */
        RasterAccessor s1 = new RasterAccessor(sources[0], destRect, 
                                               formatTags[0],
                                               getSourceImage(0).getColorModel());
        RasterAccessor s2 = new RasterAccessor(sources[1], destRect, 
                                               formatTags[1],
                                               getSourceImage(1).getColorModel());
        RasterAccessor d = new RasterAccessor(dest, destRect, 
                                              formatTags[2], getColorModel());

        switch (d.getDataType()) {
        case DataBuffer.TYPE_BYTE:
            computeRectByte(s1, s2, d);
            break;
        case DataBuffer.TYPE_USHORT:
            computeRectUShort(s1, s2, d);
            break;
        case DataBuffer.TYPE_SHORT:
            computeRectShort(s1, s2, d);
            break;
        case DataBuffer.TYPE_INT:
            computeRectInt(s1, s2, d);
            break;
        case DataBuffer.TYPE_FLOAT:
            computeRectFloat(s1, s2, d);
            break;
        case DataBuffer.TYPE_DOUBLE:
            computeRectDouble(s1, s2, d);
            break;
        }

        if (d.isDataCopy()) {
            d.clampDataArrays();
            d.copyDataToRaster();
        }
    }
View Full Code Here

        Raster source = sources[0];
        Rectangle srcRect = mapDestRect(destRect, 0);
        RasterAccessor srcAccessor =
            new RasterAccessor(source, srcRect, formatTags[0],
                               getSource(0).getColorModel());
        RasterAccessor dstAccessor =
            new RasterAccessor(dest, destRect, formatTags[1],
                               this.getColorModel());
        switch (dstAccessor.getDataType()) {
        case DataBuffer.TYPE_BYTE:
            byteLoop(srcAccessor, dstAccessor);
            break;
        case DataBuffer.TYPE_INT:
            intLoop(srcAccessor, dstAccessor);
            break;
        case DataBuffer.TYPE_SHORT:
            shortLoop(srcAccessor, dstAccessor);
            break;
        case DataBuffer.TYPE_USHORT:
            ushortLoop(srcAccessor, dstAccessor);
            break;
        case DataBuffer.TYPE_FLOAT:
            floatLoop(srcAccessor, dstAccessor);
            break;
        case DataBuffer.TYPE_DOUBLE:
            doubleLoop(srcAccessor, dstAccessor);
            break;
        default:
        }
        // If the RasterAccessor object set up a temporary buffer for the
        // op to write to, tell the RasterAccessor to write that data
        // to the raster no that we're done with it.
        if (dstAccessor.isDataCopy()) {
            dstAccessor.clampDataArrays();
            dstAccessor.copyDataToRaster();
        }
    }
View Full Code Here

        RasterFormatTag[] formatTags = getFormatTags();

        Raster source = sources[0];
        Rectangle srcRect = mapDestRect(destRect, 0);
        RasterAccessor srcAccessor =
            new RasterAccessor(source,
                               srcRect,
                               formatTags[0], getSourceImage(0).getColorModel());
        RasterAccessor dstAccessor =
            new RasterAccessor(dest,
                               destRect,
                               formatTags[1], getColorModel());
        switch (dstAccessor.getDataType()) {
        case DataBuffer.TYPE_BYTE:
            byteLoop(srcAccessor, dstAccessor);
            break;
        case DataBuffer.TYPE_INT:
            intLoop(srcAccessor, dstAccessor);
            break;
        case DataBuffer.TYPE_SHORT:
            shortLoop(srcAccessor, dstAccessor);
            break;
        case DataBuffer.TYPE_USHORT:
            ushortLoop(srcAccessor, dstAccessor);
            break;
        case DataBuffer.TYPE_FLOAT:
            floatLoop(srcAccessor, dstAccessor);
            break;
        case DataBuffer.TYPE_DOUBLE:
            doubleLoop(srcAccessor, dstAccessor);
            break;

        default:
        }
        // If the RasterAccessor object set up a temporary buffer for the
        // op to write to, tell the RasterAccessor to write that data
        // to the raster no that we're done with it.
        if (dstAccessor.isDataCopy()) {
            dstAccessor.clampDataArrays();
            dstAccessor.copyDataToRaster();
        }
    }
View Full Code Here

        RasterFormatTag[] formatTags = getFormatTags();

        if(isByteData) {
            computeRectByte(sources, dest, destRect);
        } else {
            RasterAccessor dst =
                new RasterAccessor(dest, destRect, formatTags[1],
                                   getColorModel());
            RasterAccessor src =
                new RasterAccessor(sources[0], destRect, formatTags[0],
                                   getSource(0).getColorModel());

            switch (dst.getDataType()) {
            case DataBuffer.TYPE_USHORT:
                computeRectUShort(src, dst);
View Full Code Here

        // Retrieve format tags.
        RasterFormatTag[] formatTags = getFormatTags();

        int numSrcs = getNumSources();
       
        RasterAccessor dst = new RasterAccessor(dest, destRect,
                               formatTags[numSrcs], getColorModel());

        RasterAccessor[] srcs = new RasterAccessor[numSrcs];
        for (int i = 0; i < numSrcs; i++) {
            Rectangle srcRect = mapDestRect(destRect, i);
            srcs[i] = new RasterAccessor(sources[i], srcRect, 
                                         formatTags[i],
                                         getSourceImage(i).getColorModel());
        }

        switch (dst.getDataType()) {
        case DataBuffer.TYPE_BYTE:
            computeRectByte(srcs, dst);
            break;
        case DataBuffer.TYPE_USHORT:
            computeRectUShort(srcs, dst);
            break;
        case DataBuffer.TYPE_SHORT:
            computeRectShort(srcs, dst);
            break;
        case DataBuffer.TYPE_INT:
            computeRectInt(srcs, dst);
            break;
        case DataBuffer.TYPE_FLOAT:
            computeRectFloat(srcs, dst);
            break;
        case DataBuffer.TYPE_DOUBLE:
            computeRectDouble(srcs, dst);
            break;
        }

        if (dst.needsClamping()) {
            /* Further clamp down to underlying raster data type. */
            dst.clampDataArrays();
        }
        dst.copyDataToRaster();
    }
View Full Code Here

        byte[][] dstData = dst.getByteDataArrays();

        int numSrcs = getNumSources();
       
        for (int i = 0; i < numSrcs; i++) {
            RasterAccessor src = srcs[i];
            int srcLineStride = src.getScanlineStride();
            int srcPixelStride = src.getPixelStride();
            int[] srcBandOffsets = src.getBandOffsets();
            byte[][] srcData = src.getByteDataArrays();

            for (int b = 0; b < dstBands; b++) {
                int dstLineOffset = dstBandOffsets[b];
                int srcLineOffset = srcBandOffsets[b];
View Full Code Here

TOP

Related Classes of com.lightcrafts.mediax.jai.RasterAccessor

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.