Package java.awt.image

Examples of java.awt.image.WritableRaster


     * @param destRect  The rectangle within the tile to be computed.
     */
    protected void computeRect(Raster[] sources,
                               WritableRaster dest,
                               Rectangle destRect) {
  WritableRaster tempRas = null;

        // Save a reference to the source Raster.
        Raster source = sources[0];

        // Ensure the source Raster has the same bounds as the destination.
View Full Code Here


                s.getHeight() != destRect.height) {
                s = s.createChild(destRect.x, destRect.y,
                                  destRect.width, destRect.height,
                                  destRect.x, destRect.y, null);
            }
            WritableRaster d = dest;
            if (d.getMinX() != destRect.x ||
                d.getMinY() != destRect.y ||
                d.getWidth() != destRect.width ||
                d.getHeight() != destRect.height) {
                d = d.createWritableChild(destRect.x, destRect.y,
                                           destRect.width, destRect.height,
                                          destRect.x, destRect.y, null);
            }

            // Perform the color conversion on the (possible child) Rasters.
View Full Code Here

    }

    // Shift the sample value to [0, MAX-MIN]
    private Raster convertRasterToUnsigned(Raster ras) {
        int type = ras.getSampleModel().getDataType();
        WritableRaster tempRas = null;

        if ((type == DataBuffer.TYPE_INT
            || type == DataBuffer.TYPE_SHORT)) {
            int minX = ras.getMinX(), minY = ras.getMinY();
            int w = ras.getWidth() , h = ras.getHeight();

            int[] buf = ras.getPixels(minX, minY, w, h, (int[])null);
            convertBufferToUnsigned(buf, type);

            tempRas = createTempWritableRaster(ras);
            tempRas.setPixels(minX, minY, w, h, buf);
      return tempRas;
        }
        return ras;
    }
View Full Code Here

    }
   
    // Shift the sample value back to [MIN, MAX]
    private WritableRaster convertRasterToSigned(WritableRaster ras) {
  int type = ras.getSampleModel().getDataType();
  WritableRaster tempRas = null;

        if ((type == DataBuffer.TYPE_INT
            || type == DataBuffer.TYPE_SHORT)) {
      int minX = ras.getMinX(), minY = ras.getMinY();
      int w = ras.getWidth() , h = ras.getHeight();

            int[] buf = ras.getPixels(minX, minY, w, h, (int[])null);
            convertBufferToSigned(buf, type);

            if (ras instanceof WritableRaster)
                tempRas = (WritableRaster) ras;
            else
                tempRas = createTempWritableRaster(ras);
            tempRas.setPixels(minX, minY, w, h, buf);
      return tempRas;
        }
  return ras;
    }
View Full Code Here

     * @param image
     * @return .
     */
    public static boolean isBlack(final BufferedImage image) {

        final WritableRaster raster = image.getRaster();
        final int w = raster.getWidth();
        final int h = raster.getHeight();

        final double d[] = new double[4];

        for (int y = 0; y < h; y++) {
            for (int x = 0; x < w; x++) {
                raster.getPixel(x, y, d);

                final double q = d[0] + d[1] + d[2];
                if (q > 0) return false;
            }
        }
View Full Code Here

        System.exit(0);
      }
    });

    // Get a direct direct DataBuffer onto the bufferedimage
    WritableRaster raster = map.getRaster();
    pixels = ((DataBufferInt) raster.getDataBuffer()).getData();
  }
View Full Code Here

        int historyIdx;

        int aSum;

        ColorModel srcColorModel = src.getColorModel();
        WritableRaster srcRaster = src.getRaster();
        int[] dstBuffer = ((DataBufferInt) dst.getRaster().getDataBuffer()).getData();

        int lastPixelOffset = right * dstWidth;
        float hSumDivider = 1.0f / size;
        float vSumDivider = opacity / size;

        // horizontal pass : extract the alpha mask from the source picture and
        // blur it into the destination picture
        for (int srcY = 0, dstOffset = left * dstWidth; srcY < srcHeight; srcY++) {

            // first pixels are empty
            for (historyIdx = 0; historyIdx < shadowSize; ) {
                aHistory[historyIdx++] = 0;
            }

            aSum = 0;
            historyIdx = 0;

            // compute the blur average with pixels from the source image
            for (int srcX = 0; srcX < srcWidth; srcX++) {

                int a = (int) (aSum * hSumDivider); // calculate alpha value
                dstBuffer[dstOffset++] = a << 24;   // store the alpha value only
                                                    // the shadow color will be added in the next pass

                aSum -= aHistory[historyIdx]; // substract the oldest pixel from the sum

                // extract the new pixel ...
                a = srcColorModel.getAlpha(srcRaster.getDataElements(srcX, srcY, null));
                aHistory[historyIdx] = a;   // ... and store its value into history
                aSum += a;                  // ... and add its value to the sum

                if (++historyIdx >= shadowSize) {
                    historyIdx -= shadowSize;
View Full Code Here

        }

        int imageType = img.getType();
        if (imageType == BufferedImage.TYPE_INT_ARGB ||
            imageType == BufferedImage.TYPE_INT_RGB) {
            WritableRaster raster = img.getRaster();
            raster.setDataElements(x, y, w, h, pixels);
        } else {
            // Unmanages the image
            img.setRGB(x, y, w, h, pixels, 0, w);
        }
    }
View Full Code Here

    gfx.setXORMode(Color.BLACK);
    gfx.setStroke(new BasicStroke(randomInt(rng, fontSize / 8, fontSize / 2)));
    gfx.drawOval(x, y, dx, dy);

    WritableRaster rstr = image.getRaster();
    int[] vColor = new int[3];
    int[] oldColor = new int[3];

    // noise
    for (x = 0; x < width; x++)
    {
      for (y = 0; y < height; y++)
      {
        rstr.getPixel(x, y, oldColor);

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

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

     * @param height The height of the subrectangle.
     */
    public synchronized void getPixelBytes(final byte[] pixelBytes, final int x, final int y,
                                           final int width, final int height) {

        WritableRaster srcRas = bufImage.getRaster();
        DataBufferInt srcDataBuf = (DataBufferInt) srcRas.getDataBuffer();
        int[] srcPixels = srcDataBuf.getData();
        int srcLineWidth = bufImage.getWidth();

        int dstIdx = 0;
        int srcIdx = y * srcLineWidth + x;
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.