<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!--NewPage-->
<html>
<head>
<!-- Generated by javadoc on Wed Jul 28 01:21:15 GMT 1999 -->
<title>
  Class java.awt.image.PixelGrabber
</title>
</head>
<body>
<a name="_top_"></a>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.awt.image.html">This Package</a>  <a href="java.awt.image.MemoryImageSource.html#_top_">Previous</a>  <a href="java.awt.image.RGBImageFilter.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
<hr>
<h1>
  Class java.awt.image.PixelGrabber
</h1>
<pre>
<a href="java.lang.Object.html#_top_">java.lang.Object</a>
   |
   +----java.awt.image.PixelGrabber
</pre>
<hr>
<dl>
  <dt> public class <b>PixelGrabber</b>
  <dt> extends <a href="java.lang.Object.html#_top_">Object</a>
  <dt> implements <a href="java.awt.image.ImageConsumer.html#_top_">ImageConsumer</a>
</dl>
The PixelGrabber class implements an ImageConsumer which can be attached
 to an Image or ImageProducer object to retrieve a subset of the pixels
 in that image.  Here is an example:
 <pre>
 public void handlesinglepixel(int x, int y, int pixel) {
	int alpha = (pixel >> 24) & 0xff;
	int red   = (pixel >> 16) & 0xff;
	int green = (pixel >>  8) & 0xff;
	int blue  = (pixel      ) & 0xff;
	// Deal with the pixel as necessary...
 }
 public void handlepixels(Image img, int x, int y, int w, int h) {
	int[] pixels = new int[w * h];
	PixelGrabber pg = new PixelGrabber(img, x, y, w, h, pixels, 0, w);
	try {
	    pg.grabPixels();
	} catch (InterruptedException e) {
	    System.err.println("interrupted waiting for pixels!");
	    return;
	}
	if ((pg.getStatus() & ImageObserver.ABORT) != 0) {
	    System.err.println("image fetch aborted or errored");
	    return;
	}
	for (int j = 0; j < h; j++) {
	    for (int i = 0; i < w; i++) {
		handlesinglepixel(x+i, y+j, pixels[j * w + i]);
	    }
	}
 }
 </pre>
<p>
<dl>
    <dt> <b>See Also:</b>
    <dd> <a href="java.awt.image.ColorModel.html#getRGBdefault">getRGBdefault</a>
</dl>
<hr>
<a name="index"></a>
<h2>
  <img src="images/constructor-index.gif" width=275 height=38 alt="Constructor Index">
</h2>
<dl>
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#PixelGrabber(java.awt.Image, int, int, int, int, boolean)"><b>PixelGrabber</b></a>(Image, int, int, int, int, boolean)
  <dd>  Create a PixelGrabber object to grab the (x, y, w, h) rectangular
 section of pixels from the specified image.
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#PixelGrabber(java.awt.Image, int, int, int, int, int[], int, int)"><b>PixelGrabber</b></a>(Image, int, int, int, int, int[], int, int)
  <dd>  Create a PixelGrabber object to grab the (x, y, w, h) rectangular
 section of pixels from the specified image into the given array.
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#PixelGrabber(java.awt.image.ImageProducer, int, int, int, int, int[], int, int)"><b>PixelGrabber</b></a>(ImageProducer, int, int, int, int, int[], int, int)
  <dd>  Create a PixelGrabber object to grab the (x, y, w, h) rectangular
 section of pixels from the image produced by the specified
 ImageProducer into the given array.
</dl>
<h2>
  <img src="images/method-index.gif" width=207 height=38 alt="Method Index">
