📄 introduction to java advanced imaging.htm
字号:
applications also require certain types of compressed image files. It is
beyond the scope of any API to support the hundreds of known compression
algorithms, so JAI also supports the addition of customized coders and
decoders (codecs), which can be added to the core API.
<P><A name=54289>
<H3>1.3.5 <IMG
src="Introduction to Java Advanced Imaging.files/space.gif">Device
Independent</H3></A>The processing of images can be specified in
device-independent coordinates, with the ultimate translation to pixels being
specified as needed at run time. JAI's "renderable" mode treats all image
sources as rendering-independent. You can set up a graph (or chain) of
renderable operations without any concern for the source image resolution or
size; JAI takes care of the details of the operations.
<P>To make it possible to develop platform-independent applications, JAI makes
no assumptions about output device resolution, color space, or color model.
Nor does the API assume a particular file format. Image files may be acquired
and manipulated without the programmer having any knowledge of the file format
being acquired.
<P><A name=52444>
<H3>1.3.6 <IMG
src="Introduction to Java Advanced Imaging.files/space.gif">Powerful</H3></A>JAI
supports complex image formats, including images of up to three dimensions and
an arbitrary number of bands. Many classes of imaging algorithms are supported
directly, others may be added as needed.
<P>JAI implements a set of core image processing capabilities, including image
tiling, regions of interest, and deferred execution. The API also implements a
set of core image processing operators, including many common point, area, and
frequency-domain operations. For a list of the available operators, see <A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Programming-environ.doc.html#55112">Section
3.6, "JAI API Operators</A>."
<P><A name=52446>
<H3>1.3.7 <IMG
src="Introduction to Java Advanced Imaging.files/space.gif">High
Performance</H3></A>A variety of implementations are possible, including
highly-optimized implementations that can take advantage of hardware
acceleration and the media capabilities of the platform, such as MMX on Intel
processors and VIS on UltraSparc.
<P><A name=52448>
<H3>1.3.8 <IMG
src="Introduction to Java Advanced Imaging.files/space.gif">Interoperable</H3></A>JAI
is integrated with the rest of the Java Media APIs, enabling media-rich
applications to be deployed on the Java platform. JAI works well with other
Java APIs, such as Java 3D and Java component technologies. This allows
sophisticated imaging to be a part of every Java technology programmer's tool
box.
<P>JAI is a Java Media API. It is classified as a Standard Extension to the
Java platform. JAI provides imaging functionality beyond that of the Java
Foundation Classes, although it is compatible with those classes in most
cases.
<P><A name=53715>
<H2>1.4 <IMG src="Introduction to Java Advanced Imaging.files/space.gif">A
Simple JAI Program</H2></A>Before proceeding any further, let's take a look at
an example JAI program to get an idea of what it looks like. <A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Introduction.doc.html#55064">Listing
1-1</A> shows a simple example of a complete JAI program. This example reads
an image, passed to the program as a command line argument, scales the image
by 2x with bilinear interpolation, then displays the result.
<P><CAPTION><FONT size=-1><B><A name=55064>
<CENTER><FONT size=-1><B><I>Listing 1-1 </I><IMG
src="Introduction to Java Advanced Imaging.files/sm-blank.gif" border=0>
<STRONG>Simple Example JAI Program </STRONG></B></FONT></CENTER></A>
<P></B></FONT></CAPTION>
<HR>
<TR valign="top"><TD rowspan="9" colspan="1"><PRE> import java.awt.Frame;
import java.awt.image.renderable.ParameterBlock;
import java.io.IOException;
import javax.media.jai.Interpolation;
import javax.media.jai.JAI;
import javax.media.jai.RenderedOp;
import com.sun.media.jai.codec.FileSeekableStream;
import javax.media.jai.widget.ScrollingImagePanel;
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR
valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR
valign="top"><TD rowspan="9" colspan="1"><PRE> /**
* This program decodes an image file of any JAI supported
* formats, such as GIF, JPEG, TIFF, BMP, PNM, PNG, into a
* RenderedImage, scales the image by 2X with bilinear
* interpolation, and then displays the result of the scale
* operation.
*/
public class JAISampleProgram {
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR
valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR
valign="top"><TD rowspan="9" colspan="1"><PRE> /** The main method. */
public static void main(String[] args) {
/* Validate input. */
if (args.length != 1) {
System.out.println("Usage: java JAISampleProgram " +
"input_image_filename");
System.exit(-1);
}
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR
valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR
valign="top"><TD rowspan="11" colspan="1"><PRE> /*
* Create an input stream from the specified file name
* to be used with the file decoding operator.
*/
FileSeekableStream stream = null;
try {
stream = new FileSeekableStream(args[0]);
} catch (IOException e) {
e.printStackTrace();
System.exit(0);
}
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR
valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR
valign="top"><TR valign="top"><TR valign="top"><TD rowspan="10" colspan="1"><PRE> /* Create an operator to decode the image file. */
RenderedOp image1 = JAI.create("stream", stream);
/*
* Create a standard bilinear interpolation object to be
* used with the "scale" operator.
*/
Interpolation interp = Interpolation.getInstance(
Interpolation.INTERP_BILINEAR);
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR
valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR
valign="top"><TR valign="top"><TD rowspan="13" colspan="1"><PRE> /**
* Stores the required input source and parameters in a
* ParameterBlock to be sent to the operation registry,
* and eventually to the "scale" operator.
*/
ParameterBlock params = new ParameterBlock();
params.addSource(image1);
params.add(2.0F); // x scale factor
params.add(2.0F); // y scale factor
params.add(0.0F); // x translate
params.add(0.0F); // y translate
params.add(interp); // interpolation method
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR
valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR
valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR
valign="top"><TD rowspan="3" colspan="1"><PRE> /* Create an operator to scale image1. */
RenderedOp image2 = JAI.create("scale", params);
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TD rowspan="4"
colspan="1"><PRE> /* Get the width and height of image2. */
int width = image2.getWidth();
int height = image2.getHeight();
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TD
rowspan="4" colspan="1"><PRE> /* Attach image2 to a scrolling panel to be displayed. */
ScrollingImagePanel panel = new ScrollingImagePanel(
image2, width, height);
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TD
rowspan="7" colspan="1"><PRE> /* Create a frame to contain the panel. */
Frame window = new Frame("JAI Sample Program");
window.add(panel);
window.pack();
window.show();
}
}
</PRE><TR valign="top"><TR valign="top"><TR valign="top"><TR valign="top"><TR
valign="top"><TR valign="top">
<HR>
<P>
<P>
<HR>
<BR>
<CENTER><A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/JAITOC.fm.html"><IMG
alt=Contents
src="Introduction to Java Advanced Imaging.files/contents.gif"></A> <A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Preface.doc.html"><IMG
alt=Previous
src="Introduction to Java Advanced Imaging.files/previous.gif"></A> <A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/J2D-concepts.doc.html"><IMG
alt=Next src="Introduction to Java Advanced Imaging.files/next.gif"></A>
<P><FONT size=5><I>Programming in Java Advanced Imaging</I></FONT>
</CENTER><BR>
<H5><A
href="http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/copyright.html">Copyright</A>
© 1999, Sun Microsystems, Inc. All rights reserved.</H5><!-- Last updated: Tue Nov 02 17:07:08 1999 --></BLOCKQUOTE>
<SCRIPT language=JavaScript
src="Introduction to Java Advanced Imaging.files/s_code_remote.js"></SCRIPT>
</BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -