33 |
33 |
34 /** |
34 /** |
35 * The PixelGrabber class implements an ImageConsumer which can be attached |
35 * The PixelGrabber class implements an ImageConsumer which can be attached |
36 * to an Image or ImageProducer object to retrieve a subset of the pixels |
36 * to an Image or ImageProducer object to retrieve a subset of the pixels |
37 * in that image. Here is an example: |
37 * in that image. Here is an example: |
38 * <pre> |
38 * <pre>{@code |
39 * |
39 * |
40 * public void handlesinglepixel(int x, int y, int pixel) { |
40 * public void handlesinglepixel(int x, int y, int pixel) { |
41 * int alpha = (pixel >> 24) & 0xff; |
41 * int alpha = (pixel >> 24) & 0xff; |
42 * int red = (pixel >> 16) & 0xff; |
42 * int red = (pixel >> 16) & 0xff; |
43 * int green = (pixel >> 8) & 0xff; |
43 * int green = (pixel >> 8) & 0xff; |
163 * accumulated in the original ColorModel if the same ColorModel |
163 * accumulated in the original ColorModel if the same ColorModel |
164 * is used for every call to setPixels, otherwise the pixels are |
164 * is used for every call to setPixels, otherwise the pixels are |
165 * accumulated in the default RGB ColorModel. If the forceRGB |
165 * accumulated in the default RGB ColorModel. If the forceRGB |
166 * parameter is true, then the pixels will be accumulated in the |
166 * parameter is true, then the pixels will be accumulated in the |
167 * default RGB ColorModel anyway. A buffer is allocated by the |
167 * default RGB ColorModel anyway. A buffer is allocated by the |
168 * PixelGrabber to hold the pixels in either case. If (w < 0) or |
168 * PixelGrabber to hold the pixels in either case. If {@code (w < 0)} or |
169 * (h < 0), then they will default to the remaining width and |
169 * {@code (h < 0)}, then they will default to the remaining width and |
170 * height of the source data when that information is delivered. |
170 * height of the source data when that information is delivered. |
171 * @param img the image to retrieve the image data from |
171 * @param img the image to retrieve the image data from |
172 * @param x the x coordinate of the upper left corner of the rectangle |
172 * @param x the x coordinate of the upper left corner of the rectangle |
173 * of pixels to retrieve from the image, relative to the default |
173 * of pixels to retrieve from the image, relative to the default |
174 * (unscaled) size of the image |
174 * (unscaled) size of the image |
231 * wait for all of the pixels in the rectangle of interest to be |
231 * wait for all of the pixels in the rectangle of interest to be |
232 * delivered or until the specified timeout has elapsed. This method |
232 * delivered or until the specified timeout has elapsed. This method |
233 * behaves in the following ways, depending on the value of |
233 * behaves in the following ways, depending on the value of |
234 * <code>ms</code>: |
234 * <code>ms</code>: |
235 * <ul> |
235 * <ul> |
236 * <li> If <code>ms</code> == 0, waits until all pixels are delivered |
236 * <li> If {@code ms == 0}, waits until all pixels are delivered |
237 * <li> If <code>ms</code> > 0, waits until all pixels are delivered |
237 * <li> If {@code ms > 0}, waits until all pixels are delivered |
238 * as timeout expires. |
238 * as timeout expires. |
239 * <li> If <code>ms</code> < 0, returns <code>true</code> if all pixels |
239 * <li> If {@code ms < 0}, returns <code>true</code> if all pixels |
240 * are grabbed, <code>false</code> otherwise and does not wait. |
240 * are grabbed, <code>false</code> otherwise and does not wait. |
241 * </ul> |
241 * </ul> |
242 * @param ms the number of milliseconds to wait for the image pixels |
242 * @param ms the number of milliseconds to wait for the image pixels |
243 * to arrive before timing out |
243 * to arrive before timing out |
244 * @return true if the pixels were successfully grabbed, false on |
244 * @return true if the pixels were successfully grabbed, false on |