O'Reilly logo

Graphic Java™ 1.2, Volume I: AWT, Third Edition by David M. Geary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Grabbing Pixels

As we've seen, the AWT provides extensive support for filtering images. However, sometimes it is convenient to be able access the pixel data of an image without having to bother with implementing an image filter in order to access this data. do so. That is precisely the role of the PixelGrabber class. PixelGrabber is an implementation of the ImageConsumer interface that grabs a rectangular region of pixels within a given image.

PixelGrabber provides three constructors that take the following arguments:

(Image im, int x, int y, int w, int h, boolean forceRGB
(Image im, int x, int y, int w, int h, int[] buffer,
           int offset, int scansize)
(ImageProducer ip, int x, int y, int w, int h, int[] buffer,
           int offset, int scansize)

All ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required