</h2>
<dl>
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#abortGrabbing()"><b>abortGrabbing</b></a>()
  <dd>  Request the PixelGrabber to abort the image fetch.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getColorModel()"><b>getColorModel</b></a>()
  <dd>  Get the ColorModel for the pixels stored in the array.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getHeight()"><b>getHeight</b></a>()
  <dd>  Get the height of the pixel buffer (after adjusting for image height).
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getPixels()"><b>getPixels</b></a>()
  <dd>  Get the pixel buffer.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getStatus()"><b>getStatus</b></a>()
  <dd>  Return the status of the pixels.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getWidth()"><b>getWidth</b></a>()
  <dd>  Get the width of the pixel buffer (after adjusting for image width).
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#grabPixels()"><b>grabPixels</b></a>()
  <dd>  Request the Image or ImageProducer to start delivering pixels and
 wait for all of the pixels in the rectangle of interest to be
 delivered.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#grabPixels(long)"><b>grabPixels</b></a>(long)
  <dd>  Request the Image or ImageProducer to start delivering pixels and
 wait for all of the pixels in the rectangle of interest to be
 delivered or until the specified timeout has elapsed.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#imageComplete(int)"><b>imageComplete</b></a>(int)
  <dd>  The imageComplete method is part of the ImageConsumer API which
 this class must implement to retrieve the pixels.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setColorModel(java.awt.image.ColorModel)"><b>setColorModel</b></a>(ColorModel)
  <dd>  The setColorModel method is part of the ImageConsumer API which
 this class must implement to retrieve the pixels.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setDimensions(int, int)"><b>setDimensions</b></a>(int, int)
  <dd>  The setDimensions method is part of the ImageConsumer API which
 this class must implement to retrieve the pixels.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setHints(int)"><b>setHints</b></a>(int)
  <dd>  The setHints method is part of the ImageConsumer API which
 this class must implement to retrieve the pixels.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setPixels(int, int, int, int, java.awt.image.ColorModel, byte[], int, int)"><b>setPixels</b></a>(int, int, int, int, ColorModel, byte[], int, int)
  <dd>  The setPixels method is part of the ImageConsumer API which
 this class must implement to retrieve the pixels.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setPixels(int, int, int, int, java.awt.image.ColorModel, int[], int, int)"><b>setPixels</b></a>(int, int, int, int, ColorModel, int[], int, int)
  <dd>  The setPixels method is part of the ImageConsumer API which
 this class must implement to retrieve the pixels.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setProperties(java.util.Hashtable)"><b>setProperties</b></a>(Hashtable)
  <dd>  The setProperties method is part of the ImageConsumer API which
 this class must implement to retrieve the pixels.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#startGrabbing()"><b>startGrabbing</b></a>()
  <dd>  Request the PixelGrabber to start fetching the pixels.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#status()"><b>status</b></a>()
  <dd>  DEPRECATED:  Replaced by getStatus().
</dl>
<a name="constructors"></a>
<h2>
  <img src="images/constructors.gif" width=231 height=38 alt="Constructors">
</h2>
<a name="PixelGrabber"></a>
<a name="PixelGrabber(java.awt.Image, int, int, int, int, int[], int, int)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>PixelGrabber</b>
<pre>
 public PixelGrabber(<a href="java.awt.Image.html#_top_">Image</a> img,
                     int x,
                     int y,
                     int w,
                     int h,
                     int pix[],
                     int off,
                     int scansize)
</pre>
<dl>
  <dd> Create a PixelGrabber object to grab the (x, y, w, h) rectangular
 section of pixels from the specified image into the given array.
 The pixels are stored into the array in the default RGB ColorModel.
 The RGB data for pixel (i, j) where (i, j) is inside the rectangle
 (x, y, w, h) is stored in the array at
 <tt>pix[(j - y) * scansize + (i - x) + off]</tt>.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> img - the image to retrieve pixels from
    <dd> x - the x coordinate of the upper left corner of the rectangle
 of pixels to retrieve from the image, relative to the default
 (unscaled) size of the image
    <dd> y - the y coordinate of the upper left corner of the rectangle
 of pixels to retrieve from the image
    <dd> w - the width of the rectangle of pixels to retrieve
    <dd> h - the height of the rectangle of pixels to retrieve
    <dd> pix - the array of integers which are to be used to hold the
 RGB pixels retrieved from the image
    <dd> off - the offset into the array of where to store the first pixel
    <dd> scansize - the distance from one row of pixels to the next in
 the array
    <dt> <b>See Also:</b>
    <dd> <a href="java.awt.image.ColorModel.html#getRGBdefault">getRGBdefault</a>
  </dl></dd>
</dl>
<a name="PixelGrabber(java.awt.image.ImageProducer, int, int, int, int, int[], int, int)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>PixelGrabber</b>
<pre>
 public PixelGrabber(<a href="java.awt.image.ImageProducer.html#_top_">ImageProducer</a> ip,
                     int x,
                     int y,
                     int w,
                     int h,
                     int pix[],
                     int off,
                     int scansize)
</pre>
<dl>
  <dd> Create a PixelGrabber object to grab the (x, y, w, h) rectangular
 section of pixels from the image produced by the specified
 ImageProducer into the given array.
 The pixels are stored into the array in the default RGB ColorModel.
 The RGB data for pixel (i, j) where (i, j) is inside the rectangle
 (x, y, w, h) is stored in the array at
 <tt>pix[(j - y) * scansize + (i - x) + off]</tt>.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> img - the image to retrieve pixels from
    <dd> x - the x coordinate of the upper left corner of the rectangle
 of pixels to retrieve from the image, relative to the default
 (unscaled) size of the image
    <dd> y - the y coordinate of the upper left corner of the rectangle
 of pixels to retrieve from the image
    <dd> w - the width of the rectangle of pixels to retrieve
    <dd> h - the height of the rectangle of pixels to retrieve
    <dd> pix - the array of integers which are to be used to hold the
 RGB pixels retrieved from the image
    <dd> off - the offset into the array of where to store the first pixel
    <dd> scansize - the distance from one row of pixels to the next in
 the array
    <dt> <b>See Also:</b>
    <dd> <a href="java.awt.image.ColorModel.html#getRGBdefault">getRGBdefault</a>
  </dl></dd>
</dl>
<a name="PixelGrabber(java.awt.Image, int, int, int, int, boolean)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>PixelGrabber</b>
<pre>
 public PixelGrabber(<a href="java.awt.Image.html#_top_">Image</a> img,
                     int x,
                     int y,
                     int w,
                     int h,
                     boolean forceRGB)
</pre>
<dl>
  <dd> Create a PixelGrabber object to grab the (x, y, w, h) rectangular
 section of pixels from the specified image.  The pixels are
 accumulated in the original ColorModel if the same ColorModel
 is used for every call to setPixels, otherwise the pixels are
 accumulated in the default RGB ColorModel.  If the forceRGB
 parameter is true, then the pixels will be accumulated in the
 default RGB ColorModel anywya.  A buffer is allocated by the
 PixelGrabber to hold the pixels in either case.  If (w < 0) or
 (h < 0), then they will default to the remaining width and
 height of the source data when that information is delivered.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> img - the image to retrieve the image data from
    <dd> x - the x coordinate of the upper left corner of the rectangle
 of pixels to retrieve from the image, relative to the default
 (unscaled) size of the image
    <dd> y - the y coordinate of the upper left corner of the rectangle
 of pixels to retrieve from the image
    <dd> w - the width of the rectangle of pixels to retrieve
    <dd> h - the height of the rectangle of pixels to retrieve
    <dd> forceRGB - true if the pixels should always be converted to
 the default RGB ColorModel
  </dl></dd>
</dl>
<a name="methods"></a>
<h2>
  <img src="images/methods.gif" width=151 height=38 alt="Methods">
</h2>
<a name="startGrabbing()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="startGrabbing"><b>startGrabbing</b></a>
<pre>
 public synchronized void startGrabbing()
</pre>
<dl>
  <dd> Request the PixelGrabber to start fetching the pixels.
<p>
</dl>
<a name="abortGrabbing()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="abortGrabbing"><b>abortGrabbing</b></a>
<pre>
 public synchronized void abortGrabbing()
</pre>
<dl>
  <dd> Request the PixelGrabber to abort the image fetch.
<p>
</dl>
<a name="grabPixels()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="grabPixels"><b>grabPixels</b></a>
<pre>
 public boolean grabPixels() throws <a href="java.lang.InterruptedException.html#_top_">InterruptedException</a>
</pre>
<dl>
  <dd> Request the Image or ImageProducer to start delivering pixels and
 wait for all of the pixels in the rectangle of interest to be
 delivered.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> true if the pixels were successfully grabbed, false on
 abort, error or timeout
    <dt> <b>Throws:</b> <a href="java.lang.InterruptedException.html#_top_">InterruptedException</a>
    <dd> Another thread has interrupted this thread.
  </dl></dd>
</dl>
<a name="grabPixels(long)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="grabPixels"><b>grabPixels</b></a>
<pre>
 public synchronized boolean grabPixels(long ms) throws <a href="java.lang.InterruptedException.html#_top_">InterruptedException</a>
</pre>
<dl>
  <dd> Request the Image or ImageProducer to start delivering pixels and
 wait for all of the pixels in the rectangle of interest to be
 delivered or until the specified timeout has elapsed.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> ms - the number of milliseconds to wait for the image pixels
 to arrive before timing out
    <dt> <b>Returns:</b>
    <dd> true if the pixels were successfully grabbed, false on
 abort, error or timeout
    <dt> <b>Throws:</b> <a href="java.lang.InterruptedException.html#_top_">InterruptedException</a>
    <dd> Another thread has interrupted this thread.
  </dl></dd>
</dl>
<a name="getStatus()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getStatus"><b>getStatus</b></a>
<pre>
 public synchronized int getStatus()
</pre>
<dl>
  <dd> Return the status of the pixels.  The ImageObserver flags
 representing the available pixel information are returned.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the bitwise OR of all relevant ImageObserver flags
    <dt> <b>See Also:</b>
    <dd> <a href="java.awt.image.ImageObserver.html#_top_">ImageObserver</a>
  </dl></dd>
</dl>
<a name="getWidth()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getWidth"><b>getWidth</b></a>
<pre>
 public synchronized int getWidth()
</pre>
<dl>
  <dd> Get the width of the pixel buffer (after adjusting for image width).
 If no width was specified for the rectangle of pixels to grab then
 then this information will only be available after the image has
 delivered the dimensions.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the final width used for the pixel buffer or -1 if the width
 is not yet known
    <dt> <b>See Also:</b>
    <dd> <a href="#getStatus">getStatus</a>
  </dl></dd>
</dl>
<a name="getHeight()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getHeight"><b>getHeight</b></a>
<pre>
 public synchronized int getHeight()
</pre>
<dl>
  <dd> Get the height of the pixel buffer (after adjusting for image height).
 If no width was specified for the rectangle of pixels to grab then
 then this information will only be available after the image has
 delivered the dimensions.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the final height used for the pixel buffer or -1 if the height
 is not yet known
    <dt> <b>See Also:</b>
    <dd> <a href="#getStatus">getStatus</a>
  </dl></dd>
</dl>
<a name="getPixels()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getPixels"><b>getPixels</b></a>
<pre>
 public synchronized <a href="java.lang.Object.html#_top_">Object</a> getPixels()
</pre>
<dl>
  <dd> Get the pixel buffer.  If the PixelGrabber was not constructed
 with an explicit pixel buffer to hold the pixels then this method
 will return null until the size and format of the image data is
 known.
 Since the PixelGrabber may fall back on accumulating the data
 in the default RGB ColorModel at any time if the source image
 uses more than one ColorModel to deliver the data, the array
 object returned by this method may change over time until the
 image grab is complete.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> either a byte array or an int array
    <dt> <b>See Also:</b>
    <dd> <a href="#getStatus">getStatus</a>
  </dl></dd>
</dl>
<a name="getColorModel()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getColorModel"><b>getColorModel</b></a>
<pre>
 public synchronized <a href="java.awt.image.ColorModel.html#_top_">ColorModel</a> getColorModel()
