⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 java awt imaging.htm

📁 是一部关于java高级图像处理的的一本入门书
💻 HTM
📖 第 1 页 / 共 4 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0097)http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/J2D-concepts.doc.html -->
<HTML><HEAD><TITLE>Java AWT Imaging</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content=exclude name=collection>
<META content="MSHTML 6.00.2900.3132" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff>
<CENTER><A 
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/JAITOC.fm.html"><IMG 
alt=Contents src="Java AWT Imaging.files/contents.gif"></A> <A 
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Introduction.doc.html"><IMG 
alt=Previous src="Java AWT Imaging.files/previous.gif"></A> <A 
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Programming-environ.doc.html"><IMG 
alt=Next src="Java AWT Imaging.files/next.gif"></A> 
<P><FONT size=5><I>Programming in Java Advanced Imaging</I></FONT> </CENTER><BR>
<CENTER><A name=47227>
<TABLE width="90%" border=0>
  <TBODY>
  <TR>
    <TD align=right><FONT size=3>C H A P T E R</FONT><FONT size=7><IMG 
      src="Java AWT Imaging.files/sm-space.gif">2</FONT></TD></TR></TBODY></TABLE></A></CENTER>
<CENTER><A name=47285>
<TABLE width="90%" border=0>
  <TBODY>
  <TR>
    <TD align=right>
      <HR noShade SIZE=7>
      <FONT size=6>Java AWT Imaging</FONT></TD></TR></TBODY></TABLE></A></CENTER>
