Package javax.media.jai

Examples of javax.media.jai.RasterAccessor


                               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());
        if(d.isBinary()) {
            byte[] dstBits = d.getBinaryDataArray();

            // Subtraction in this case boils down to copying image 1.
            System.arraycopy(s1.getBinaryDataArray(), 0,
                             dstBits, 0, dstBits.length);

            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 src1Accessor =
            new RasterAccessor(sources[0], destRect, 
                               formatTags[0],
                               getSourceImage(0).getColorModel());
        RasterAccessor src2Accessor =
            new RasterAccessor(sources[1], destRect, 
                               formatTags[1],
                               getSourceImage(1).getColorModel());
        RasterAccessor dstAccessor =
            new RasterAccessor(dest, destRect, 
                               formatTags[2], getColorModel());

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

        if (dstAccessor.needsClamping()) {
            dstAccessor.clampDataArrays();
        }
        // Make sure that the output data is copied to the destination.
        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],
                                                getSourceImage(0).getColorModel());

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

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

        // Construct RasterAccessors.
        RasterAccessor magAccessor =
            new RasterAccessor(sources[0], destRect, formatTags[0],
                               getSource(0).getColorModel());
        RasterAccessor phsAccessor =
            new RasterAccessor(sources[1], destRect, formatTags[1],
                               getSource(1).getColorModel());
        RasterAccessor dstAccessor =
            new RasterAccessor(dest, destRect, formatTags[2], getColorModel());

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

        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 ColormapOpImage, srcRect = destRect. */
        RasterAccessor s = new RasterAccessor(sources[0], destRect, 
                                              formatTags[0],
                                              getSourceImage(0).getColorModel());
        RasterAccessor d = new RasterAccessor(dest, destRect, 
                                              formatTags[1], getColorModel());

        if(d.isBinary()) {
            byte[] srcBits = s.getBinaryDataArray();
            byte[] dstBits = d.getBinaryDataArray();
            int length = dstBits.length;
            for(int i = 0; i < length; i++) {
                dstBits[i] = (byte)(~(srcBits[i]));
            }
            d.copyBinaryDataToRaster();
        } else {
            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:
            case DataBuffer.TYPE_DOUBLE:
                throw new RuntimeException(JaiI18N.getString("InvertOpImage0"));
            }

            d.copyDataToRaster();
        }
    }
