Examples of Raster


Examples of java.awt.image.Raster

     * @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

Examples of java.awt.image.Raster

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

Examples of java.awt.image.Raster

  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

Examples of java.awt.image.Raster

     * @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

Examples of java.awt.image.Raster

        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

Examples of java.awt.image.Raster

     * 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

Examples of java.awt.image.Raster

        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

Examples of java.awt.image.Raster

        if(tileIndices == null) {
            throw new IllegalArgumentException(JaiI18N.getString("Generic0"));
        }

        int size = tileIndices.length;
        Raster tiles[] = new Raster[size];

        for (int i = 0; i < tileIndices.length; i++) {
            Point p = tileIndices[i];
            tiles[i] = getTile(p.x,p.y);
        }
View Full Code Here

Examples of java.awt.image.Raster

        Rectangle tileBounds = new Rectangle(xmin, ymin,
                 getTileWidth(),
                 getTileHeight());
        tileBounds = tileBounds.intersection(imageBounds);

        Raster tile = getTile(i, j);

        Rectangle realTileBounds = new Rectangle(tile.getMinX(),
                     tile.getMinY(),
                     tile.getWidth(),
                     tile.getHeight());
        System.out.println("Tile bounds (actual)   = " + realTileBounds);
        System.out.println("Tile bounds (computed) = " + tileBounds);

        xmin = tileBounds.x;
        ymin = tileBounds.y;
        int xmax = tileBounds.x + tileBounds.width - 1;
        int ymax = tileBounds.y + tileBounds.height - 1;
        int numBands = getSampleModel().getNumBands();
        int[] val = new int[numBands];
        int pi, pj;

        for (pj = ymin; pj <= ymax; pj++) {
            for (pi = xmin; pi <= xmax; pi++) {
            tile.getPixel(pi, pj, val);
            if (numBands == 1) {
                System.out.print("(" + val[0] + ") ");
            } else if (numBands == 3) {
                System.out.print("(" + val[0] + "," + val[1] +
                                     "," + val[2] + ") ");
View Full Code Here

Examples of java.awt.image.Raster

        int xOrg, yOrg;
        int srcX1, srcY1, srcX2, srcY2, srcW, srcH;

        for (int y = startY; y <= endY; y++) {
            for (int x = startX; x <= endX; x++) {
                Raster tile = getTile(x, y);
                if (tile == null) {
                    //
                    // Out-of-bounds tile. Zero fill will be supplied
                    // since dstRaster is initialized to zero
                    //
                    continue;
                }

                if (! tileParamsSet) {
                    //
                    // These are constant for all tiles,
                    // so only set them once.
                    //
                    srcSM = (ComponentSampleModel)tile.getSampleModel();
                    srcPS = srcSM.getPixelStride();
                    srcSS = srcSM.getScanlineStride();
                    tileParamsSet = true;
                }

                //
                //  Intersect the tile and the rectangle
                //  Avoid use of Math.min/max
                //
                yOrg  = y*tileHeight + tileGridYOffset;
                srcY1 = yOrg;
                srcY2 = srcY1 + tileHeight - 1;
                if (bounds.y > srcY1) srcY1 = bounds.y;
                if (rectYend < srcY2) srcY2 = rectYend;
                srcH = srcY2 - srcY1 + 1;

                xOrg  = x*tileWidth + tileGridXOffset;
                srcX1 = xOrg;
                srcX2 = srcX1 + tileWidth - 1;
                if (bounds.x > srcX1) srcX1 = bounds.x;
                if (rectXend < srcX2) srcX2 = rectXend;
                srcW = srcX2 - srcX1 + 1;

                int dstX = srcX1 - bounds.x;
                int dstY = srcY1 - bounds.y;

                // Get the actual data array
                DataBufferByte srcDB = (DataBufferByte)tile.getDataBuffer();
                byte[] src = srcDB.getData();

                int nsamps = srcW * srcPS;
                boolean useArrayCopy = (nsamps >= MIN_ARRAYCOPY_SIZE);

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.