<BLOCKQUOTE>
  <P><BR><BR><BR>
  <P><FONT size=7><B>D</B></FONT>IGITAL imaging in Java has been supported since 
  its first release, through the <STRONG><KBD>java.awt</KBD></STRONG> and 
  <STRONG><KBD>java.awt.image</KBD></STRONG> class packages. The image-oriented 
  part of these class packages is referred to as <EM>AWT Imaging</EM> throughout 
  this guide. 
  <P><A name=52422>
  <H2>2.1 <IMG src="Java AWT Imaging.files/space.gif">Introduction</H2></A>The 
  Java Advanced Imaging (JAI) API supports three imaging models: 
  <P>
  <UL>
    <LI>The producer/consumer (push) model - the basic AWT imaging model
    <P></P></LI></UL>
  <UL>
    <LI>The immediate mode model - an advanced AWT imaging model
    <P></P></LI></UL>
  <UL>
    <LI>The pipeline (pull) model - The JAI model
    <P></P></LI></UL><A 
  href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/J2D-concepts.doc.html#52516">Table 
  2-1</A> lists the interfaces and classes for each of the three models.
  <P>
  <TABLE cellPadding=3 border=3>
    <CAPTION><FONT size=-1><B><A name=52516><I>Table 2-1 </I><IMG 
    src="Java AWT Imaging.files/sm-blank.gif" border=0> Imaging Model Interfaces 
    and Classes </A></B></FONT></CAPTION>
    <TBODY>
    <TR vAlign=top>
      <TH><A name=52522>AWT Push Model </A>
      <TH><A name=52524>Java 2D Immediate Mode Model </A>
      <TH><A name=52526>Pull Model </A>
    <TR vAlign=top>
      <TD><A name=52528>Image</A><BR><A name=52529>ImageProducer</A><BR><A 
        name=52530>ImageConsumer</A><BR><A name=52531>ImageObserver</A><BR>
      <TD><A name=52533>BufferedImage</A><BR><A name=52534>Raster</A><BR><A 
        name=52535>BufferedImageOp</A><BR><A name=52536>RasterOp</A><BR>
      <TD><A name=52538>RenderableImage</A><BR><A 
        name=52539>RenderableImageOp</A><BR><A name=52540>RenderedOp</A><BR><A 
        name=52541>RenderableOp</A><BR><A 
  name=52542>TiledImage</A><BR></TR></TBODY></TABLE>
  <P><A name=52427>
  <H3>2.1.1 <IMG src="Java AWT Imaging.files/space.gif">The AWT Push 
  Model</H3></A>The AWT push model, supported through the <CODE>java.awt</CODE> 
  class package, is a simple filter model of image producers and consumers for 
  image processing. An <CODE>Image</CODE> object is an abstraction that is not 
  manipulated directly; rather it is used to obtain a reference to another 
  object that implements the <CODE>ImageProducer</CODE> interface. Objects that 
  implement this interface are in turn attached to objects that implement the 
  ImageConsumer interface. Filter objects implement both the producer and 
  consumer interfaces and can thus serve as both a source and sink of image 
  data. Image data has associated with it a ColorModel that describes the pixel 
  layout within the image and the interpretation of the data. 
  <P>To process images in the push model, an Image object is obtained from some 
  source (for example, through the <CODE>Applet.getImage()</CODE> method). The 
  <CODE>Image.getSource()</CODE> method can then be used to get the 
  <CODE>ImageProducer</CODE> for that <CODE>Image</CODE>. A series of 
  FilteredImageSource objects can then be attached to the ImageProducer, with 
  each filter being an ImageConsumer of the previous image source. AWT Imaging 
  defines a few simple filters for image cropping and color channel 
  manipulation. 
  <P>The ultimate destination for a filtered image is an AWT <CODE>Image</CODE> 
  object, created by a call to, for example, 
  <CODE>Component.createImage()</CODE>. Once this consumer image has been 
  created, it can by drawn upon the screen by calling 
  <CODE>Image.getGraphics()</CODE> to obtain a <CODE>Graphics</CODE> object 
  (such as a screen device), followed by <CODE>Graphics.drawImage()</CODE>. 
  <P>AWT Imaging was largely designed to facilitate the display of images in a 
  browser environment. In this context, an image resides somewhere on the 
  network. There is no guarantee that the image will be available when required, 
  so the AWT model does not force image filtering or display to completion. The 
  model is entirely a <EM>push</EM> model. An ImageConsumer can never ask for 
  data; it must wait for the ImageProducer to "push" the data to it. Similarly, 
  an ImageConsumer has no guarantee about when the data will be completely 
  delivered; it must wait for a call to its <CODE>ImageComplete()</CODE> method 
  to know that it has the complete image. An application can also instantiate an 
  ImageObserver object if it wishes to be notified about completion of imaging 
  operations. 
  <P>AWT Imaging does not incorporate the idea of an image that is backed by a 
  persistent image store. While methods are provided to convert an input memory 
  array into an ImageProducer, or capture an output memory array from an 
  ImageProducer, there is no notion of a persistent image object that can be 
  reused. When data is wanted from an Image, the programmer must retrieve a 
  handle to the Image's ImageProducer to obtain it. 
  <P>The AWT imaging model is not amenable to the development of 
  high-performance image processing code. The push model, the lack of a 
  persistent image data object, the restricted model of an image filter, and the 
  relative paucity of image data formats are all severe constraints. AWT Imaging 
  also lacks a number of common concepts that are often used in image 
  processing, such as operations performed on a region of interest in an image. 
  <P><A name=52551>
  <H3>2.1.2 <IMG src="Java AWT Imaging.files/space.gif">AWT Push Model 
  Interfaces and Classes</H3></A>The following are the Java interfaces and 
  classes associated with the AWT push model of imaging.
  <P>
  <TABLE cellPadding=3 border=3>
    <CAPTION><FONT size=-1><B><A name=52555><I>Table 2-2 </I><IMG 
    src="Java AWT Imaging.files/sm-blank.gif" border=0> Push Model Imaging 
    Interfaces </A></B></FONT></CAPTION>
    <TBODY>
    <TR vAlign=top>
      <TH><A name=52559>Interface </A>
      <TH><A name=52561>Description </A>
    <TR vAlign=top>
      <TD><A name=52582>Image</A><BR>
      <TD><A name=52584>Extends: Object</A><BR><A name=52585>The superclass of 
        all classes that represent graphical images.</A><BR></TR></TBODY></TABLE>
  <P>
  <TABLE cellPadding=3 border=3>
    <CAPTION><FONT size=-1><B><A name=52594><I>Table 2-3 </I><IMG 
    src="Java AWT Imaging.files/sm-blank.gif" border=0> Push Model Imaging 
    Classes </A></B></FONT></CAPTION>
    <TBODY>
    <TR vAlign=top>
      <TH><A name=52598>Class </A>
      <TH><A name=52600>Description </A>
    <TR vAlign=top>
      <TD><A name=52680>ColorModel</A><BR>
      <TD><A name=52684>An abstract class that encapsulates the methods for 
        translating a pixel value to color components (e.g., red, green, blue) 
        and an alpha component.</A><BR>
    <TR vAlign=top>
      <TD><A name=52695>FilteredImageSource</A><BR>
      <TD><A name=52699>An implementation of the ImageProducer interface which 
        takes an existing image and a filter object and uses them to produce 
        image data for a new filtered version of the original image.</A><BR>
    <TR vAlign=top>
      <TD><A name=52602>ImageProducer</A><BR>
      <TD><A name=52621>The interface for objects that can produce the image 
        data for Images. Each image contains an ImageProducer that is used to 
        reconstruct the image whenever it is needed, for example, when a new 
        size of the Image is scaled, or when the width or height of the Image is 
        being requested. </A><BR>
    <TR vAlign=top>
      <TD><A name=52606>ImageConsumer</A><BR>
      <TD><A name=52641>The interface for objects expressing interest in image 
        data through the ImageProducer interfaces. When a consumer is added to 
        an image producer, the producer delivers all of the data about the image 
        using the method calls defined in this interface. </A><BR>
    <TR vAlign=top>
      <TD><A name=52610>ImageObserver</A><BR>
      <TD><A name=52653>An asynchronous update interface for receiving 
        notifications about Image information as the Image is constructed. 
        </A><BR></TR></TBODY></TABLE>
  <P><A name=50792>
  <H2>2.2 <IMG src="Java AWT Imaging.files/space.gif">The Immediate Mode 
  Model</H2></A>To alleviate some of the restrictions of the original AWT 
  imaging model and to provide a higher level of abstraction, a new 
  specification called the <EM>Java 2D</EM> API was developed. This new API 
  extends AWT's capabilities for both two-dimensional graphics and imaging. In 
  practice, the Java 2D package is now merged into the AWT specification and is 
  a part of the Java Core (and thus available in all Java implementations). 
  However, for purposes of discussion, the distinction between Java 2D and the 
  AWT is preserved in this chapter. 
  <P>The Java 2D API specifies a set of classes that extend the Java AWT classes 
  to provide extensive support for both two-dimensional graphics and imaging. 
  The support for 2D graphics is fairly complete, but will not be discussed 
  further here. 
  <P>For digital imaging, the Java 2D API retains to some extent the AWT 
  producer/consumer model but adds the concept of a memory-backed persistent 
  image data object, an extensible set of 2D image filters, a wide variety of 
  image data formats and color models, and a more sophisticated representation 
  of output devices. The Java 2D API also introduces the notion of 
  resolution-independent image rendering by the introduction of the 
  <EM>Renderable</EM> and <EM>Rendered</EM> interfaces, allowing images to be 
  pulled through a chain of filter operations, with the image resolution 
  selected through a rendering context. 
  <P>The concepts of rendered and renderable images contained in the Java 2D API 
  are essential to JAI. The next few sections explain these concepts; complete 
  information about the classes discussed can be found in <EM>The Java 2D API 
  Specification</EM> and the <EM>Java 2D API White Paper</EM>. 
  <P><A name=51197>
  <H3>2.2.1 <IMG src="Java AWT Imaging.files/space.gif">Rendering 
  Independence</H3></A>Rendering independence for images is a poorly understood 
  topic because it is poorly named. The more general problem is "resolution 
  independence," the ability to describe an image as you want it to appear, but 
  independent of any specific instance of it. Resolution is but one feature of 
  any such rendering. Others are the physical size, output device type, color 
  quality, tonal quality, and rendering speed. A rendering-independent 
  description is concerned with none of these. 
  <P>In this document, the term <EM>rendering-independent</EM> is for the more 
  general concept instead of <EM>resolution-independent</EM>. The latter term is 
  used to specifically refer to independence from final display resolution. 
  <P>For a rendering-independent description of an image, two fundamental 
  elements are needed: 
  <P>
  <UL>
    <LI>An unrendered source (sometimes called a <EM>resolution-independent 
    source</EM>). For a still image, this is, conceptually, the viewfinder of an 
    idealized camera trained on a real scene. It has no logical "size." Rather, 
    one knows what it looks like and can imagine projecting it onto any surface. 
    Furthermore, the ideal camera has an ideal lens that is capable of infinite 
    zooming. The characteristics of this image are that it is dimensional, has a 
    native aspect ratio (that of the capture device), and may have properties 
    that could be queried.
    <P></P></LI></UL>
  <UL>
    <LI>Operators for describing how to change the character of the image, 
    independent of its final destination. It can be useful to think of this as a 
    pipe of operations.
    <P></P></LI></UL>Together, the unrendered source and the operators specify the 
  visual character that the image should have when it is rendered. This 
  specification can then be associated with any device, display size, or 
  rendering quality. The primary power of rendering independence is that the 
  same visual description can be routed to any display context with an optimal 
  result. 
  <P><A name=51292>
  <H3>2.2.2 <IMG src="Java AWT Imaging.files/space.gif">Rendering-independent 
  Imaging in Java AWT</H3></A>The Java AWT API architecture integrates a model 
  of rendering independence with a parallel, device-dependent (rendered) model. 
  The rendering-independent portion of the architecture is a superset of, rather 
  than a replacement for, the traditional model of device-dependent imaging. 
  <P>The Java AWT API architecture supports context-dependent adaptation, which 
  is superior to full image production and processing. Context-dependent 
  adaptation is inherently more efficient and thus also suited to network 
  sources. Beyond efficiency, it is the mechanism by which optimal image quality 
  can be assured in any context. 
  <P>The Java AWT API architecture is essentially synchronous is nature. This 
  has several advantages, such as a simplified programming model and explicit 
  controls on the type and order of results. However, the synchronous nature of 
  Java AWT has one distinct disadvantage in that it is not well suited to 
  notions of progressive rendering or network resources. These issues are 
  addressed in JAI. 
  <P><A name=51333>
  <H3>2.2.3 <IMG src="Java AWT Imaging.files/space.gif">The Renderable Layer vs. 
  the Rendered Layer</H3></A>The Java AWT API architecture provides for two 
  integrated imaging layers: renderable and rendered. 
  <P><A name=51343>
  <H4>2.2.3.1 <IMG src="Java AWT Imaging.files/space.gif">Renderable 
  Layer</H4></A>The renderable layer is a rendering-independent layer. All the 
  interfaces and classes in the Java AWT API have <CODE>renderable</CODE> in 
  their names. 
  <P>The renderable layer provides image sources that can be optimally reused 
  multiple times in different contexts, such as screen display or printing. The 
  renderable layer also provides imaging operators that take 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -