Package javax.media.jai

Examples of javax.media.jai.RasterAccessor


        //
        // Get data for the source rectangle & the destination rectangle
        Rectangle srcRect = src.getBounds();

        RasterAccessor srcAccessor =
            new RasterAccessor(src, srcRect,
                               formatTags[0],
                               getSource(0).getColorModel());
        RasterAccessor dstAccessor =
            new RasterAccessor(dest, destRect, formatTags[1], getColorModel());

        int incr1 = 0, incr2 = 0, s_x = 0, s_y = 0;
        int srcPixelStride = srcAccessor.getPixelStride();
        int srcScanlineStride = srcAccessor.getScanlineStride();

        // Backwards map starting point of destination rectangle
        int[] pt = new int[2];
        pt[0] = destRect.x;
        pt[1] = destRect.y;
        mapPoint(pt, sMinX, sMinY, sMaxX, sMaxY, type, false);
        s_x = pt[0];
        s_y = pt[1];

        // Determine source stride along dest row (incr1) and column (incr2)
        switch (type) {
        case 0: // FLIP_VERTICAL
            incr1 = srcPixelStride;
            incr2 = -srcScanlineStride;
            break;

        case 1: // FLIP_HORIZONTAL
            incr1 = -srcPixelStride;
            incr2 = srcScanlineStride;
            break;

        case 2: // FLIP_DIAGONAL;
            incr1 = srcScanlineStride;
            incr2 = srcPixelStride;
            break;

        case 3: // FLIP_ANTIDIAGONAL
            incr1 = -srcScanlineStride;
            incr2 = -srcPixelStride;
            break;

        case 4: // ROTATE_90
            incr1 = -srcScanlineStride;
            incr2 = srcPixelStride;
            break;

        case 5: // ROTATE_180
            incr1 = -srcPixelStride;
            incr2 = -srcScanlineStride;
            break;

        case 6: // ROTATE_270
            incr1 = srcScanlineStride;
            incr2 = -srcPixelStride;
            break;
        }

        switch (dstAccessor.getDataType()) {
        case DataBuffer.TYPE_BYTE:
            byteLoop(srcAccessor,
                     destRect,
                     translateX,
                     translateY,
                     dstAccessor,
                     incr1, incr2, s_x, s_y);
            break;

        case DataBuffer.TYPE_INT:
            intLoop(srcAccessor,
                    destRect,
                    translateX,
                    translateY,
                    dstAccessor,
                    incr1, incr2, s_x, s_y);
            break;

        case DataBuffer.TYPE_SHORT:
        case DataBuffer.TYPE_USHORT:
            shortLoop(srcAccessor,
                      destRect,
                      translateX,
                      translateY,
                      dstAccessor,
                      incr1, incr2, s_x, s_y);
            break;

        case DataBuffer.TYPE_FLOAT:
            floatLoop(srcAccessor,
                      destRect,
                      translateX,
                      translateY,
                      dstAccessor,
                      incr1, incr2, s_x, s_y);
            break;

        case DataBuffer.TYPE_DOUBLE:
            doubleLoop(srcAccessor,
                       destRect,
                       translateX,
                       translateY,
                       dstAccessor,
                       incr1, incr2, s_x, s_y);
            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, that we're done with it.
        //
        if (dstAccessor.isDataCopy()) {
            dstAccessor.clampDataArrays();
            dstAccessor.copyDataToRaster();
        }
    }
View Full Code Here


        // 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],
                                                getSource(0).getColorModel());

        switch (dst.getDataType()) {
        case DataBuffer.TYPE_BYTE:
View Full Code Here

        // In the first version source Rectangle is the whole source
        // image always.
        //
        // See if we can cache the source to avoid multiple rasteraccesors
        //
        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,
                     destRect,
                     srcRectX,
                     srcRectY,
                     dstAccessor);
            break;

        case DataBuffer.TYPE_INT:
            intLoop(srcAccessor,
                    destRect,
                    srcRectX,
                    srcRectY,
                    dstAccessor);
            break;

        case DataBuffer.TYPE_SHORT:
            shortLoop(srcAccessor,
                      destRect,
                      srcRectX,
                      srcRectY,
                      dstAccessor);
            break;

        case DataBuffer.TYPE_USHORT:
            ushortLoop(srcAccessor,
                       destRect,
                       srcRectX,
                       srcRectY,
                       dstAccessor);
      break;

        case DataBuffer.TYPE_FLOAT:
            floatLoop(srcAccessor,
                      destRect,
                      srcRectX,
                      srcRectY,
                      dstAccessor);
      break;

        case DataBuffer.TYPE_DOUBLE:
            doubleLoop(srcAccessor,
                       destRect,
                       srcRectX,
                       srcRectY,
                       dstAccessor);
      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, that we're done with it.
        if (dstAccessor.isDataCopy()) {
            dstAccessor.clampDataArrays();
            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],
                                               getSource(0).getColorModel());
        RasterAccessor s2 = new RasterAccessor(sources[1], destRect, 
                                               formatTags[1],
                                               getSource(1).getColorModel());
        RasterAccessor d = new RasterAccessor(dest, destRect, 
                                              formatTags[2], getColorModel());

        if(d.isBinary()) {
            byte[] src1Bits = s1.getBinaryDataArray();
            byte[] src2Bits = s2.getBinaryDataArray();
            byte[] dstBits = d.getBinaryDataArray();

            int length = dstBits.length;
            for(int i = 0; i < length; i++) {
                dstBits[i] = (byte)(src1Bits[i] ^ src2Bits[i]);
            }

            d.copyBinaryDataToRaster();

      return;
        }

        int src1LineStride = s1.getScanlineStride();
        int src1PixelStride = s1.getPixelStride();
        int[] src1BandOffsets = s1.getBandOffsets();

        int src2LineStride = s2.getScanlineStride();
        int src2PixelStride = s2.getPixelStride();
        int[] src2BandOffsets = s2.getBandOffsets();

        int dstNumBands = d.getNumBands();
        int dstWidth = d.getWidth();
        int dstHeight = d.getHeight();
        int dstLineStride = d.getScanlineStride();
        int dstPixelStride = d.getPixelStride();
        int[] dstBandOffsets = d.getBandOffsets();

        switch (d.getDataType()) {
     
        case DataBuffer.TYPE_BYTE:
            byteLoop(dstNumBands, dstWidth, dstHeight,
                     src1LineStride, src1PixelStride,
                     src1BandOffsets, s1.getByteDataArrays(),
                     src2LineStride, src2PixelStride,
                     src2BandOffsets, s2.getByteDataArrays(),
                     dstLineStride, dstPixelStride,
                     dstBandOffsets, d.getByteDataArrays());
            break;
     
        case DataBuffer.TYPE_USHORT:
        case DataBuffer.TYPE_SHORT:
            shortLoop(dstNumBands, dstWidth, dstHeight,
          src1LineStride, src1PixelStride,
          src1BandOffsets, s1.getShortDataArrays(),
          src2LineStride, src2PixelStride,
          src2BandOffsets, s2.getShortDataArrays(),
          dstLineStride, dstPixelStride,
          dstBandOffsets, d.getShortDataArrays());
            break;
     
        case DataBuffer.TYPE_INT:
            intLoop(dstNumBands, dstWidth, dstHeight,
                    src1LineStride, src1PixelStride,
                    src1BandOffsets, s1.getIntDataArrays(),
                    src2LineStride, src2PixelStride,
                    src2BandOffsets, s2.getIntDataArrays(),
                    dstLineStride, dstPixelStride,
                    dstBandOffsets, d.getIntDataArrays());
            break;
        }
 
        d.copyDataToRaster();
    }
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);
      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

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

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

        if(d.isBinary()) {
            byte[] src1Bits = s1.getBinaryDataArray();
            byte[] src2Bits = s2.getBinaryDataArray();
            byte[] dstBits = d.getBinaryDataArray();

            int length = dstBits.length;
            for(int i = 0; i < length; i++) {
                // "Multiply" is equivalent to "And".
                dstBits[i] = (byte)(src1Bits[i] & src2Bits[i]);
            }

            d.copyBinaryDataToRaster();

      return;
        }

        int src1LineStride = s1.getScanlineStride();
        int src1PixelStride = s1.getPixelStride();
        int[] src1BandOffsets = s1.getBandOffsets();

        int src2LineStride = s2.getScanlineStride();
        int src2PixelStride = s2.getPixelStride();
        int[] src2BandOffsets = s2.getBandOffsets();

        int dstNumBands = d.getNumBands();
        int dstWidth = d.getWidth();
        int dstHeight = d.getHeight();
        int dstLineStride = d.getScanlineStride();
        int dstPixelStride = d.getPixelStride();
        int[] dstBandOffsets = d.getBandOffsets();

        switch (d.getDataType()) {
     
        case DataBuffer.TYPE_BYTE:
            byteLoop(dstNumBands, dstWidth, dstHeight,
                     src1LineStride, src1PixelStride,
                     src1BandOffsets, s1.getByteDataArrays(),
                     src2LineStride, src2PixelStride,
                     src2BandOffsets, s2.getByteDataArrays(),
                     dstLineStride, dstPixelStride,
                     dstBandOffsets, d.getByteDataArrays());
            break;
     
        case DataBuffer.TYPE_USHORT:
            ushortLoop(dstNumBands, dstWidth, dstHeight,
                       src1LineStride, src1PixelStride,
                       src1BandOffsets, s1.getShortDataArrays(),
                       src2LineStride, src2PixelStride,
                       src2BandOffsets, s2.getShortDataArrays(),
                       dstLineStride, dstPixelStride,
                       dstBandOffsets, d.getShortDataArrays());
            break;
     
        case DataBuffer.TYPE_SHORT:
            shortLoop(dstNumBands, dstWidth, dstHeight,
                      src1LineStride, src1PixelStride,
                      src1BandOffsets, s1.getShortDataArrays(),
                      src2LineStride, src2PixelStride,
                      src2BandOffsets, s2.getShortDataArrays(),
                      dstLineStride, dstPixelStride,
                      dstBandOffsets, d.getShortDataArrays());
            break;
     
        case DataBuffer.TYPE_INT:
            intLoop(dstNumBands, dstWidth, dstHeight,
                    src1LineStride, src1PixelStride,
                    src1BandOffsets, s1.getIntDataArrays(),
                    src2LineStride, src2PixelStride,
                    src2BandOffsets, s2.getIntDataArrays(),
                    dstLineStride, dstPixelStride,
                    dstBandOffsets, d.getIntDataArrays());
            break;
     
        case DataBuffer.TYPE_FLOAT:
            floatLoop(dstNumBands, dstWidth, dstHeight,
                      src1LineStride, src1PixelStride,
                      src1BandOffsets, s1.getFloatDataArrays(),
                      src2LineStride, src2PixelStride,
                      src2BandOffsets, s2.getFloatDataArrays(),
                      dstLineStride, dstPixelStride,
                      dstBandOffsets, d.getFloatDataArrays());
            break;

        case DataBuffer.TYPE_DOUBLE:
            doubleLoop(dstNumBands, dstWidth, dstHeight,
                       src1LineStride, src1PixelStride,
                       src1BandOffsets, s1.getDoubleDataArrays(),
                       src2LineStride, src2PixelStride,
                       src2BandOffsets, s2.getDoubleDataArrays(),
                       dstLineStride, dstPixelStride,
                       dstBandOffsets, d.getDoubleDataArrays());
            break;
        }

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

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

        RasterAccessor s = new RasterAccessor(sources[0], destRect, 
                                              formatTags[0],
                                              getSourceImage(0).getColorModel());
        RasterAccessor d = new RasterAccessor(dest, destRect, 
                                              formatTags[1], getColorModel());

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

        if (d.isDataCopy()) {
            d.clampDataArrays();
            d.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],
                                               getSource(0).getColorModel());
        RasterAccessor s2 = new RasterAccessor(sources[1], destRect, 
                                               formatTags[1],
                                               getSource(1).getColorModel());
        RasterAccessor d = new RasterAccessor(dest, destRect, 
                                              formatTags[2], getColorModel());

        if(d.isBinary()) {
            byte[] src1Bits = s1.getBinaryDataArray();
            byte[] src2Bits = s2.getBinaryDataArray();
            byte[] dstBits = d.getBinaryDataArray();

            int length = dstBits.length;
            for(int i = 0; i < length; i++) {
                dstBits[i] = (byte)(src1Bits[i] | src2Bits[i]);
            }

            d.copyBinaryDataToRaster();

            return;
        }
        int src1LineStride = s1.getScanlineStride();
        int src1PixelStride = s1.getPixelStride();
        int[] src1BandOffsets = s1.getBandOffsets();

        int src2LineStride = s2.getScanlineStride();
        int src2PixelStride = s2.getPixelStride();
        int[] src2BandOffsets = s2.getBandOffsets();

        int dstNumBands = d.getNumBands();
        int dstWidth = d.getWidth();
        int dstHeight = d.getHeight();
        int dstLineStride = d.getScanlineStride();
        int dstPixelStride = d.getPixelStride();
        int[] dstBandOffsets = d.getBandOffsets();

        switch (d.getDataType()) {
     
        case DataBuffer.TYPE_BYTE:
            byteLoop(dstNumBands, dstWidth, dstHeight,
                     src1LineStride, src1PixelStride,
                     src1BandOffsets, s1.getByteDataArrays(),
                     src2LineStride, src2PixelStride,
                     src2BandOffsets, s2.getByteDataArrays(),
                     dstLineStride, dstPixelStride,
                     dstBandOffsets, d.getByteDataArrays());
            break;
     
        case DataBuffer.TYPE_USHORT:
        case DataBuffer.TYPE_SHORT:
            shortLoop(dstNumBands, dstWidth, dstHeight,
          src1LineStride, src1PixelStride,
          src1BandOffsets, s1.getShortDataArrays(),
          src2LineStride, src2PixelStride,
          src2BandOffsets, s2.getShortDataArrays(),
          dstLineStride, dstPixelStride,
          dstBandOffsets, d.getShortDataArrays());
            break;
     
        case DataBuffer.TYPE_INT:
            intLoop(dstNumBands, dstWidth, dstHeight,
                    src1LineStride, src1PixelStride,
                    src1BandOffsets, s1.getIntDataArrays(),
                    src2LineStride, src2PixelStride,
                    src2BandOffsets, s2.getIntDataArrays(),
                    dstLineStride, dstPixelStride,
                    dstBandOffsets, d.getIntDataArrays());
            break;
        }
 
        d.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_SHORT:
            shortLoop(srcAccessor,dstAccessor);
            break;
        case DataBuffer.TYPE_INT:
            intLoop(srcAccessor,dstAccessor);
            break;
        case DataBuffer.TYPE_FLOAT:
            floatLoop(srcAccessor,dstAccessor);
            break;
        case DataBuffer.TYPE_DOUBLE:
            doubleLoop(srcAccessor,dstAccessor);
            break;
        case DataBuffer.TYPE_BYTE:
        case DataBuffer.TYPE_USHORT:
        default:
            throw new RuntimeException(JaiI18N.getString("ConjugateOpImage0"));
        }

        // 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

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

        RasterAccessor src = new RasterAccessor(sources[0], destRect,
                                                formatTags[0],
                                                getSourceImage(0).getColorModel());
        RasterAccessor dst = new RasterAccessor(dest, destRect,
                                                formatTags[1],
                                                getColorModel());

        if(dst.isBinary()) {
            byte[] dstBits = dst.getBinaryDataArray();
            System.arraycopy(src.getBinaryDataArray(), 0,
                             dstBits, 0, dstBits.length);

            dst.copyBinaryDataToRaster();

      return;
        }

        /* Find out what kind of data type is used to store the image */
        switch ( dst.getDataType() ) {
        case DataBuffer.TYPE_BYTE:
            byteAbsolute(dst.getNumBands(),
                         dst.getWidth(),
                         dst.getHeight(),
                         src.getScanlineStride(),
                         src.getPixelStride(),
                         src.getBandOffsets(),
                         src.getByteDataArrays(),
                         dst.getScanlineStride(),
                         dst.getPixelStride(),
                         dst.getBandOffsets(),
                         dst.getByteDataArrays());
            break;

        case DataBuffer.TYPE_SHORT:
            shortAbsolute(dst.getNumBands(),
                          dst.getWidth(),
                          dst.getHeight(),
                          src.getScanlineStride(),
                          src.getPixelStride(),
                          src.getBandOffsets(),
                          src.getShortDataArrays(),
                          dst.getScanlineStride(),
                          dst.getPixelStride(),
                          dst.getBandOffsets(),
                          dst.getShortDataArrays());
            break;

        case DataBuffer.TYPE_USHORT:
            ushortAbsolute(dst.getNumBands(),
                           dst.getWidth(),
                           dst.getHeight(),
                           src.getScanlineStride(),
                           src.getPixelStride(),
                           src.getBandOffsets(),
                           src.getShortDataArrays(),
                           dst.getScanlineStride(),
                           dst.getPixelStride(),
                           dst.getBandOffsets(),
                           dst.getShortDataArrays());
            break;

        case DataBuffer.TYPE_INT:
            intAbsolute(dst.getNumBands(),
                        dst.getWidth(),
                        dst.getHeight(),
                        src.getScanlineStride(),
                        src.getPixelStride(),
                        src.getBandOffsets(),
                        src.getIntDataArrays(),
                        dst.getScanlineStride(),
                        dst.getPixelStride(),
                        dst.getBandOffsets(),
                        dst.getIntDataArrays());
            break;

        case DataBuffer.TYPE_FLOAT:
            floatAbsolute(dst.getNumBands(),
                          dst.getWidth(),
                          dst.getHeight(),
                          src.getScanlineStride(),
                          src.getPixelStride(),
                          src.getBandOffsets(),
                          src.getFloatDataArrays(),
                          dst.getScanlineStride(),
                          dst.getPixelStride(),
                          dst.getBandOffsets(),
                          dst.getFloatDataArrays());
            break;

        case DataBuffer.TYPE_DOUBLE:
            doubleAbsolute(dst.getNumBands(),
                           dst.getWidth(),
                           dst.getHeight(),
                           src.getScanlineStride(),
                           src.getPixelStride(),
                           src.getBandOffsets(),
                           src.getDoubleDataArrays(),
                           dst.getScanlineStride(),
                           dst.getPixelStride(),
                           dst.getBandOffsets(),
                           dst.getDoubleDataArrays());
            break;
        }
        if (dst.needsClamping()) {
            dst.clampDataArrays();
        }
        dst.copyDataToRaster();
    }
View Full Code Here

TOP

Related Classes of javax.media.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.