Source Code Cross Referenced for MlibFilteredSubsampleOpImage.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: MlibFilteredSubsampleOpImage.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:56 $
010:         * $State: Exp $
011:         */package com.sun.media.jai.mlib;
012:
013:        import java.awt.Rectangle;
014:        import java.awt.image.DataBuffer;
015:        import java.awt.image.Raster;
016:        import java.awt.image.RenderedImage;
017:        import java.awt.image.WritableRaster;
018:        import javax.media.jai.ImageLayout;
019:        import javax.media.jai.Interpolation;
020:        import javax.media.jai.InterpolationNearest;
021:        import javax.media.jai.OpImage;
022:        import java.util.Map;
023:        import javax.media.jai.BorderExtender;
024:        import com.sun.media.jai.opimage.FilteredSubsampleOpImage;
025:        import com.sun.medialib.mlib.*;
026:
027:        /**
028:         * <p> A class extending <code>FilteredSubsampleOpImage</code> to
029:         * subsample and antialias filter images using medialib.
030:         *
031:         * @see FilteredSubsampleOpImage
032:         */
033:        final class MlibFilteredSubsampleOpImage extends
034:                FilteredSubsampleOpImage {
035:
036:            protected double[] m_hKernel;
037:            protected double[] m_vKernel;
038:
039:            private static final boolean DEBUG = false;
040:
041:            /** <p> <code>MlibFilteredSubsampleOpImage</code> constructs an OpImage representing
042:             * filtered integral subsampling.  The scale factors represent the ratio of
043:             * source to destination dimensions.
044:             *
045:             * @param source a RenderedImage.
046:             * @param extender a BorderExtender, or null.
047:             * @param config a Map object possibly holding tile cache information
048:             * @param layout an ImageLayout optionally containing the tile grid layout,
049:             *	  SampleModel, and ColorModel, or null.
050:             * @param interp a Interpolation object to use for resampling.
051:             * @param scaleX downsample factor along x axis.
052:             * @param scaleY downsample factor along y axis.
053:             * @param qsFilter symmetric filter coefficients (partial kernel).
054:             * @throws IllegalArgumentException if the interp type is not one of:
055:             *    INTERP_NEAREST, INTERP_BILINEAR, INTERP_BICUBIC, or INTERP_BICUBIC_2
056:             */
057:            public MlibFilteredSubsampleOpImage(RenderedImage source,
058:                    BorderExtender extender, Map config, ImageLayout layout,
059:                    int scaleX, int scaleY, float[] qsFilter,
060:                    Interpolation interp) {
061:
062:                // Propagate to FilteredSubsampleOpImage constructor
063:                super (source, extender, config, layout, scaleX, scaleY,
064:                        qsFilter, interp);
065:
066:                // If enabled, print debug information
067:                if (DEBUG)
068:                    System.out.println("Object: MlibFilteredSubsampleOpImage");
069:
070:                // Copy floating arrays to medialib double arrays
071:                m_hKernel = new double[hKernel.length];
072:                m_vKernel = new double[vKernel.length];
073:                if (DEBUG)
074:                    System.out.print("\n hParity: " + hParity + " hKernel: ");
075:                for (int i = 0; i < hKernel.length; i++) {
076:                    m_hKernel[i] = (double) hKernel[i];
077:                    if (DEBUG)
078:                        System.out.print(" " + m_hKernel[i]);
079:                } // for i
080:                if (DEBUG)
081:                    System.out.print("\n vParity: " + vParity + " vKernel: ");
082:                for (int j = 0; j < vKernel.length; j++) {
083:                    m_vKernel[j] = (double) vKernel[j];
084:                    if (DEBUG)
085:                        System.out.print(" " + m_vKernel[j]);
086:                } // for j
087:                if (DEBUG)
088:                    System.out.println("\n");
089:
090:            } // MlibFilteredSubsampleOpImage
091:
092:            /**
093:             * <p> Performs a combined subsample/filter operation on a specified rectangle.
094:             * The sources are cobbled.
095:             *
096:             * @param sources  an array of source Rasters, guaranteed to provide all
097:             *                 necessary source data for computing the output.
098:             * @param dest     a WritableRaster  containing the area to be computed.
099:             * @param destRect the rectangle within dest to be processed.
100:             */
101:            public void computeRect(Raster[] sources, WritableRaster dest,
102:                    Rectangle destRect) {
103:
104:                // Get RasterAccessor tag
105:                int formatTag = MediaLibAccessor.findCompatibleTag(sources,
106:                        dest);
107:
108:                // Get destination accessor.
109:                MediaLibAccessor dst = new MediaLibAccessor(dest, destRect,
110:                        formatTag);
111:
112:                // Get source accessor.
113:                MediaLibAccessor src = new MediaLibAccessor(sources[0],
114:                        mapDestRect(destRect, 0), formatTag);
115:
116:                // Medialib requires translation terms (java version doesn't)
117:                int transX = m_hKernel.length - (scaleX + 1) / 2
118:                        - (hParity * (1 + scaleX)) % 2;
119:                int transY = m_vKernel.length - (scaleY + 1) / 2
120:                        - (vParity * (1 + scaleY)) % 2;
121:                mediaLibImage srcML[], dstML[];
122:                switch (dst.getDataType()) {
123:                case DataBuffer.TYPE_BYTE:
124:                case DataBuffer.TYPE_USHORT:
125:                case DataBuffer.TYPE_SHORT:
126:                case DataBuffer.TYPE_INT:
127:                    srcML = src.getMediaLibImages();
128:                    dstML = dst.getMediaLibImages();
129:                    for (int i = 0; i < dstML.length; i++) {
130:                        Image.FilteredSubsample(dstML[i], srcML[i], scaleX,
131:                                scaleY, transX, transY, m_hKernel, m_vKernel,
132:                                hParity, vParity,
133:                                Constants.MLIB_EDGE_DST_NO_WRITE);
134:                    } // for
135:                    break;
136:                case DataBuffer.TYPE_FLOAT:
137:                case DataBuffer.TYPE_DOUBLE:
138:                    srcML = src.getMediaLibImages();
139:                    dstML = dst.getMediaLibImages();
140:                    for (int i = 0; i < dstML.length; i++) {
141:                        Image.FilteredSubsample_Fp(dstML[i], srcML[i], scaleX,
142:                                scaleY, transX, transY, m_hKernel, m_vKernel,
143:                                hParity, vParity,
144:                                Constants.MLIB_EDGE_DST_NO_WRITE);
145:                    } // for
146:                    break;
147:                default:
148:                    throw new IllegalArgumentException(JaiI18N
149:                            .getString("Generic2"));
150:                } // switch getDataType
151:
152:                // If the RasterAccessor set up a temporary write buffer for the
153:                // operator, tell it to copy that data to the destination Raster.
154:                if (dst.isDataCopy()) {
155:                    dst.clampDataArrays();
156:                    dst.copyDataToRaster();
157:                } // if isDataCopy
158:
159:            } // computeRect
160:
161:        } // class MlibFilteredSubsampleOpImage
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.