Package java.awt.image

Examples of java.awt.image.DataBufferInt


  private static WritableRenderedImage toImage(RgbImage rgb) {
    WritableRenderedImage im = new BufferedImage(
        rgb.getWidth(),
        rgb.getHeight(),
        BufferedImage.TYPE_INT_RGB);
    DataBufferInt dbi = new DataBufferInt(
        rgb.getData(),
        rgb.getHeight() * rgb.getWidth());
    Raster r = Raster.createRaster(
        im.getSampleModel(),
        dbi,
View Full Code Here


        // Access raster internal int array. Because we use a DirectColorModel,
        // we know the DataBuffer is of type DataBufferInt and the SampleModel
        // is SinglePixelPackedSampleModel.
        // Adjust for initial offset in DataBuffer and also for the scanline
        // stride.
        DataBufferInt rasterDB = (DataBufferInt)raster.getDataBuffer();
        int[] pixels = rasterDB.getBankData()[0];
        int off = rasterDB.getOffset();
        int scanlineStride = ((SinglePixelPackedSampleModel)
                              raster.getSampleModel()).getScanlineStride();
        int adjust = scanlineStride - w;
       
        fillRaster(pixels, off, adjust, x, y, w, h); // delegate to subclass
View Full Code Here

      {
//        if (true)
        {
          // optimized, don't copy data or iterate through pixels:
          final int[] bytes = (int[]) buffer.getData();
          final DataBufferInt db = new DataBufferInt(new int[][] {bytes}, bytes.length);
          final SinglePixelPackedSampleModel sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT, w, h, new int[] {redMask, greenMask, blueMask});
          final WritableRaster r = Raster.createWritableRaster(sm, db, new Point(0, 0));
         
                  final ColorModel colorModel = new DirectColorModel(24,
                            redMask,   // Red
View Full Code Here

            byte[] data = byteBuffer.getData();
            System.arraycopy( finalData, 0, data, 0, data.length );
        }
        else if( rasterBuffer instanceof DataBufferInt )
        {
            DataBufferInt byteBuffer = (DataBufferInt)rasterBuffer;
            int[] data = byteBuffer.getData();
            for( int i=0; i<finalData.length; i++ )
            {
                data[i] = (finalData[i]+256)%256;
            }
        }
View Full Code Here

            dataBuffer =
                new DataBufferUShort((short[][])dataArray, size, offsets);
            break;
        case DataBuffer.TYPE_INT:
            dataBuffer =
                new DataBufferInt((int[][])dataArray, size, offsets);
            break;
        case DataBuffer.TYPE_FLOAT:
            dataBuffer =
                DataBufferUtils.createDataBufferFloat((float[][])dataArray, size, offsets);
            break;
View Full Code Here

        case DataBuffer.TYPE_SHORT:
            d = new DataBufferShort(size);
            break;

        case DataBuffer.TYPE_INT:
            d = new DataBufferInt(size);
            break;

        case DataBuffer.TYPE_FLOAT:
            d = DataBufferUtils.createDataBufferFloat(size);
            break;
View Full Code Here

        case DataBuffer.TYPE_SHORT:
            d = new DataBufferShort(size, banks);
            break;

        case DataBuffer.TYPE_INT:
            d = new DataBufferInt(size, banks);
            break;

        case DataBuffer.TYPE_FLOAT:
            d = DataBufferUtils.createDataBufferFloat(size, banks);
            break;
View Full Code Here

            dataBuffer =
                new DataBufferUShort((short[][])dataArray, size, offsets);
            break;
        case DataBuffer.TYPE_INT:
            dataBuffer =
                new DataBufferInt((int[][])dataArray, size, offsets);
            break;
        case DataBuffer.TYPE_FLOAT:
            dataBuffer =
                DataBufferUtils.createDataBufferFloat((float[][])dataArray, size, offsets);
            break;
View Full Code Here

        int endY = YToTileY(rectYend);

        //
        //  Get parameters of destination raster
        //
        DataBufferInt dstDB = (DataBufferInt)dstRaster.getDataBuffer();
        int[] dst           = dstDB.getData();
        int dstPS            = dstSM.getPixelStride();
        int dstSS            = dstSM.getScanlineStride();

        boolean tileParamsSet = false;
        ComponentSampleModel srcSM = null;
        int srcPS=0, srcSS=0;
        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
                DataBufferInt srcDB = (DataBufferInt)tile.getDataBuffer();
                int[] src = srcDB.getData();

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

                int ySrcIdx = (srcY1 - yOrg)*srcSS + (srcX1 - xOrg)*srcPS;
 
View Full Code Here

            break;
        case DataBuffer.TYPE_USHORT:
            dataBuffer = new DataBufferUShort(size, numBanks);
            break;
        case DataBuffer.TYPE_INT:
            dataBuffer = new DataBufferInt(size, numBanks);
            break;
        case DataBuffer.TYPE_SHORT:
            dataBuffer = new DataBufferShort(size, numBanks);
            break;
        case DataBuffer.TYPE_FLOAT:
View Full Code Here

TOP

Related Classes of java.awt.image.DataBufferInt

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.