Source Code Cross Referenced for TIFFDecodeParam.java in  » Graphic-Library » xmlgraphics-commons-1.2 » org » apache » xmlgraphics » image » codec » tiff » 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 » Graphic Library » xmlgraphics commons 1.2 » org.apache.xmlgraphics.image.codec.tiff 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        /* $Id: TIFFDecodeParam.java 496556 2007-01-16 00:59:48Z cam $ */
019:
020:        package org.apache.xmlgraphics.image.codec.tiff;
021:
022:        import org.apache.xmlgraphics.image.codec.util.ImageDecodeParam;
023:
024:        /**
025:         * An instance of <code>ImageDecodeParam</code> for decoding images in
026:         * the TIFF format.
027:         *
028:         * <p> To determine the number of images present in a TIFF file, use
029:         * the <code>getNumPages()</code> method on the
030:         * <code>ImageDecoder</code> object that will be used to perform the
031:         * decoding.  The desired page number may be passed as an argument to
032:         * the <code>ImageDecoder.decodeAsRaster)()</code> or
033:         * <code>decodeAsRenderedImage()</code> methods.
034:         *
035:         * <p> For TIFF Palette color images, the colorMap always has entries
036:         * of short data type, the color Black being represented by 0,0,0 and 
037:         * White by 65536,65536,65536. In order to display these images, the 
038:         * default behavior is to dither the short values down to 8 bits. 
039:         * The dithering is done by calling the <code>decode16BitsTo8Bits</code> 
040:         * method for each short value that needs to be dithered. The method has
041:         * the following implementation:
042:         * <code>
043:         *       byte b;
044:         *       short s;
045:         *       s = s & 0xffff;
046:         *       b = (byte)((s >> 8) & 0xff);
047:         * </code>
048:         * If a different algorithm is to be used for the dithering, this class
049:         * should be subclassed and an appropriate implementation should be
050:         * provided for the <code>decode16BitsTo8Bits</code> method in the subclass.
051:         *
052:         * <p>If the palette contains image data that is signed short, as specified
053:         * by the SampleFormat tag, the dithering is done by calling 
054:         * <code>decodeSigned16BitsTo8Bits</code> instead. The method has the 
055:         * following implementation:
056:         * <code>
057:         *       byte b;
058:         *       short s;
059:         *       b = (byte)((s + Short.MIN_VALUE) >> 8);
060:         * </code>
061:         * In order to use a different algorithm for the dithering, this class 
062:         * should be subclassed and the method overridden.
063:         *
064:         * <p> If it is desired that the Palette be decoded such that the output
065:         * image is of short data type and no dithering is performed, the 
066:         * <code>setDecodePaletteAsShorts</code> method should be used. 
067:         *
068:         * <p><b> This class is not a committed part of the JAI API.  It may
069:         * be removed or changed in future releases of JAI.</b>
070:         *
071:         * @see TIFFDirectory
072:         */
073:        public class TIFFDecodeParam implements  ImageDecodeParam {
074:
075:            private boolean decodePaletteAsShorts = false;
076:            private Long ifdOffset = null;
077:            private boolean convertJPEGYCbCrToRGB = true;
078:
079:            /** Constructs a default instance of <code>TIFFDecodeParam</code>. */
080:            public TIFFDecodeParam() {
081:            }
082:
083:            /** 
084:             * If set, the entries in the palette will be decoded as shorts
085:             * and no short to byte lookup will be applied to them.
086:             */
087:            public void setDecodePaletteAsShorts(boolean decodePaletteAsShorts) {
088:                this .decodePaletteAsShorts = decodePaletteAsShorts;
089:            }
090:
091:            /**
092:             * Returns <code>true</code> if palette entries will be decoded as
093:             * shorts, resulting in an output image with short datatype.
094:             */
095:            public boolean getDecodePaletteAsShorts() {
096:                return decodePaletteAsShorts;
097:            }
098:
099:            /** 
100:             * Returns an unsigned 8 bit value computed by dithering the unsigned 
101:             * 16 bit value. Note that the TIFF specified short datatype is an
102:             * unsigned value, while Java's <code>short</code> datatype is a 
103:             * signed value. Therefore the Java <code>short</code> datatype cannot
104:             * be used to store the TIFF specified short value. A Java 
105:             * <code>int</code> is used as input instead to this method. The method
106:             * deals correctly only with 16 bit unsigned values.
107:             */
108:            public byte decode16BitsTo8Bits(int s) {
109:                return (byte) ((s >> 8) & 0xffff);
110:            }
111:
112:            /** 
113:             * Returns an unsigned 8 bit value computed by dithering the signed 
114:             * 16 bit value. This method deals correctly only with values in the 
115:             * 16 bit signed range.
116:             */
117:            public byte decodeSigned16BitsTo8Bits(short s) {
118:                return (byte) ((s + Short.MIN_VALUE) >> 8);
119:            }
120:
121:            /**
122:             * Sets the offset in the stream from which to read the image.  There
123:             * must be an Image File Directory (IFD) at that position or an error
124:             * will occur.  If <code>setIFDOffset()</code> is never invoked then
125:             * the decoder will assume that the TIFF stream is at the beginning of
126:             * the 8-byte image header.  If the directory offset is set and a page
127:             * number is supplied to the TIFF <code>ImageDecoder</code> then the
128:             * page will be the zero-relative index of the IFD in linked list of
129:             * IFDs beginning at the specified offset with a page of zero indicating
130:             * the directory at that offset.
131:             */
132:            public void setIFDOffset(long offset) {
133:                ifdOffset = new Long(offset);
134:            }
135:
136:            /**
137:             * Returns the value set by <code>setIFDOffset()</code> or
138:             * <code>null</code> if no value has been set.
139:             */
140:            public Long getIFDOffset() {
141:                return ifdOffset;
142:            }
143:
144:            /**
145:             * Sets a flag indicating whether to convert JPEG-compressed YCbCr data
146:             * to RGB.  The default value is <code>true</code>.  This flag is
147:             * ignored if the image data are not JPEG-compressed.
148:             */
149:            public void setJPEGDecompressYCbCrToRGB(
150:                    boolean convertJPEGYCbCrToRGB) {
151:                this .convertJPEGYCbCrToRGB = convertJPEGYCbCrToRGB;
152:            }
153:
154:            /**
155:             * Whether JPEG-compressed YCbCr data will be converted to RGB.
156:             */
157:            public boolean getJPEGDecompressYCbCrToRGB() {
158:                return convertJPEGYCbCrToRGB;
159:            }
160:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.