Programming in Java Advanced Imaging
Total Page:16
File Type:pdf, Size:1020Kb
Programming in Java™ Advanced Imaging Release 1.0.1 November 1999 JavaSoft A Sun Microsystems, Inc. Business 901 San Antonio Road Palo Alto, CA 94303 USA 415 960-1300 fax 415 969-9131 1999 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California 94303 U.S.A. All rights reserved. RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the United States Government is subject to the restrictions set forth in DFARS 252.227-7013 (c)(1)(ii) and FAR 52.227-19. The release described in this document may be protected by one or more U.S. patents, for- eign patents, or pending applications. Sun Microsystems, Inc. (SUN) hereby grants to you a fully paid, nonexclusive, nontrans- ferable, perpetual, worldwide limited license (without the right to sublicense) under SUN’s intellectual property rights that are essential to practice this specification. This license allows and is limited to the creation and distribution of clean-room implementa- tions of this specification that (i) are complete implementations of this specification, (ii) pass all test suites relating to this specification that are available from SUN, (iii) do not derive from SUN source code or binary materials, and (iv) do not include any SUN binary materials without an appropriate and separate license from SUN. Java, JavaScript, Java 3D, and Java Advanced Imaging are trademarks of Sun Microsys- tems, Inc. Sun, Sun Microsystems, the Sun logo, Java and HotJava are trademarks or reg- istered trademarks of Sun Microsystems, Inc. UNIX® is a registered trademark in the United States and other countries, exclusively licensed through X/Open Company, Ltd. All other product names mentioned herein are the trademarks of their respective owners. THIS PUBLICATION IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THIS PUBLICATION COULD INCLUDE TECHNICAL INACCURACIES OR TYPO- GRAPHICAL ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFOR- MATION HEREIN; THESE CHANGES WILL BE INCORPORATED IN NEW EDITIONS OF THE PUBLICATION. SUN MICROSYSTEMS, INC. MAY MAKE IMPROVEMENTS AND/OR CHANGES IN THE PRODUCT(S) AND/OR THE PRO- GRAM(S) DESCRIBED IN THIS PUBLICATION AT ANY TIME. Contents Figures . xi Preface . .xiii Disclaimer . xiii About This Book . xiii Related Documentation . .xv Additional Information . .xv Style Conventions . xvi 1 Introduction to Java Advanced Imaging . 1 1.1 The Evolution of Imaging in Java . .2 1.2 Why Another Imaging API? . .2 1.3 JAI Features. .3 1.3.1 Cross-platform Imaging . .3 1.3.2 Distributed Imaging . .4 1.3.3 Object-oriented API . .4 1.3.4 Flexible and Extensible . .4 1.3.5 Device Independent . .4 1.3.6 Powerful . .5 1.3.7 High Performance. .5 1.3.8 Interoperable. .5 1.4 A Simple JAI Program. .6 2 Java AWT Imaging. 9 2.1 Introduction . .9 2.1.1 The AWT Push Model . .9 2.1.2 AWT Push Model Interfaces and Classes . .11 2.2 The Immediate Mode Model . .11 2.2.1 Rendering Independence . .12 2.2.2 Rendering-independent Imaging in Java AWT . .13 2.2.3 The Renderable Layer vs. the Rendered Layer . .13 2.2.4 The Render Context . .15 2.3 Renderable and Rendered Classes. .15 2.3.1 The Renderable Layer . .16 2.3.2 The Rendered Layer . .18 2.4 Java Image Data Representation . .19 Release 1.0.1, November 1999 iii CONTENTS 2.5 Introducing the Java Advanced Imaging API . 21 2.5.1 Similarities with the Java 2D API . 22 2.5.2 JAI Data Classes . 22 3 Programming in Java Advanced Imaging . 27 3.1 Introduction . 27 3.2 An Overview of Graphs . 28 3.3 Processing Graphs . 29 3.3.1 Rendered Graphs . 30 3.3.2 Renderable Graphs . 32 3.3.3 Reusing Graphs . 37 3.4 Remote Execution . 38 3.5 Basic JAI API Classes . 38 3.5.1 The JAI Class . 38 3.5.2 The PlanarImage Class . 39 3.5.3 The CollectionImage Class . 39 3.5.4 The TiledImage Class . 40 3.5.5 The OpImage Class . 40 3.5.6 The RenderableOp Class. 41 3.5.7 The RenderedOp Class . 42 3.6 JAI API Operators . 42 3.6.1 Point Operators . 43 3.6.2 Area Operators . 46 3.6.3 Geometric Operators . 47 3.6.4 Color Quantization Operators . 48 3.6.5 File Operators . 48 3.6.6 Frequency Operators . 49 3.6.7 Statistical Operators . 51 3.6.8 Edge Extraction Operators . 51 3.6.9 Miscellaneous Operators . 52 3.7 Creating Operations . 52 3.7.1 Operation Name . 55 3.7.2 Parameter Blocks. 56 3.7.3 Rendering Hints. 60 4 Image Acquisition and Display. 65 4.1 Introduction . 65 4.1.1 Image Data . 67 4.1.2 Basic Storage Types . 68 4.2 JAI Image Types. 71 4.2.1 Planar Image . 72 4.2.2 Tiled Image . 74 4.2.3 Snapshot Image . 81 4.2.4 Remote Image . 83 4.2.5 Collection Image . 83 4.2.6 Image Sequence. 84 4.2.7 Image Stack . 84 4.2.8 Image MIP Map. 85 iv Programming in Java Advanced Imaging 4.2.9 Image Pyramid . .89 4.2.10 Multi-resolution Renderable Images . .95 4.3 Streams . .97 4.4 Reading Image Files . .101 4.4.1 Standard File Readers for Most Data Types. .103 4.4.2 Reading TIFF Images . .104 4.4.3 Reading FlashPix Images . .109 4.4.4 Reading JPEG Images . .110 4.4.5 Reading GIF Images. .110 4.4.6 Reading BMP Images. .111 4.4.7 Reading PNG Images . .112 4.4.8 Reading PNM Images. .117 4.4.9 Reading Standard AWT Images. ..