Package java.awt.image

Examples of java.awt.image.Raster


     */
    protected void computeRect(Raster[] sources,
                               WritableRaster dest,
                               Rectangle destRect) {

  Raster source = sources[0];

  Rectangle srcRect = mapDestRect(destRect,0);

        // Hack: derive the source format tag as if it was writing to
        // a destination with the same layout as itself.
View Full Code Here


     * @param destRect  the rectangle within this OpImage to be processed.
     */
    protected void computeRect(Raster[] sources,
                               WritableRaster dest,
                               Rectangle destRect) {
        Raster source = sources[0];
        int formatTag = MediaLibAccessor.findCompatibleTag(sources, dest);

  // For PointOpImages, srcRect is the same as destRect
        MediaLibAccessor srcAccessor = new MediaLibAccessor(source, destRect,
                  formatTag);
View Full Code Here

     * the same.
     */
    protected void computeRect(Raster[] sources,
                               WritableRaster dest,
                               Rectangle destRect) {
        Raster source = sources[0];

        /* Find the mediaLib data tag. */
        int formatTag = MediaLibAccessor.findCompatibleTag(sources, dest);

        MediaLibAccessor srcMA =
            new MediaLibAccessor(source, source.getBounds(), formatTag);
        MediaLibAccessor dstMA =
            new MediaLibAccessor(dest, destRect, formatTag);

        mediaLibImage[] srcMLI = srcMA.getMediaLibImages();
        mediaLibImage[] dstMLI = dstMA.getMediaLibImages();

        switch (dstMA.getDataType()) {
        case DataBuffer.TYPE_BYTE:
        case DataBuffer.TYPE_USHORT:
        case DataBuffer.TYPE_SHORT:
        case DataBuffer.TYPE_INT:
            if (setBackground)
                for (int i = 0 ; i < dstMLI.length; i++) {
                    Image.PolynomialWarp2(dstMLI[i], srcMLI[i],
                                         xCoeffs, yCoeffs,
                                         destRect.x,
                                         destRect.y,
                                         source.getMinX(),
                                         source.getMinY(),
                                         preScaleX, preScaleY,
                                         postScaleX, postScaleY,
                                         filter,
                                         Constants.MLIB_EDGE_DST_NO_WRITE,
                                         intBackgroundValues);
              }
            else
                for (int i = 0 ; i < dstMLI.length; i++) {
                    Image.PolynomialWarp(dstMLI[i], srcMLI[i],
                                         xCoeffs, yCoeffs,
                                         destRect.x,
                                         destRect.y,
                                         source.getMinX(),
                                         source.getMinY(),
                                         preScaleX, preScaleY,
                                         postScaleX, postScaleY,
                                         filter,
                                         Constants.MLIB_EDGE_DST_NO_WRITE);
                    MlibUtils.clampImage(dstMLI[i], getColorModel());
                }
            break;

        case DataBuffer.TYPE_FLOAT:
        case DataBuffer.TYPE_DOUBLE:
            if (setBackground)
                for (int i = 0 ; i < dstMLI.length; i++) {
                    Image.PolynomialWarp2_Fp(dstMLI[i], srcMLI[i],
                                            xCoeffs, yCoeffs,
                                            destRect.x,
                                            destRect.y,
                                            source.getMinX(),
                                            source.getMinY(),
                                            preScaleX, preScaleY,
                                            postScaleX, postScaleY,
                                            filter,
                                            Constants.MLIB_EDGE_DST_NO_WRITE,
                                            backgroundValues);
                }
            else
                for (int i = 0 ; i < dstMLI.length; i++) {
                    Image.PolynomialWarp_Fp(dstMLI[i], srcMLI[i],
                                            xCoeffs, yCoeffs,
                                            destRect.x,
                                            destRect.y,
                                            source.getMinX(),
                                            source.getMinY(),
                                            preScaleX, preScaleY,
                                            postScaleX, postScaleY,
                                            filter,
                                            Constants.MLIB_EDGE_DST_NO_WRITE);
                }
View Full Code Here

     * @param destRect the rectangle within dest to be processed.
     */
    protected void computeRect(Raster[] sources,
                               WritableRaster dest,
                               Rectangle destRect) {
        Raster source = sources[0];
        Rectangle srcRect = mapDestRect(destRect, 0);
        int formatTag = MediaLibAccessor.findCompatibleTag(sources,dest);
        MediaLibAccessor srcAccessor =
View Full Code Here

     */
    protected void computeRect(Raster[] sources,
                               WritableRaster dest,
                               Rectangle destRect) {

        Raster source = sources[0];
        Rectangle srcRect = mapDestRect(destRect, 0);

        int formatTag = MediaLibAccessor.findCompatibleTag(sources,dest);
        MediaLibAccessor srcAccessor =
View Full Code Here

  InterpolationTable jtable = (InterpolationTable)interp;

  // The Medialib InterpolationTable class equivalent
  mediaLibImageInterpTable mlibInterpTable;

  Raster source = sources[0];
  Rectangle srcRect = source.getBounds();
 
        int formatTag = MediaLibAccessor.findCompatibleTag(sources, dest);

        MediaLibAccessor srcAccessor = new MediaLibAccessor(source, srcRect,
                  formatTag);
View Full Code Here

     * @param destRect  the rectangle within this OpImage to be processed.
     */
    protected void computeRect(Raster[] sources,
                               WritableRaster dest,
                               Rectangle destRect) {
        Raster source = sources[0];
        Rectangle srcRect = mapDestRect(destRect, 0);

        int formatTag = MediaLibAccessor.findCompatibleTag(sources,dest);

        MediaLibAccessor srcAccessor =
View Full Code Here

        int endTileY = YToTileY(xsect.y + xsect.height - 1);

        if (startTileX == endTileX && startTileY == endTileY &&
            getTileRect(startTileX, startTileY).contains(region)) {
            // Requested region is within a single tile.
            Raster tile = getTile(startTileX, startTileY);

            if(this instanceof WritableRenderedImage) {
                // Returned Raster must not change if the corresponding
                // image data are modified so if this image is mutable
                // a copy must be created.
                SampleModel sm = tile.getSampleModel();
                if(sm.getWidth() != region.width ||
                   sm.getHeight() != region.height) {
                    sm = sm.createCompatibleSampleModel(region.width,
                                                        region.height);
                }
                WritableRaster destinationRaster =
                    createWritableRaster(sm, region.getLocation());
                Raster sourceRaster =
                    tile.getBounds().equals(region) ?
                    tile : tile.createChild(region.x, region.y,
                                            region.width, region.height,
                                            region.x, region.y,
                                            null);
                JDKWorkarounds.setRect(destinationRaster, sourceRaster);
                return destinationRaster;
            } else {
                // Image is immutable so returning the tile or a child
                // thereof is acceptable.
                return tile.getBounds().equals(region) ?
                    tile : tile.createChild(region.x, region.y,
                                            region.width, region.height,
                                            region.x, region.y,
                                            null);
            }
        } else {
            // Extract a region crossing tiles into a new WritableRaster
            WritableRaster dstRaster;
            SampleModel srcSM = getSampleModel();
            int dataType = srcSM.getDataType();
            int nbands = srcSM.getNumBands();
            boolean isBandChild = false;

            ComponentSampleModel csm = null;
            int[] bandOffs = null;

            boolean fastCobblePossible = false;
            if (srcSM instanceof ComponentSampleModel) {
                csm = (ComponentSampleModel)srcSM;
                int ps = csm.getPixelStride();
                boolean isBandInt = (ps == 1 && nbands > 1);
                isBandChild = (ps > 1 && nbands != ps);
                if ( (!isBandChild) && (!isBandInt)) {
                    bandOffs = csm.getBandOffsets();
                    int i;
                    for (i=0; i<nbands; i++) {
                        if (bandOffs[i] >= nbands) {
                            break;
                        }
                    }
                    if (i == nbands) {
                        fastCobblePossible = true;
                    }
                }
            }

            if (fastCobblePossible) {
                // For acceptable cases of ComponentSampleModel,
                // use an optimized cobbler which directly accesses the
                // tile DataBuffers, using arraycopy whenever possible.
                try {
                    SampleModel interleavedSM =
                        RasterFactory.createPixelInterleavedSampleModel(
                            dataType,
                            region.width,
                            region.height,
                            nbands,
                            region.width*nbands,
                            bandOffs);
                    dstRaster = createWritableRaster(interleavedSM,
                                                     region.getLocation());
                } catch (IllegalArgumentException e) {
                    throw new IllegalArgumentException(
                        JaiI18N.getString("PlanarImage2"));
                }

                switch (dataType) {
                  case DataBuffer.TYPE_BYTE:
                    cobbleByte(region, dstRaster);
                    break;
                  case DataBuffer.TYPE_SHORT:
                    cobbleShort(region, dstRaster);
                    break;
                  case DataBuffer.TYPE_USHORT:
                    cobbleUShort(region, dstRaster);
                    break;
                  case DataBuffer.TYPE_INT:
                    cobbleInt(region, dstRaster);
                    break;
                  case DataBuffer.TYPE_FLOAT:
                    cobbleFloat(region, dstRaster);
                    break;
                  case DataBuffer.TYPE_DOUBLE:
                    cobbleDouble(region, dstRaster);
                    break;
                  default:
                    break;
                }
            } else {
                SampleModel sm = sampleModel;
                if(sm.getWidth() != region.width ||
                   sm.getHeight() != region.height) {
                    sm = sm.createCompatibleSampleModel(region.width,
                                                        region.height);
                }

                try {
                    dstRaster = createWritableRaster(sm,
                                                     region.getLocation());
                } catch (IllegalArgumentException e) {
                    throw new IllegalArgumentException(
                        JaiI18N.getString("PlanarImage2"));
                }

                for (int j = startTileY; j <= endTileY; j++) {
                    for (int i = startTileX; i <= endTileX; i++) {
                        Raster tile = getTile(i, j);

                        Rectangle subRegion = region.intersection(
                                              tile.getBounds());
                        Raster subRaster =
                            tile.createChild(subRegion.x,
                                             subRegion.y,
                                             subRegion.width,
                                             subRegion.height,
                                             subRegion.x,
                                             subRegion.y,
                                             null);

      if (sm instanceof ComponentSampleModel &&
                            isBandChild) {
                            // Need to handle this case specially, since
                            // setDataElements will not copy band child images
                            switch (sm.getDataType()) {
                              case DataBuffer.TYPE_FLOAT:
                                dstRaster.setPixels(
                                  subRegion.x,
                                  subRegion.y,
                                  subRegion.width,
                                  subRegion.height,
                                  subRaster.getPixels(
                                    subRegion.x,
                                    subRegion.y,
                                    subRegion.width,
                                    subRegion.height,
                                    new float[nbands*subRegion.width*subRegion.height]));
                                break;
                              case DataBuffer.TYPE_DOUBLE:
                                dstRaster.setPixels(
                                  subRegion.x,
                                  subRegion.y,
                                  subRegion.width,
                                  subRegion.height,
                                  subRaster.getPixels(
                                    subRegion.x,
                                    subRegion.y,
                                    subRegion.width,
                                    subRegion.height,
                                    new double[nbands*subRegion.width*subRegion.height]));
                                break;
                              default:
                                dstRaster.setPixels(
                                  subRegion.x,
                                  subRegion.y,
                                  subRegion.width,
                                  subRegion.height,
                                  subRaster.getPixels(
                                    subRegion.x,
                                    subRegion.y,
                                    subRegion.width,
                                    subRegion.height,
                                    new int[nbands*subRegion.width*subRegion.height]));
 
View Full Code Here

     * the same.
     */
    protected void computeRect(Raster[] sources,
                               WritableRaster dest,
                               Rectangle destRect) {
        Raster source = sources[0];

        /* Find the mediaLib data tag. */
        int formatTag = MediaLibAccessor.findCompatibleTag(sources, dest);

        MediaLibAccessor srcMA =
            new MediaLibAccessor(source, source.getBounds(), formatTag);
        MediaLibAccessor dstMA =
            new MediaLibAccessor(dest, destRect, formatTag);

        mediaLibImage[] srcMLI = srcMA.getMediaLibImages();
        mediaLibImage[] dstMLI = dstMA.getMediaLibImages();

        switch (dstMA.getDataType()) {
        case DataBuffer.TYPE_BYTE:
        case DataBuffer.TYPE_USHORT:
        case DataBuffer.TYPE_SHORT:
        case DataBuffer.TYPE_INT:
       if (mlibInterpTableI==null){
          InterpolationTable jtable = (InterpolationTable)interp;
          mlibInterpTableI =
      new mediaLibImageInterpTable(Constants.MLIB_INT,
                 jtable.getWidth(),
                 jtable.getHeight(),
                 jtable.getLeftPadding(),
                 jtable.getTopPadding(),
                 jtable.getSubsampleBitsH(),
                 jtable.getSubsampleBitsV(),
                 jtable.getPrecisionBits(),
                 jtable.getHorizontalTableData(),
                 jtable.getVerticalTableData());

      }

            if (setBackground)
                for (int i = 0 ; i < dstMLI.length; i++) {
                    Image.PolynomialWarpTable2(dstMLI[i], srcMLI[i],
                                               xCoeffs, yCoeffs,
                                               destRect.x,
                                               destRect.y,
                                               source.getMinX(),
                                               source.getMinY(),
                                               preScaleX, preScaleY,
                                               postScaleX, postScaleY,
                                               mlibInterpTableI,
                                               Constants.MLIB_EDGE_DST_NO_WRITE,
                                               intBackgroundValues);
                }
            else
                for (int i = 0 ; i < dstMLI.length; i++) {
                    Image.PolynomialWarpTable(dstMLI[i], srcMLI[i],
                                              xCoeffs, yCoeffs,
                                              destRect.x,
                                              destRect.y,
                                              source.getMinX(),
                                              source.getMinY(),
                                              preScaleX, preScaleY,
                                              postScaleX, postScaleY,
                                              mlibInterpTableI,
                                              Constants.MLIB_EDGE_DST_NO_WRITE);
                    MlibUtils.clampImage(dstMLI[i], getColorModel());
                }
            break;

        case DataBuffer.TYPE_FLOAT:
      if (mlibInterpTableF==null){
          InterpolationTable jtable = (InterpolationTable)interp;
          mlibInterpTableF =
        new mediaLibImageInterpTable(Constants.MLIB_FLOAT,
                                             jtable.getWidth(),
                                             jtable.getHeight(),
                                             jtable.getLeftPadding(),
                                             jtable.getTopPadding(),
                                             jtable.getSubsampleBitsH(),
                                             jtable.getSubsampleBitsV(),
                                             jtable.getPrecisionBits(),
                                             jtable.getHorizontalTableDataFloat(),
                                             jtable.getVerticalTableDataFloat());

      }

            if (setBackground)
                for (int i = 0 ; i < dstMLI.length; i++) {
                    Image.PolynomialWarpTable2_Fp(dstMLI[i], srcMLI[i],
                                                 xCoeffs, yCoeffs,
                                                 destRect.x,
                                                 destRect.y,
                                                 source.getMinX(),
                                                 source.getMinY(),
                                                 preScaleX, preScaleY,
                                                 postScaleX, postScaleY,
                                                 mlibInterpTableD,
                                                 Constants.MLIB_EDGE_DST_NO_WRITE,
                                                 backgroundValues);
          }
            else
                for (int i = 0 ; i < dstMLI.length; i++) {
                    Image.PolynomialWarpTable_Fp(dstMLI[i], srcMLI[i],
                                                 xCoeffs, yCoeffs,
                                                 destRect.x,
                                                 destRect.y,
                                                 source.getMinX(),
                                                 source.getMinY(),
                                                 preScaleX, preScaleY,
                                                 postScaleX, postScaleY,
                                                 mlibInterpTableD,
                                                 Constants.MLIB_EDGE_DST_NO_WRITE);
          }
            break;


        case DataBuffer.TYPE_DOUBLE:
        if (mlibInterpTableD == null){
          InterpolationTable jtable = (InterpolationTable)interp;
          mlibInterpTableD =
      new mediaLibImageInterpTable(Constants.MLIB_DOUBLE,
                                             jtable.getWidth(),
                                             jtable.getHeight(),
                                             jtable.getLeftPadding(),
                                             jtable.getTopPadding(),
                                             jtable.getSubsampleBitsH(),
                                             jtable.getSubsampleBitsV(),
                                             jtable.getPrecisionBits(),
                                             jtable.getHorizontalTableDataDouble(),
                                             jtable.getVerticalTableDataDouble());
      }

            if (setBackground)
                for (int i = 0 ; i < dstMLI.length; i++) {
                    Image.PolynomialWarpTable2_Fp(dstMLI[i], srcMLI[i],
                                                 xCoeffs, yCoeffs,
                                                 destRect.x,
                                                 destRect.y,
                                                 source.getMinX(),
                                                 source.getMinY(),
                                                 preScaleX, preScaleY,
                                                 postScaleX, postScaleY,
                                                 mlibInterpTableD,
                                                 Constants.MLIB_EDGE_DST_NO_WRITE,
                                                 backgroundValues);
                }
            else
                for (int i = 0 ; i < dstMLI.length; i++) {
                    Image.PolynomialWarpTable_Fp(dstMLI[i], srcMLI[i],
                                                 xCoeffs, yCoeffs,
                                                 destRect.x,
                                                 destRect.y,
                                                 source.getMinX(),
                                                 source.getMinY(),
                                                 preScaleX, preScaleY,
                                                 postScaleX, postScaleY,
                                                 mlibInterpTableD,
                                                 Constants.MLIB_EDGE_DST_NO_WRITE);
                }
View Full Code Here

        RasterFormatTag dstTag =
            new RasterFormatTag(raster.getSampleModel(),tagID);

        for (int ty = startTileY; ty <= endTileY; ty++) {
            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(raster, subRegion,
                                                      dstTag, null);
View Full Code Here

TOP

Related Classes of java.awt.image.Raster

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.