The Java Tutorials have been written for JDK 8.Java教程是为JDK 8编写的。Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available.本页中描述的示例和实践没有利用后续版本中引入的改进,并且可能使用不再可用的技术。See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases.有关Java SE 9及其后续版本中更新的语言特性的摘要,请参阅Java语言更改。
See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases.有关所有JDK版本的新功能、增强功能以及已删除或不推荐的选项的信息,请参阅JDK发行说明。
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).可以在图像上绘制不同的对象,例如线条、文字和其他图形,甚至其他图像(如下图所示)。
The Java 2D API enables you to apply image filtering operations to Java 2D API使您能够将图像过滤操作应用于BufferedImage
and includes several built-in filters. 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.要了解有关图像的更多信息,请参阅使用图像课程。