storing image information using class Image
Class Image is an abstract class—as a result, programs cannot instantiate class Image to create objects. To achieve platform independence, the Java implementation on each plat开发者_运维百科form provides its own subclass of Image to store image information.
The text is about class java.awt.Image
.
I don't understand the second part, namely:-
... provides its own subclass of Image to store image information.
Technically, how does that happen?
Image
instances are typically created through methods such as Toolkit.createImage()
. In this case, the actual instantiation of the Image
object is delegated to the Toolkit
class, which is platform-dependent.
Note that while you cannot directly instantiate class Image
, you can instantiate BufferedImage
, which is a concrete Image
subclass.
The concrete subclass of Image
might, in some cases, be a class which isn't part of the public API of the JDK. (In other cases, you might find that you're getting a BufferedImage
, which is much nicer in the event that you intend to do something with the image you get.)
Try System.out.println(img.getClass().getName());
just to see what you're getting.
精彩评论