View Full Code Here

    }

    protected void computeRect(PlanarImage[] sources,
                               WritableRaster dest,
                               Rectangle destRect) {
        RasterAccessor dst = new RasterAccessor(dest, destRect,
                                 rasterFormatTag,null);

        int dwidth = dst.getWidth();
        int dheight = dst.getHeight();

        int lineStride = dst.getScanlineStride();
        int pixelStride = dst.getPixelStride();

        int lineOffset0 = dst.getBandOffset(0);
        int lineOffset1 = dst.getBandOffset(1);
        int lineOffset2 = dst.getBandOffset(2);

        byte[] data = dst.getByteDataArray(0);

        int offset = (destRect.y - minY) * width + (destRect.x - minX);

        for (int h = 0; h < dheight; h++) {
            int pixelOffset0 = lineOffset0;
View Full Code Here

        Rectangle srcRect = source.getBounds();

  int srcRectX = srcRect.x;
  int srcRectY = srcRect.y;

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

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

  // Loop variables based on the destination rectangle to be calculated.
  int dx = destRect.x;
  int dy = destRect.y;
  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];

  // Precalculate the y positions and store them in an array.
  int[] yfracvalues = new int[dheight];
  // Precalculate the x positions and store them in an array.
  int[] xfracvalues = new int[dwidth];

  long syNum = dy, syDenom = 1;

  // Subtract the X translation factor sy -= transY
  syNum = syNum * transYRationalDenom - transYRationalNum * syDenom;
  syDenom *= transYRationalDenom;
 
  // Add 0.5
  syNum = 2 * syNum + syDenom;
  syDenom *= 2;

  // Multply by invScaleX
  syNum *= invScaleYRationalNum;
  syDenom *= invScaleYRationalDenom;

  // Subtract 0.5
  syNum = 2 * syNum - syDenom;
  syDenom *= 2;

  // Separate the x source coordinate into integer and fractional part
  int srcYInt = Rational.floor(syNum , syDenom);
  long srcYFrac = syNum % syDenom;
  if (srcYInt < 0) {
      srcYFrac = syDenom + srcYFrac;
  }

  // Normalize - Get a common denominator for the fracs of
  // src and invScaleY
  long commonYDenom = syDenom * invScaleYRationalDenom;
  srcYFrac *= invScaleYRationalDenom;
  long newInvScaleYFrac = invScaleYFrac * syDenom;

  long sxNum = dx, sxDenom = 1;

  // Subtract the X translation factor sx -= transX
  sxNum = sxNum * transXRationalDenom - transXRationalNum * sxDenom;
  sxDenom *= transXRationalDenom;
 
  // Add 0.5
  sxNum = 2 * sxNum + sxDenom;
  sxDenom *= 2;

  // Multply by invScaleX
  sxNum *= invScaleXRationalNum;
  sxDenom *= invScaleXRationalDenom;

  // Subtract 0.5
  sxNum = 2 * sxNum - sxDenom;
  sxDenom *= 2;

  // Separate the x source coordinate into integer and fractional part
  // int part is floor(sx), frac part is sx - floor(sx)
  int srcXInt = Rational.floor(sxNum , sxDenom);
  long srcXFrac = sxNum % sxDenom;
  if (srcXInt < 0) {
      srcXFrac = sxDenom + srcXFrac;
  }
 
  // Normalize - Get a common denominator for the fracs of
  // src and invScaleX
  long commonXDenom = sxDenom * invScaleXRationalDenom;
  srcXFrac *= invScaleXRationalDenom;
  long newInvScaleXFrac = invScaleXFrac * sxDenom;

  for (int i=0; i<dwidth; i++) {
       xpos[i] = (srcXInt - srcRectX) * srcPixelStride;
      xfracvalues[i] = (int)(((float)srcXFrac/(float)commonXDenom) * one);

      // Move onto the next source pixel.

      // Add the integral part of invScaleX to the integral part
      // of srcX
      srcXInt += invScaleXInt;

      // Add the fractional part of invScaleX to the fractional part
      // of srcX
      srcXFrac += newInvScaleXFrac;

      // If the fractional part is now greater than equal to the
      // denominator, divide so as to reduce the numerator to be less
      // than the denominator and add the overflow to the integral part.
      if (srcXFrac >= commonXDenom) {
    srcXInt += 1;
    srcXFrac -= commonXDenom;
      }
  }

  for (int i = 0; i < dheight; i++) {

      // Calculate the source position in the source data array.
      ypos[i] = (srcYInt - srcRectY) * srcScanlineStride;

      // Calculate the yfrac value
      yfracvalues[i] = (int)(((float)srcYFrac/(float)commonYDenom) * one);

      // Move onto the next source pixel.

      // Add the integral part of invScaleY to the integral part
      // of srcY
      srcYInt += invScaleYInt;

      // Add the fractional part of invScaleY to the fractional part
      // of srcY
      srcYFrac += newInvScaleYFrac;

      // If the fractional part is now greater than equal to the
      // denominator, divide so as to reduce the numerator to be less
      // than the denominator and add the overflow to the integral part.
      if (srcYFrac >= commonYDenom) {
    srcYInt += 1;
    srcYFrac -= commonYDenom;
      }
  }

        switch (dstAccessor.getDataType()) {

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

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

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

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

  case DataBuffer.TYPE_FLOAT:
      initTableDataF();
      floatLoop(srcAccessor, destRect, dstAccessor,
      xpos, ypos, xfracvalues, yfracvalues);
      break;

  case DataBuffer.TYPE_DOUBLE:
      initTableDataD();
      doubleLoop(srcAccessor, destRect, dstAccessor,
      xpos, ypos, xfracvalues, yfracvalues);
      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 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();
        int dstPixelStrideImag = 1;
        int dstLineStrideImag = destRect.width;
        if(complexDst) {
            dstPixelStrideImag = dstPixelStride;
            dstLineStrideImag = dstScanlineStride;
        }

        // Set indices and strides for image bands (real/imaginary).
        int srcBandIndex = 0;
        int srcBandStride = complexSrc ? 2 : 1;
        int dstBandIndex = 0;
        int dstBandStride = complexDst ? 2 : 1;

        // Get the number of components.
        int numComponents = (complexDst ?
                             dest.getSampleModel().getNumBands() / 2 :
                             dest.getSampleModel().getNumBands());

        // Loop over the components.
        for(int comp = 0; comp < numComponents; comp++) {
            // Get the real source data for this component.
            Object srcReal = srcAccessor.getDataArray(srcBandIndex);

            // Get the imaginary source data for this component if present.
            Object srcImag = null;
            if(complexSrc) {
                srcImag = srcAccessor.getDataArray(srcBandIndex+1);
            }

            // Specify the destination components.
            Object dstReal = dstAccessor.getDataArray(dstBandIndex);
            Object dstImag = null;
            if(complexDst) {
                dstImag = dstAccessor.getDataArray(dstBandIndex+1);
            } else {
                // Need to allocate an array for the entire band anyway
                // even though the destination is real because it is needed
                // for storage of the result of the row transforms.
                if(dstDataType == DataBuffer.TYPE_FLOAT) {
                    dstImag = new float[destRect.width*destRect.height];
                } else {
                    dstImag = new double[destRect.width*destRect.height];
                }
            }

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

                // Initialize the source offsets for this component.
                int srcOffsetReal =
                    srcAccessor.getBandOffset(srcBandIndex);
                int srcOffsetImag = 0;
                if(complexSrc) {
                    srcOffsetImag =
                        srcAccessor.getBandOffset(srcBandIndex+1);
                }

                // Initialize destination offsets and strides.
                int dstOffsetReal =
                    dstAccessor.getBandOffset(dstBandIndex);
                int dstOffsetImag = 0;
                if(complexDst) {
                    dstOffsetImag =
                        dstAccessor.getBandOffset(dstBandIndex+1);
                }

                // Perform the row transforms.
                for(int row = 0; row < srcHeight; row++) {
                    // Set the input data of the FFT.
                    fft.setData(srcDataType,
                                srcReal, srcOffsetReal, srcPixelStride,
                                srcImag, srcOffsetImag, srcPixelStride,
                                srcWidth);

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

                    // Get the output data of the FFT.
                    fft.getData(dstDataType,
                                dstReal, dstOffsetReal, dstPixelStride,
                                dstImag, dstOffsetImag, dstPixelStrideImag);

                    // Increment the data offsets.
                    srcOffsetReal += srcScanlineStride;
                    srcOffsetImag += srcScanlineStride;
                    dstOffsetReal += dstScanlineStride;
                    dstOffsetImag += dstLineStrideImag;
                }
            }

            if(destRect.width == 1) { // destRect.height > 1
                // NB 1) destRect.height has to be greater than one or this
                // would be the degenerate case of a single point which is
                // handled above. 2) There is no need to do setLength() on
                // the FFT object here as the length will already have been
                // set to the maximum of destRect.width amd destRect.height
                // which must be destRect.height.

                // Initialize the source offsets for this component.
                int srcOffsetReal =
                    srcAccessor.getBandOffset(srcBandIndex);
                int srcOffsetImag = 0;
                if(complexSrc) {
                    srcOffsetImag =
                        srcAccessor.getBandOffset(srcBandIndex+1);
                }

                // Initialize destination offsets and strides.
                int dstOffsetReal =
                    dstAccessor.getBandOffset(dstBandIndex);
                int dstOffsetImag = 0;
                if(complexDst) {
                    dstOffsetImag =
                        dstAccessor.getBandOffset(dstBandIndex+1);
                }

                // Set the input data of the FFT.
                fft.setData(srcDataType,
                            srcReal, srcOffsetReal, srcScanlineStride,
                            srcImag, srcOffsetImag, srcScanlineStride,
                            srcHeight);

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

                // Get the output data of the FFT.
                fft.getData(dstDataType,
                            dstReal, dstOffsetReal, dstScanlineStride,
                            dstImag, dstOffsetImag, dstLineStrideImag);
            } else if(destRect.height > 1) { // destRect.width > 1
                // Reset the FFT length.
                fft.setLength(getHeight());

                // Initialize destination offsets and strides.
                int dstOffsetReal =
                    dstAccessor.getBandOffset(dstBandIndex);
                int dstOffsetImag = 0;
                if(complexDst) {
                    dstOffsetImag =
                        dstAccessor.getBandOffset(dstBandIndex+1);
                }

                // Perform the column transforms.
                for(int col = 0; col < destRect.width; col++) {
                    // Set the input data of the FFT.
                    fft.setData(dstDataType,
                                dstReal, dstOffsetReal, dstScanlineStride,
                                dstImag, dstOffsetImag, dstLineStrideImag,
                                destRect.height);

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

                    // Get the output data of the FFT.
                    fft.getData(dstDataType,
                                dstReal, dstOffsetReal, dstScanlineStride,
                                complexDst ? dstImag : null,
                                dstOffsetImag, dstLineStrideImag);

                    // Increment the data offset.
                    dstOffsetReal += dstPixelStride;
                    dstOffsetImag += dstPixelStrideImag;
                }
            }

            // Increment the indices of the real bands in both images.
            srcBandIndex += srcBandStride;
            dstBandIndex += dstBandStride;
        }

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

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

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

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

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

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

        int srcRectY = srcRect.y;

        //
        // Get data for the source rectangle & the destination rectangle
        //
        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:
            int dstNumBands = dstAccessor.getNumBands();
            if (dstNumBands == 1) {
                byteLoop_1band(srcAccessor,
                               destRect,
                               srcRectX,
                               srcRectY,
                               dstAccessor);
            } else if (dstNumBands == 3) {
                byteLoop_3band(srcAccessor,
                               destRect,
                               srcRectX,
                               srcRectY,
                               dstAccessor);
            } else {
                byteLoop(srcAccessor,
                         destRect,
                         srcRectX,
                         srcRectY,
                         dstAccessor);
            }
            break;

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

        case DataBuffer.TYPE_SHORT:
        case DataBuffer.TYPE_USHORT:
            shortLoop(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

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.