</pre>
<dl>
  <dd> Get the ColorModel for the pixels stored in the array.  If the
 PixelGrabber was constructed with an explicit pixel buffer then
 this method will always return the default RGB ColorModel,
 otherwise it may return null until the ColorModel used by the
 ImageProducer is known.
 Since the PixelGrabber may fall back on accumulating the data
 in the default RGB ColorModel at any time if the source image
 uses more than one ColorModel to deliver the data, the ColorModel
 object returned by this method may change over time until the
 image grab is complete.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the ColorModel object used for storing the pixels
    <dt> <b>See Also:</b>
    <dd> <a href="#getStatus">getStatus</a>, <a href="java.awt.image.ColorModel.html#getRGBdefault">getRGBdefault</a>
  </dl></dd>
</dl>
<a name="setDimensions(int, int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setDimensions"><b>setDimensions</b></a>
<pre>
 public void setDimensions(int width,
                           int height)
</pre>
<dl>
  <dd> The setDimensions method is part of the ImageConsumer API which
 this class must implement to retrieve the pixels.
<p>
</dl>
<a name="setHints(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setHints"><b>setHints</b></a>
<pre>
 public void setHints(int hints)
</pre>
<dl>
  <dd> The setHints method is part of the ImageConsumer API which
 this class must implement to retrieve the pixels.
<p>
</dl>
<a name="setProperties(java.util.Hashtable)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setProperties"><b>setProperties</b></a>
<pre>
 public void setProperties(<a href="java.util.Hashtable.html#_top_">Hashtable</a> props)
</pre>
<dl>
  <dd> The setProperties method is part of the ImageConsumer API which
 this class must implement to retrieve the pixels.
<p>
</dl>
<a name="setColorModel(java.awt.image.ColorModel)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setColorModel"><b>setColorModel</b></a>
<pre>
 public void setColorModel(<a href="java.awt.image.ColorModel.html#_top_">ColorModel</a> model)
</pre>
<dl>
  <dd> The setColorModel method is part of the ImageConsumer API which
 this class must implement to retrieve the pixels.
<p>
</dl>
<a name="setPixels(int, int, int, int, java.awt.image.ColorModel, byte[], int, int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setPixels"><b>setPixels</b></a>
<pre>
 public void setPixels(int srcX,
                       int srcY,
                       int srcW,
                       int srcH,
                       <a href="java.awt.image.ColorModel.html#_top_">ColorModel</a> model,
                       byte pixels[],
                       int srcOff,
                       int srcScan)
</pre>
<dl>
  <dd> The setPixels method is part of the ImageConsumer API which
 this class must implement to retrieve the pixels.
<p>
</dl>
<a name="setPixels(int, int, int, int, java.awt.image.ColorModel, int[], int, int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setPixels"><b>setPixels</b></a>
<pre>
 public void setPixels(int srcX,
                       int srcY,
                       int srcW,
                       int srcH,
                       <a href="java.awt.image.ColorModel.html#_top_">ColorModel</a> model,
                       int pixels[],
                       int srcOff,
                       int srcScan)
</pre>
<dl>
  <dd> The setPixels method is part of the ImageConsumer API which
 this class must implement to retrieve the pixels.
<p>
</dl>
<a name="imageComplete(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="imageComplete"><b>imageComplete</b></a>
<pre>
 public synchronized void imageComplete(int status)
</pre>
<dl>
  <dd> The imageComplete method is part of the ImageConsumer API which
 this class must implement to retrieve the pixels.
<p>
</dl>
<a name="status()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="status"><b>status</b></a>
<pre>
 public synchronized int status()
</pre>
<dl>
  <dd> DEPRECATED:  Replaced by getStatus().
<p>
</dl>
<hr>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.awt.image.html">This Package</a>  <a href="java.awt.image.MemoryImageSource.html#_top_">Previous</a>  <a href="java.awt.image.RGBImageFilter.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
</body>
</html>
