Source Code Cross Referenced for TIFFTranscoder.java in  » Graphic-Library » batik » org » apache » batik » transcoder » image » 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 » batik » org.apache.batik.transcoder.image 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Licensed to the Apache Software Foundation (ASF) under one or more
004:           contributor license agreements.  See the NOTICE file distributed with
005:           this work for additional information regarding copyright ownership.
006:           The ASF licenses this file to You under the Apache License, Version 2.0
007:           (the "License"); you may not use this file except in compliance with
008:           the License.  You may obtain a copy of the License at
009:
010:               http://www.apache.org/licenses/LICENSE-2.0
011:
012:           Unless required by applicable law or agreed to in writing, software
013:           distributed under the License is distributed on an "AS IS" BASIS,
014:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:           See the License for the specific language governing permissions and
016:           limitations under the License.
017:
018:         */
019:
020:        package org.apache.batik.transcoder.image;
021:
022:        import java.awt.image.BufferedImage;
023:        import java.awt.image.SinglePixelPackedSampleModel;
024:
025:        import org.apache.batik.bridge.UserAgent;
026:        import org.apache.batik.transcoder.TranscoderException;
027:        import org.apache.batik.transcoder.TranscoderOutput;
028:        import org.apache.batik.transcoder.TranscodingHints;
029:        import org.apache.batik.transcoder.keys.StringKey;
030:
031:        /**
032:         * This class is an <tt>ImageTranscoder</tt> that produces a TIFF image.
033:         *
034:         * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
035:         * @version $Id: TIFFTranscoder.java 475477 2006-11-15 22:44:28Z cam $
036:         */
037:        public class TIFFTranscoder extends ImageTranscoder {
038:
039:            /**
040:             * Constructs a new transcoder that produces tiff images.
041:             */
042:            public TIFFTranscoder() {
043:                hints.put(KEY_FORCE_TRANSPARENT_WHITE, Boolean.FALSE);
044:            }
045:
046:            /** @return the transcoder's user agent */
047:            public UserAgent getUserAgent() {
048:                return this .userAgent;
049:            }
050:
051:            /**
052:             * Creates a new ARGB image with the specified dimension.
053:             * @param width the image width in pixels
054:             * @param height the image height in pixels
055:             */
056:            public BufferedImage createImage(int width, int height) {
057:                return new BufferedImage(width, height,
058:                        BufferedImage.TYPE_INT_ARGB);
059:            }
060:
061:            private WriteAdapter getWriteAdapter(String className) {
062:                WriteAdapter adapter;
063:                try {
064:                    Class clazz = Class.forName(className);
065:                    adapter = (WriteAdapter) clazz.newInstance();
066:                    return adapter;
067:                } catch (ClassNotFoundException e) {
068:                    return null;
069:                } catch (InstantiationException e) {
070:                    return null;
071:                } catch (IllegalAccessException e) {
072:                    return null;
073:                }
074:            }
075:
076:            /**
077:             * Writes the specified image to the specified output.
078:             * @param img the image to write
079:             * @param output the output where to store the image
080:             * @throws TranscoderException if an error occured while storing the image
081:             */
082:            public void writeImage(BufferedImage img, TranscoderOutput output)
083:                    throws TranscoderException {
084:
085:                //
086:                // This is a trick so that viewers which do not support the alpha
087:                // channel will see a white background (and not a black one).
088:                //
089:                boolean forceTransparentWhite = false;
090:
091:                if (hints
092:                        .containsKey(PNGTranscoder.KEY_FORCE_TRANSPARENT_WHITE)) {
093:                    forceTransparentWhite = ((Boolean) hints
094:                            .get(PNGTranscoder.KEY_FORCE_TRANSPARENT_WHITE))
095:                            .booleanValue();
096:                }
097:
098:                if (forceTransparentWhite) {
099:                    SinglePixelPackedSampleModel sppsm;
100:                    sppsm = (SinglePixelPackedSampleModel) img.getSampleModel();
101:                    forceTransparentWhite(img, sppsm);
102:                }
103:
104:                WriteAdapter adapter = getWriteAdapter("org.apache.batik.ext.awt.image.codec.tiff.TIFFTranscoderInternalCodecWriteAdapter");
105:                if (adapter == null) {
106:                    adapter = getWriteAdapter("org.apache.batik.transcoder.image.TIFFTranscoderImageIOWriteAdapter");
107:                }
108:                if (adapter == null) {
109:                    throw new TranscoderException(
110:                            "Could not write TIFF file because no WriteAdapter is availble");
111:                }
112:                adapter.writeImage(this , img, output);
113:            }
114:
115:            // --------------------------------------------------------------------
116:            // TIFF specific interfaces
117:            // --------------------------------------------------------------------
118:
119:            /**
120:             * This interface is used by <tt>TIFFTranscoder</tt> to write TIFF images 
121:             * through different codecs.
122:             *
123:             * @version $Id: TIFFTranscoder.java 475477 2006-11-15 22:44:28Z cam $
124:             */
125:            public interface WriteAdapter {
126:
127:                /**
128:                 * Writes the specified image to the specified output.
129:                 * @param transcoder the calling PNGTranscoder
130:                 * @param img the image to write
131:                 * @param output the output where to store the image
132:                 * @throws TranscoderException if an error occured while storing the image
133:                 */
134:                void writeImage(TIFFTranscoder transcoder, BufferedImage img,
135:                        TranscoderOutput output) throws TranscoderException;
136:
137:            }
138:
139:            // --------------------------------------------------------------------
140:            // Keys definition
141:            // --------------------------------------------------------------------
142:
143:            /**
144:             * The forceTransparentWhite key.
145:             *
146:             * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
147:             * <TR>
148:             * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH>
149:             * <TD VALIGN="TOP">KEY_FORCE_TRANSPARENT_WHITE</TD></TR>
150:             * <TR>
151:             * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH>
152:             * <TD VALIGN="TOP">Boolean</TD></TR>
153:             * <TR>
154:             * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH>
155:             * <TD VALIGN="TOP">false</TD></TR>
156:             * <TR>
157:             * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH>
158:             * <TD VALIGN="TOP">No</TD></TR>
159:             * <TR>
160:             * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH>
161:             * <TD VALIGN="TOP">It controls whether the encoder should
162:             * force the image's fully transparent pixels to be fully transparent
163:             * white instead of fully transparent black.  This is usefull when the
164:             * encoded TIFF is displayed in a viewer which does not support TIFF
165:             * transparency and lets the image display with a white background instead
166:             * of a black background. <br /> 
167:             *
168:             * However, note that the modified image will display differently
169:             * over a white background in a viewer that supports
170:             * transparency.</TD></TR>
171:             * </TABLE> 
172:             */
173:            public static final TranscodingHints.Key KEY_FORCE_TRANSPARENT_WHITE = ImageTranscoder.KEY_FORCE_TRANSPARENT_WHITE;
174:
175:            /**
176:             * The compression method for the image.
177:             * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
178:             * <TR>
179:             * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH>
180:             * <TD VALIGN="TOP">KEY_COMPRESSION_METHOD</TD></TR>
181:             * <TR>
182:             * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH>
183:             * <TD VALIGN="TOP">String ("none", "packbits", "jpeg" etc.)</TD></TR>
184:             * <TR>
185:             * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH>
186:             * <TD VALIGN="TOP">"none" (no compression)</TD></TR>
187:             * <TR>
188:             * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH>
189:             * <TD VALIGN="TOP">Recommended</TD></TR>
190:             * <TR>
191:             * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH>
192:             * <TD VALIGN="TOP">Specify the compression method used to encode the image.</TD></TR>
193:             * </TABLE>
194:             */
195:            public static final TranscodingHints.Key KEY_COMPRESSION_METHOD = new StringKey();
196:
197:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.