Package java.awt.image

Examples of java.awt.image.WritableRaster


    public Raster computeTile(int tileX, int tileY) {
        //
        // Create a new WritableRaster to represent this tile.
        //
        Point org = new Point(tileXToX(tileX), tileYToY(tileY));
        WritableRaster dest = createWritableRaster(sampleModel, org);

        //
        // Clip output rectangle to image bounds.
        //
        Rectangle rect = new Rectangle(org.x,
View Full Code Here


            // a SinglePixelPackedSampleModel with numBands < 3.
            tile = tile.createChild(tile.getMinX(), tile.getMinY(),
                                    tile.getWidth(), tile.getHeight(),
                                    tile.getMinX(), tile.getMinY(),
                                    bandIndices);
            WritableRaster raster = createTile(tileX, tileY);
            raster.setRect(tile);

            return raster;
        } else {
            // Simply return a child of the corresponding source tile.
            return tile.createChild(tile.getMinX(), tile.getMinY(),
View Full Code Here

     * @param tileY The Y index of the tile.
     */
    public Raster computeTile(int tileX, int tileY) {
        // Create a new raster.
        Point org = new Point(getMinX(), getMinY());
        WritableRaster dest = createWritableRaster(sampleModel, org);
           
        // Determine the active area. Since the image has a single
        // tile equal in coverage to the image bounds just set this
        // to the image bounds.
        Rectangle destRect = getBounds();
View Full Code Here

     *
     * @return A <code>Graphics2D</code> object.
     */
    private Graphics2D getBogusGraphics2D(boolean shouldCopyState) {
        Raster r =  tiledImage.getTile(tileXMinimum, tileYMinimum);
        WritableRaster wr = r.createCompatibleWritableRaster(1, 1);
        BufferedImage bi =
            new BufferedImage(colorModel, wr,
                              colorModel.isAlphaPremultiplied(), properties);

        Graphics2D bogusG2D = bi.createGraphics();
View Full Code Here

            int tileMinY = tiledImage.tileYToY(tileY);
            for(int tileX = minTileX; tileX <= maxTileX; tileX++) {
                int tileMinX = tiledImage.tileXToX(tileX);

                // Get the WritableRaster of the current tile
                WritableRaster wr = tiledImage.getWritableTile(tileX, tileY);
                wr = wr.createWritableTranslatedChild(0, 0);

                // Create an equivalent BufferedImage
                BufferedImage bi =
                    new BufferedImage(colorModel, wr,
                                      colorModel.isAlphaPremultiplied(),
View Full Code Here

        else
            gfx.setStroke(new BasicStroke(config.getFontSize()));
           
        gfx.drawOval(x, y, dx, dy);

        WritableRaster rstr = image.getRaster();
        int[] vColor = new int[3];
        int[] oldColor = new int[3];
        Random vRandom = new Random(System.currentTimeMillis());
        // noise
        for (x = 0; x < width; x++)
        {
            for (y = 0; y < height; y++)
            {
                rstr.getPixel(x, y, oldColor);

                // hard noise
                vColor[0] = 0 + (int) (Math.floor(vRandom.nextFloat() * 1.03) * 255);
                // soft noise
                vColor[0] = vColor[0]
                        ^ (170 + (int) (vRandom.nextFloat() * 80));
                // xor to image
                vColor[0] = vColor[0] ^ oldColor[0];
                vColor[1] = vColor[0];
                vColor[2] = vColor[0];

                rstr.setPixel(x, y, vColor);
            }
        }
    }
View Full Code Here

   * <p/>
   * does not unmange the image for all (A)RGN and (A)BGR and gray imaged
   */
  public static void setBGRPixels(byte[] bgrPixels, BufferedImage img, int x, int y, int w, int h) {
    int imageType = img.getType();
    WritableRaster raster = img.getRaster();
    //int ttype= raster.getTransferType();
    if (imageType == BufferedImage.TYPE_3BYTE_BGR ||
        imageType == BufferedImage.TYPE_4BYTE_ABGR ||
        imageType == BufferedImage.TYPE_4BYTE_ABGR_PRE ||
        imageType == BufferedImage.TYPE_BYTE_GRAY) {
      raster.setDataElements(x, y, w, h, bgrPixels);
    } else {
      int[] pixels;
      if (imageType == BufferedImage.TYPE_INT_BGR) {
        pixels = bytes2int(bgrPixels, 2, 1, 0)// bgr -->  bgr
      } else if (imageType == BufferedImage.TYPE_INT_ARGB ||
          imageType == BufferedImage.TYPE_INT_ARGB_PRE) {
        pixels = bytes2int(bgrPixels, 3, 0, 1, 2)// abgr -->  argb
      } else {
        pixels = bytes2int(bgrPixels, 0, 1, 2)// bgr -->  rgb
      }
      if (w == 0 || h == 0) {
        return;
      } else if (pixels.length < w * h) {
        throw new IllegalArgumentException("pixels array must have a length" + " >= w*h");
      }
      if (imageType == BufferedImage.TYPE_INT_ARGB ||
          imageType == BufferedImage.TYPE_INT_RGB ||
          imageType == BufferedImage.TYPE_INT_ARGB_PRE ||
          imageType == BufferedImage.TYPE_INT_BGR) {
        raster.setDataElements(x, y, w, h, pixels);
      } else {
        // Unmanages the image
        img.setRGB(x, y, w, h, pixels, 0, w);
      }
    }
View Full Code Here

     * @param tileY the Y index of the tile.
     */
    public Raster computeTile(int tileX, int tileY) {
        // Create a new WritableRaster to represent this tile.
        Point org = new Point(tileXToX(tileX), tileYToY(tileY));
        WritableRaster dest = createWritableRaster(sampleModel, org);

        // Clip output rectangle to image bounds.
        Rectangle rect = new Rectangle(org.x, org.y,
                                       sampleModel.getWidth(),
                                       sampleModel.getHeight());
View Full Code Here

        return sourceRect.intersection(getBounds());
    }

    public Raster computeTile(int tileX, int tileY) {
        // Create a new Raster.
        WritableRaster dest = createWritableRaster(sampleModel,
                                                   new Point(tileXToX(tileX),
                                                             tileYToY(tileY)));

        // Determine the active area; tile intersects with image's bounds.
        Rectangle destRect = getTileRect(tileX, tileY);
View Full Code Here

     * @param tileX  The X index of the tile.
     * @param tileY  The Y index of the tile.
     */
    public Raster computeTile(int tileX, int tileY) {
        // Create a new Raster.
        WritableRaster dest = createWritableRaster(sampleModel,
                                                   new Point(tileXToX(tileX),
                                                             tileYToY(tileY)));
           
        // Determine the active area; tile intersects with image's bounds.
        Rectangle destRect = getTileRect(tileX, tileY);
View Full Code Here

TOP

Related Classes of java.awt.image.WritableRaster

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.