Documentation

The Java™ Tutorials
Hide TOC
Images图像
Trail: 2D Graphics
Lesson: Overview of the Java 2D API Concepts

Images图像

In the Java 2D API an image is typically a rectangular two-dimensional array of pixels, where each pixel represents the color at that position of the image and where the dimensions represent the horizontal extent (width) and vertical extent (height) of the image as it is displayed.在Java 2D API中,图像通常是一个矩形的二维像素阵列,其中每个像素表示图像该位置的颜色,其中尺寸表示图像显示时的水平范围(宽度)和垂直范围(高度)。

The most important image class for representing such images is the java.awt.image.BufferedImage class. 用于表示此类图像的最重要的图像类是java.awt.image.buffereImage类。The Java 2D API stores the contents of such images in memory so that they can be directly accessed.Java2D API将这些图像的内容存储在内存中,以便可以直接访问它们。

Applications can directly create a BufferedImage object or obtain an image from an external image format such as PNG or GIF.应用程序可以直接创建BuffereImage对象或从外部图像格式(如PNG或GIF)获取图像。

In either case, the application can then draw on to image by using Java 2D API graphics calls. 在这两种情况下,应用程序都可以通过使用Java2D API图形调用来绘制图像。So, images are not limited to displaying photographic type images. 因此,图像不限于显示照相类型的图像。Different objects such as line art, text, and other graphics and even other images can be drawn onto an image (as shown on the following images).可以在图像上绘制不同的对象,例如线条、文字和其他图形,甚至其他图像(如下图所示)。

This figure represents an images as a drawing surface

The Java 2D API enables you to apply image filtering operations to BufferedImage and includes several built-in filters. Java 2D API使您能够将图像过滤操作应用于BuffereImage,并包括几个内置过滤器。For example, the ConvolveOp filter can be used to blur or sharpen images.例如,ConvolveOp滤镜可用于模糊或锐化图像。

The resulting image can then be drawn to a screen, sent to a printer, or saved in a graphics format such as PNG, GIF etc. 然后,生成的图像可以绘制到屏幕上,发送到打印机,或以图形格式(如PNG、GIF等)保存。To learn more about images see the Working with Images lesson.要了解有关图像的更多信息,请参阅使用图像课程。


Previous page: Text
Next page: Printing