Source Code Cross Referenced for TIFFDecodeParam.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » com » sun » media » jai » codec » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » Java Advanced Imaging » com.sun.media.jai.codec 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: TIFFDecodeParam.java,v $
003:         *
004:         * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * Use is subject to license terms.
007:         *
008:         * $Revision: 1.1 $
009:         * $Date: 2005/02/11 04:55:34 $
010:         * $State: Exp $
011:         */
012:        package com.sun.media.jai.codec;
013:
014:        /**
015:         * An instance of <code>ImageDecodeParam</code> for decoding images in
016:         * the TIFF format.
017:         *
018:         * <p> To determine the number of images present in a TIFF file, use
019:         * the <code>getNumPages()</code> method on the
020:         * <code>ImageDecoder</code> object that will be used to perform the
021:         * decoding.  The desired page number may be passed as an argument to
022:         * the <code>ImageDecoder.decodeAsRaster)()</code> or
023:         * <code>decodeAsRenderedImage()</code> methods.
024:         *
025:         * <p> For TIFF Palette color images, the colorMap always has entries
026:         * of short data type, the color Black being represented by 0,0,0 and 
027:         * White by 65536,65536,65536. In order to display these images, the 
028:         * default behavior is to dither the short values down to 8 bits. 
029:         * The dithering is done by calling the <code>decode16BitsTo8Bits</code> 
030:         * method for each short value that needs to be dithered. The method has
031:         * the following implementation:
032:         * <code>
033:         *       byte b;
034:         *       short s;
035:         *       s = s & 0xffff;
036:         *       b = (byte)((s >> 8) & 0xff);
037:         * </code>
038:         * If a different algorithm is to be used for the dithering, this class
039:         * should be subclassed and an appropriate implementation should be
040:         * provided for the <code>decode16BitsTo8Bits</code> method in the subclass.
041:         *
042:         * <p>If the palette contains image data that is signed short, as specified
043:         * by the SampleFormat tag, the dithering is done by calling 
044:         * <code>decodeSigned16BitsTo8Bits</code> instead. The method has the 
045:         * following implementation:
046:         * <code>
047:         *       byte b;
048:         *       short s;
049:         *       b = (byte)((s + Short.MIN_VALUE) >> 8);
050:         * </code>
051:         * In order to use a different algorithm for the dithering, this class 
052:         * should be subclassed and the method overridden.
053:         *
054:         * <p> If it is desired that the Palette be decoded such that the output
055:         * image is of short data type and no dithering is performed, the 
056:         * <code>setDecodePaletteAsShorts</code> method should be used. 
057:         *
058:         * <p><b> This class is not a committed part of the JAI API.  It may
059:         * be removed or changed in future releases of JAI.</b>
060:         *
061:         * @see TIFFDirectory
062:         */
063:        public class TIFFDecodeParam implements  ImageDecodeParam {
064:
065:            private boolean decodePaletteAsShorts = false;
066:            private Long ifdOffset = null;
067:            private boolean convertJPEGYCbCrToRGB = true;
068:
069:            /** Constructs a default instance of <code>TIFFDecodeParam</code>. */
070:            public TIFFDecodeParam() {
071:            }
072:
073:            /** 
074:             * If set, the entries in the palette will be decoded as shorts
075:             * and no short to byte lookup will be applied to them.
076:             */
077:            public void setDecodePaletteAsShorts(boolean decodePaletteAsShorts) {
078:                this .decodePaletteAsShorts = decodePaletteAsShorts;
079:            }
080:
081:            /**
082:             * Returns <code>true</code> if palette entries will be decoded as
083:             * shorts, resulting in an output image with short datatype.
084:             */
085:            public boolean getDecodePaletteAsShorts() {
086:                return decodePaletteAsShorts;
087:            }
088:
089:            /** 
090:             * Returns an unsigned 8 bit value computed by dithering the unsigned 
091:             * 16 bit value. Note that the TIFF specified short datatype is an
092:             * unsigned value, while Java's <code>short</code> datatype is a 
093:             * signed value. Therefore the Java <code>short</code> datatype cannot
094:             * be used to store the TIFF specified short value. A Java 
095:             * <code>int</code> is used as input instead to this method. The method
096:             * deals correctly only with 16 bit unsigned values.
097:             */
098:            public byte decode16BitsTo8Bits(int s) {
099:                return (byte) ((s >> 8) & 0xffff);
100:            }
101:
102:            /** 
103:             * Returns an unsigned 8 bit value computed by dithering the signed 
104:             * 16 bit value. This method deals correctly only with values in the 
105:             * 16 bit signed range.
106:             */
107:            public byte decodeSigned16BitsTo8Bits(short s) {
108:                return (byte) ((s + Short.MIN_VALUE) >> 8);
109:            }
110:
111:            /**
112:             * Sets the offset in the stream from which to read the image.  There
113:             * must be an Image File Directory (IFD) at that position or an error
114:             * will occur.  If <code>setIFDOffset()</code> is never invoked then
115:             * the decoder will assume that the TIFF stream is at the beginning of
116:             * the 8-byte image header.  If the directory offset is set and a page
117:             * number is supplied to the TIFF <code>ImageDecoder</code> then the
118:             * page will be the zero-relative index of the IFD in linked list of
119:             * IFDs beginning at the specified offset with a page of zero indicating
120:             * the directory at that offset.
121:             */
122:            public void setIFDOffset(long offset) {
123:                ifdOffset = new Long(offset);
124:            }
125:
126:            /**
127:             * Returns the value set by <code>setIFDOffset()</code> or
128:             * <code>null</code> if no value has been set.
129:             */
130:            public Long getIFDOffset() {
131:                return ifdOffset;
132:            }
133:
134:            /**
135:             * Sets a flag indicating whether to convert JPEG-compressed YCbCr data
136:             * to RGB.  The default value is <code>true</code>.  This flag is
137:             * ignored if the image data are not JPEG-compressed.
138:             */
139:            public void setJPEGDecompressYCbCrToRGB(
140:                    boolean convertJPEGYCbCrToRGB) {
141:                this .convertJPEGYCbCrToRGB = convertJPEGYCbCrToRGB;
142:            }
143:
144:            /**
145:             * Whether JPEG-compressed YCbCr data will be converted to RGB.
146:             */
147:            public boolean getJPEGDecompressYCbCrToRGB() {
148:                return convertJPEGYCbCrToRGB;
149:            }
150:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.