Examples of Raster


Examples of java.awt.image.Raster

        if (owner == null) {
            throw new IllegalArgumentException("Null owner");
        }

        // Eventual tile to be returned.
        Raster tile = null;

        // Get the tile's unique ID.
        Object tileID = tileKey(owner, tileX, tileY);

        // Set the computation flag and initialize or retrieve the tile cache.
View Full Code Here

Examples of java.awt.image.Raster

        int yIDNew = yTiles[yLocal];

        if ((xIDNew != xID) || (yIDNew != yID) || (dataBuffer == null)) {
            xID = xIDNew;
            yID = yIDNew;
            Raster tile = im.getTile(xID, yID);

            this.dataBuffer = tile.getDataBuffer();
            dataBufferChanged();

            this.bandOffsets = dataBuffer.getOffsets();
        }
    }
View Full Code Here

Examples of java.awt.image.Raster

        output.write(0); // TypeField
        output.write(0); // FixHeaderField
        output.write(intToMultiByte(width)); // width
        output.write(intToMultiByte(height)); // height

        Raster tile = null;

        // If the data are not formatted nominally then reformat.
        if(sm.getDataType() != DataBuffer.TYPE_BYTE ||
           !(sm instanceof MultiPixelPackedSampleModel) ||
           ((MultiPixelPackedSampleModel)sm).getDataBitOffset() != 0) {
            MultiPixelPackedSampleModel mppsm =
                new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
                                                width, height, 1,
                                                (width + 7)/8, 0);
            WritableRaster raster =
                Raster.createWritableRaster(mppsm,
                                            new Point(im.getMinX(),
                                                      im.getMinY()));
            raster.setRect(im.getData());
            tile = raster;
        } else if(im.getNumXTiles() == 1 &&
                  im.getNumYTiles() == 1) {
            tile = im.getTile(im.getMinTileX(), im.getMinTileY());
        } else {
            tile = im.getData();
        }

        // Check whether the image is white-is-zero.
        boolean isWhiteZero = false;
        if(im.getColorModel() instanceof IndexColorModel) {
            IndexColorModel icm = (IndexColorModel)im.getColorModel();
            isWhiteZero =
                (icm.getRed(0) + icm.getGreen(0) + icm.getBlue(0)) >
                (icm.getRed(1) + icm.getGreen(1) + icm.getBlue(1));
        }

        // Get the line stride, bytes per row, and data array.
        int lineStride =
            ((MultiPixelPackedSampleModel)sm).getScanlineStride();
        int bytesPerRow = (width + 7)/8;
        byte[] bdata = ((DataBufferByte)tile.getDataBuffer()).getData();

        // Write the data.
        if(!isWhiteZero && lineStride == bytesPerRow) {
            // Write the entire image.
            output.write(bdata, 0, height*bytesPerRow);
 
View Full Code Here

Examples of java.awt.image.Raster

        prevYBoundary = Math.max(tileYStart, bounds.y);
        nextYBoundary = Math.min(tileYEnd, lastY);
    }
    
    protected void setDataBuffer() {
        Raster tile = im.getTile(tileX, tileY);
        this.dataBuffer = tile.getDataBuffer();

        int newSampleModelTranslateX = tile.getSampleModelTranslateX();
        int newSampleModelTranslateY = tile.getSampleModelTranslateY();
        localX += sampleModelTranslateX - newSampleModelTranslateX;
        localY += sampleModelTranslateY - newSampleModelTranslateY;

        this.sampleModelTranslateX = newSampleModelTranslateX;
        this.sampleModelTranslateY = newSampleModelTranslateY;
View Full Code Here

Examples of java.awt.image.Raster

  }

  ByteArrayInputStream bais = new ByteArrayInputStream(data);
        JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(bais);

        Raster ras = decoder.decodeAsRaster()
      .createTranslatedChild(location.x, location.y);
  extractParameters(decoder.getJPEGDecodeParam(),
        ras.getSampleModel().getNumBands());

  // set the original sample model to the decoded raster
  if (sm != null) {
      int minX = ras.getMinX();
      int minY = ras.getMinY();
      int h = ras.getHeight();
      int w = ras.getWidth();
      double[] buf = ras.getPixels(minX, minY, w, h, (double[])null);
      ras = RasterFactory.createWritableRaster(sm,
                 new Point(minX, minY));
      ((WritableRaster)ras).setPixels(minX, minY, w, h, buf);
  }
  return ras;
View Full Code Here

Examples of java.awt.image.Raster

                    row = minY + h - i -1;

                // Get the pixels
                Rectangle srcRect =
                    new Rectangle(minX, row, w, 1);
                Raster src = im.getData(srcRect);

                SampleModel sm1 = src.getSampleModel();
                int pos = 0;
                int startX = srcRect.x - src.getSampleModelTranslateX();
                int startY = srcRect.y - src.getSampleModelTranslateY();
                if (sm1 instanceof SinglePixelPackedSampleModel) {
                    SinglePixelPackedSampleModel sppsm =
                        (SinglePixelPackedSampleModel)sm1;
                    pos = sppsm.getOffset(startX, startY);
                }

                switch(dataType) {
                    case DataBuffer.TYPE_SHORT:
                    short[] sdata =
                        ((DataBufferShort)src.getDataBuffer()).getData();
        for (int m = 0; m < sdata.length; m++)
      writeWord(sdata[m]);
                    break;

                    case DataBuffer.TYPE_USHORT:
                    short[] usdata =
                        ((DataBufferUShort)src.getDataBuffer()).getData();
        for (int m = 0; m < usdata.length; m++)
      writeWord(usdata[m]);
                    break;

                    case DataBuffer.TYPE_INT:
                    int[] idata =
                        ((DataBufferInt)src.getDataBuffer()).getData();
        for (int m = 0; m < idata.length; m++)
      writeDWord(idata[m]);
                    break;
                }
      }
      return;
  }

  // palette
  if (isPalette == true) {

      // write palette
      switch(version) {

    // has 3 field entries
      case BMPEncodeParam.VERSION_2:

    for (int i=0; i<paletteEntries; i++) {
        output.write(b[i]);
        output.write(g[i]);
        output.write(r[i]);
    }
    break;

    // has 4 field entries
      default:

    for (int i=0; i<paletteEntries; i++) {
        output.write(b[i]);
        output.write(g[i]);
        output.write(r[i]);
        output.write(a[i]);
    }
    break;
      }
     
  } // else no palette
 
  // Writing of actual image data

  int scanlineBytes = w * numBands;

  // Buffer for up to 8 rows of pixels
  int[] pixels = new int[8 * scanlineBytes];

        // Also create a buffer to hold one line of the data
        // to be written to the file, so we can use array writes.
        byte[] bpixels = new byte[destScanlineBytes];

  int l;

  if (!isTopDown) {
      // Process 8 rows at a time so all but the first will have a
      // multiple of 8 rows.
      int lastRow = minY + h;

      for (int row = (lastRow-1); row >= minY; row -= 8) {
    // Number of rows being read
    int rows = Math.min(8, row - minY + 1);
 
    // Get the pixels
    Raster src = im.getData(new Rectangle(minX, row - rows + 1,
                  w, rows));

    src.getPixels(minX, row - rows + 1, w, rows, pixels);
   
    l = 0;   
   
    // Last possible position in the pixels array
    int max = scanlineBytes * rows - 1;

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

        // Beginning of each scanline in the pixels array   
        l = max - (i+1) * scanlineBytes + 1;

        writePixels(l, scanlineBytes, bitsPerPixel, pixels,
        bpixels, padding, numBands, icm);
    }
 

      }
     
  } else {
      // Process 8 rows at a time so all but the last will have a
      // multiple of 8 rows.
      int lastRow = minY + h;

      for (int row = minY; row < lastRow; row += 8) {
    int rows = Math.min(8, lastRow - row);
 
    // Get the pixels
    Raster src = im.getData(new Rectangle(minX, row,
                  w, rows));
    src.getPixels(minX, row, w, rows, pixels);

    l=0;   
    for (int i=0; i<rows; i++) {
       
        writePixels(l, scanlineBytes, bitsPerPixel, pixels,
View Full Code Here

Examples of javax.media.j3d.Raster

      // s'il d�sire une capture normale
      if (value == JOptionPane.YES_OPTION) {
        int width = canvas.getSize().width;
        int height = canvas.getSize().height;
        GraphicsContext3D  ctx = canvas.getGraphicsContext3D();
        Raster ras = new Raster();
        ras.setType(Raster.RASTER_COLOR);
        ras.setSize(width, height);
        ras.setSrcOffset(0, 0);
        image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        ImageComponent2D image2d =
        new ImageComponent2D(ImageComponent2D.FORMAT_RGB, image);
        ras.setImage(image2d);
 
        ctx.readRaster(ras);
 
        // Now strip out the image info
        ImageComponent2D img_src = ras.getImage();
 
        image=img_src.getImage();
      }
      // s'il d�sire une capture grande qualit�
      else{
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.