Source Code Cross Referenced for MlibDilate3PlusOpImage.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » com » sun » media » jai » mlib » 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.mlib 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: MlibDilate3PlusOpImage.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.2 $
009:         * $Date: 2005/12/09 00:20:28 $
010:         * $State: Exp $
011:         */
012:        package com.sun.media.jai.mlib;
013:
014:        import java.awt.Rectangle;
015:        import java.awt.RenderingHints;
016:        import java.awt.image.DataBuffer;
017:        import java.awt.image.SampleModel;
018:        import java.awt.image.Raster;
019:        import java.awt.image.RenderedImage;
020:        import java.awt.image.WritableRaster;
021:        import java.awt.image.renderable.ParameterBlock;
022:        import java.awt.image.renderable.RenderedImageFactory;
023:        import javax.media.jai.AreaOpImage;
024:        import javax.media.jai.BorderExtender;
025:        import javax.media.jai.ImageLayout;
026:        import javax.media.jai.JAI;
027:        import javax.media.jai.KernelJAI;
028:        import javax.media.jai.OpImage;
029:        import java.util.Map;
030:        import com.sun.medialib.mlib.*;
031:
032:        // import com.sun.media.jai.test.OpImageTester;
033:
034:        /**
035:         * An OpImage class to perform dilation on a source image
036:         * for the specific case when the kernel is a 3x3 plus shape
037:         * with the key position in the middle,
038:         * using mediaLib, of course :-).
039:         *
040:         * @see javax.media.jai.operator.DilateDescriptor
041:         * @see KernelJAI
042:         */
043:        final class MlibDilate3PlusOpImage extends AreaOpImage {
044:
045:            // Since medialib expects single banded data with IndexColorModel, we
046:            // should not expand the indexed data
047:            private static Map configHelper(Map configuration) {
048:
049:                Map config;
050:
051:                if (configuration == null) {
052:
053:                    config = new RenderingHints(
054:                            JAI.KEY_REPLACE_INDEX_COLOR_MODEL, Boolean.FALSE);
055:
056:                } else {
057:
058:                    config = configuration;
059:
060:                    // If the user has specified a hint for this, then we don't
061:                    // want to change it, so change only if this hint is not 
062:                    // already specified
063:                    if (!(config.containsKey(JAI.KEY_REPLACE_INDEX_COLOR_MODEL))) {
064:                        RenderingHints hints = (RenderingHints) configuration;
065:                        config = (RenderingHints) hints.clone();
066:                        config.put(JAI.KEY_REPLACE_INDEX_COLOR_MODEL,
067:                                Boolean.FALSE);
068:                    }
069:                }
070:
071:                return config;
072:            }
073:
074:            /**
075:             * Creates a MlibDilate3PlusOpImage given the image source
076:             * The image dimensions are
077:             * derived from the source image.  The tile grid layout,
078:             * SampleModel, and ColorModel may optionally be specified by an
079:             * ImageLayout object.
080:             *
081:             * @param source a RenderedImage.
082:             * @param extender a BorderExtender, or null.
083:
084:             *        or null.  If null, a default cache will be used.
085:             * @param layout an ImageLayout optionally containing the tile grid layout,
086:             *        SampleModel, and ColorModel, or null.
087:             */
088:            public MlibDilate3PlusOpImage(RenderedImage source,
089:                    BorderExtender extender, Map config, ImageLayout layout) {
090:                super (source, layout, configHelper(config), true, extender, 1, //kernel.getLeftPadding(),
091:                        1, //kernel.getRightPadding(),
092:                        1, //kernel.getTopPadding(),
093:                        1 //kernel.getBottomPadding()
094:                );
095:            }
096:
097:            /**
098:             * Performs dilation on a specified rectangle. The sources are
099:             * cobbled.
100:             *
101:             * @param sources an array of source Rasters, guaranteed to provide all
102:             *                necessary source data for computing the output.
103:             * @param dest a WritableRaster tile containing the area to be computed.
104:             * @param destRect the rectangle within dest to be processed.
105:             */
106:            protected void computeRect(Raster[] sources, WritableRaster dest,
107:                    Rectangle destRect) {
108:
109:                Raster source = sources[0];
110:                Rectangle srcRect = mapDestRect(destRect, 0);
111:
112:                int formatTag = MediaLibAccessor.findCompatibleTag(sources,
113:                        dest);
114:
115:                MediaLibAccessor srcAccessor = new MediaLibAccessor(source,
116:                        srcRect, formatTag, true);
117:                MediaLibAccessor dstAccessor = new MediaLibAccessor(dest,
118:                        destRect, formatTag, true);
119:                int numBands = getSampleModel().getNumBands();
120:
121:                mediaLibImage[] srcML = srcAccessor.getMediaLibImages();
122:                mediaLibImage[] dstML = dstAccessor.getMediaLibImages();
123:                for (int i = 0; i < dstML.length; i++) {
124:                    switch (dstAccessor.getDataType()) {
125:                    case DataBuffer.TYPE_BYTE:
126:                    case DataBuffer.TYPE_USHORT:
127:                    case DataBuffer.TYPE_SHORT:
128:                    case DataBuffer.TYPE_INT:
129:                        Image.Dilate4(dstML[i], srcML[i]);
130:                        break;
131:                    case DataBuffer.TYPE_FLOAT:
132:                    case DataBuffer.TYPE_DOUBLE:
133:                        Image.Dilate4_Fp(dstML[i], srcML[i]);
134:                        break;
135:                    default:
136:                        String className = this .getClass().getName();
137:                        throw new RuntimeException(JaiI18N
138:                                .getString("Generic2"));
139:                    }
140:                }
141:
142:                if (dstAccessor.isDataCopy()) {
143:                    dstAccessor.copyDataToRaster();
144:                }
145:            }
146:
147:            //     public static OpImage createTestImage(OpImageTester oit) {
148:            //         float data[] = {0.05f,0.10f,0.05f,
149:            //                         0.10f,0.40f,0.10f,
150:            //                         0.05f,0.10f,0.05f};
151:            //         KernelJAI kJAI = new KernelJAI(3,3,1,1,data);
152:            //         return new MlibDilate4OpImage(oit.getSource(), null, null,
153:            //                                           new ImageLayout(oit.getSource()),
154:            //                                           kJAI);
155:            //     }
156:
157:            //     public static void main (String args[]) {
158:            //         String classname = "com.sun.media.jai.mlib.MlibDilate4OpImage";
159:            //         OpImageTester.performDiagnostics(classname,args);
160:            //     }
161:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.