Package com.lightcrafts.mediax.jai

Examples of com.lightcrafts.mediax.jai.RasterAccessor


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

        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_USHORT:
                computeRectUShort(s1, s2, d);
                break;
            default:
                throw new UnsupportedOperationException("Unsupported data type: " + d.getDataType());
        }

        if (d.needsClamping()) {
            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

                               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

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

        // Construct RasterAccessors.
        RasterAccessor srcAccessor =
            new RasterAccessor(sources[0], destRect,
                               formatTags[0],
                               getSourceImage(0).getColorModel());
        RasterAccessor dstAccessor =
            new RasterAccessor(dest, destRect, formatTags[1], getColorModel());

        // Branch to the method appropriate to the accessor data type.
        switch(dstAccessor.getDataType()) {
        case DataBuffer.TYPE_BYTE:
            computeRectByte(srcAccessor, dstAccessor,
                            destRect.height, destRect.width);
            break;
        case DataBuffer.TYPE_SHORT:
            computeRectShort(srcAccessor, dstAccessor,
                             destRect.height, destRect.width);
            break;
        case DataBuffer.TYPE_USHORT:
            computeRectUShort(srcAccessor, dstAccessor,
                              destRect.height, destRect.width);
            break;
        case DataBuffer.TYPE_INT:
            computeRectInt(srcAccessor, dstAccessor,
                           destRect.height, destRect.width);
            break;
        case DataBuffer.TYPE_FLOAT:
            computeRectFloat(srcAccessor, dstAccessor,
                             destRect.height, destRect.width);
            break;
        case DataBuffer.TYPE_DOUBLE:
            computeRectDouble(srcAccessor, dstAccessor,
                              destRect.height, destRect.width);
            break;
        default:
            // NB: This statement should be unreachable.
            throw new RuntimeException(JaiI18N.getString("MagnitudePhaseOpImage0"));
        }

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

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

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

                               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++) {
                // "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

                for (int tx = startTileX; tx <= endTileX; tx++) {
                    Raster tile = getTile(tx, ty);
                    Rectangle subRegion =
                        region.intersection(tile.getBounds());

                    RasterAccessor s =
                        new RasterAccessor(tile, subRegion,
                                           srcTag, getColorModel());
                    RasterAccessor d =
                        new RasterAccessor(dest, subRegion,
                                           dstTag, null);
                    ImageUtil.copyRaster(s, d);
                }
            }
        }
View Full Code Here

        Raster source = sources[0];
  // Get the source rectangle
        Rectangle srcRect = source.getBounds();

        RasterAccessor srcAccessor =
            new RasterAccessor(source, srcRect, 
                               formatTags[0], getSource(0).getColorModel());

        RasterAccessor dstAccessor =
            new RasterAccessor(dest, destRect, formatTags[1], getColorModel());

  int dwidth = destRect.width;
  int dheight = destRect.height;
        int srcPixelStride = srcAccessor.getPixelStride();
  int srcScanlineStride = srcAccessor.getScanlineStride();

  int[] ypos = new int[dheight];
  int[] xpos = new int[dwidth];

  int   xfracvalues[] = null, yfracvalues[] = null;
  float xfracvaluesFloat[] = null, yfracvaluesFloat[] = null;

        switch (dstAccessor.getDataType()) {
        case DataBuffer.TYPE_BYTE:
        case DataBuffer.TYPE_SHORT:
        case DataBuffer.TYPE_USHORT:
        case DataBuffer.TYPE_INT:
       yfracvalues = new int[dheight];
       xfracvalues = new int[dwidth];
       preComputePositionsInt(destRect, srcRect.x, srcRect.y,
      srcPixelStride, srcScanlineStride,
      xpos, ypos, xfracvalues, yfracvalues);
       break;

  case DataBuffer.TYPE_FLOAT:
  case DataBuffer.TYPE_DOUBLE:
       yfracvaluesFloat = new float[dheight];
       xfracvaluesFloat = new float[dwidth];
       preComputePositionsFloat(destRect, srcRect.x, srcRect.y,
      srcPixelStride, srcScanlineStride,
      xpos, ypos, xfracvaluesFloat, yfracvaluesFloat);
             break;

        default:
            throw
    new RuntimeException(JaiI18N.getString("OrderedDitherOpImage0"));
        }

        switch (dstAccessor.getDataType()) {

        case DataBuffer.TYPE_BYTE:
            byteLoop(srcAccessor, destRect, dstAccessor,
      xpos, ypos, xfracvalues, yfracvalues);
            break;

        case DataBuffer.TYPE_SHORT:
      shortLoop(srcAccessor, destRect, dstAccessor,
      xpos, ypos, xfracvalues, yfracvalues);
            break;

        case DataBuffer.TYPE_USHORT:
      ushortLoop(srcAccessor, destRect, dstAccessor,
      xpos, ypos, xfracvalues, yfracvalues);
            break;

        case DataBuffer.TYPE_INT:
      intLoop(srcAccessor, destRect, dstAccessor,
      xpos, ypos, xfracvalues, yfracvalues);
            break;

  case DataBuffer.TYPE_FLOAT:
      floatLoop(srcAccessor, destRect, dstAccessor,
      xpos, ypos, xfracvaluesFloat, yfracvaluesFloat);
      break;

  case DataBuffer.TYPE_DOUBLE:
      doubleLoop(srcAccessor, destRect, dstAccessor,
      xpos, ypos, xfracvaluesFloat, yfracvaluesFloat);
      break;

        default:
      throw
    new RuntimeException(JaiI18N.getString("OrderedDitherOpImage0"));
        }

        // 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 now that we're done with it.
        if (dstAccessor.isDataCopy()) {
            dstAccessor.clampDataArrays();
            dstAccessor.copyDataToRaster();
        }
    }
View Full Code Here

        } else {
            // Retrieve format tags.
            formatTags = getFormatTags();
        }

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

        switch (src.getDataType()) {
        case DataBuffer.TYPE_BYTE:
            computeRectByte(src, dst);
            break;
        case DataBuffer.TYPE_SHORT:
            computeRectShort(src, dst);
            break;
        case DataBuffer.TYPE_USHORT:
            computeRectUShort(src, dst);
            break;
        case DataBuffer.TYPE_INT:
            computeRectInt(src, dst);
            break;
        case DataBuffer.TYPE_FLOAT:
            computeRectFloat(src, dst);
            break;
        case DataBuffer.TYPE_DOUBLE:
            computeRectDouble(src, dst);
            break;
        default:
            throw new RuntimeException(JaiI18N.getString("OrderedDitherOpImage1"));
        }

        dst.copyDataToRaster();
    }
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.