Creating Images
AWT components, in addition to being image observers, are also capable of creating images. java.awt.Component comes with two methods for creating images:
createImage(ImageProducer)
createImage(int width, int height)
The first version of createImage() creates an image, given an ImageProducer from which the bits of the image are obtained; we will find a use for this method in “Loading Images as Resources”.
The second version creates an image suitable for an offscreen buffer, as we shall discover in “Double Buffering”.
Additionally, the java.awt.Toolkit class is also capable of creating images and provides the following methods:
createImage(ImageProducer)
createImage(byte[] bits)
createImage(byte[] bits, int offset, int length)
Like ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access