Source Code Cross Referenced for MlibScaleTableOpImage.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: MlibScaleTableOpImage.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/15 18:35:47 $
010:         * $State: Exp $
011:         */
012:        package com.sun.media.jai.mlib;
013:
014:        import java.awt.Rectangle;
015:        import java.awt.image.DataBuffer;
016:        import java.awt.image.Raster;
017:        import java.awt.image.RenderedImage;
018:        import java.awt.image.WritableRaster;
019:        import javax.media.jai.BorderExtender;
020:        import javax.media.jai.ImageLayout;
021:        import javax.media.jai.Interpolation;
022:        import javax.media.jai.InterpolationTable;
023:        import javax.media.jai.OpImage;
024:        import java.util.Map;
025:        import com.sun.medialib.mlib.*;
026:
027:        /**
028:         * An OpImage class that scales an image using interpolation coefficients 
029:         * specified in a table format.
030:         *
031:         */
032:        final class MlibScaleTableOpImage extends MlibScaleOpImage {
033:
034:            /**
035:             * Constructs an MlibScaleTableOpImage. The image dimensions are copied
036:             * from the source image.  The tile grid layout, SampleModel, and
037:             * ColorModel may optionally be specified by an ImageLayout object.
038:             *
039:             * @param source    a RenderedImage.
040:             * @param extender  a BorderExtender, or null.
041:             * @param layout    an ImageLayout optionally containing the tile
042:             *                  grid layout, SampleModel, and ColorModel, or null.
043:             * @param xScale    the x scaling factor.
044:             * @param yScale    the y scaling factor.
045:             * @param xTrans    the x translation factor.
046:             * @param yTrans    the y translation factor.
047:             * @param interp    the InterpolationTable object.
048:             */
049:            public MlibScaleTableOpImage(RenderedImage source,
050:                    BorderExtender extender, Map config, ImageLayout layout,
051:                    float xScale, float yScale, float xTrans, float yTrans,
052:                    Interpolation interp) {
053:                super (source, extender, config, layout, xScale, yScale, xTrans,
054:                        yTrans, interp, true);
055:            }
056:
057:            /**
058:             * Scale the given rectangle by the specified scale and translation 
059:             * factors. The sources are cobbled.
060:             *
061:             * @param sources   an array of sources, guarantee to provide all
062:             *                  necessary source data for computing the rectangle.
063:             * @param dest      a tile that contains the rectangle to be computed.
064:             * @param destRect  the rectangle within this OpImage to be processed.
065:             */
066:            protected void computeRect(Raster[] sources, WritableRaster dest,
067:                    Rectangle destRect) {
068:
069:                // Cast the Interpolation object to InterpolationTable object
070:                InterpolationTable jtable = (InterpolationTable) interp;
071:
072:                // The Medialib InterpolationTable class equivalent
073:                mediaLibImageInterpTable mlibInterpTable;
074:
075:                Raster source = sources[0];
076:                Rectangle srcRect = source.getBounds();
077:
078:                int formatTag = MediaLibAccessor.findCompatibleTag(sources,
079:                        dest);
080:
081:                MediaLibAccessor srcAccessor = new MediaLibAccessor(source,
082:                        srcRect, formatTag);
083:                MediaLibAccessor dstAccessor = new MediaLibAccessor(dest,
084:                        destRect, formatTag);
085:
086:                // Get the floating point scale factors
087:                float mlibScaleX = (float) scaleXRationalNum
088:                        / (float) scaleXRationalDenom;
089:                float mlibScaleY = (float) scaleYRationalNum
090:                        / (float) scaleYRationalDenom;
091:
092:                // Translation to be specified to Medialib. Note that we have to 
093:                // specify an additional translation since all images are 0 based
094:                // in Medialib.
095:
096:                // Calculate intermediate values.
097:                float tempDX = (float) (srcRect.x * scaleXRationalNum)
098:                        / (float) scaleXRationalDenom;
099:                float tempDY = (float) (srcRect.y * scaleYRationalNum)
100:                        / (float) scaleYRationalDenom;
101:
102:                float tx = transX - destRect.x + tempDX;
103:                float ty = transY - destRect.y + tempDY;
104:
105:                mediaLibImage srcML[], dstML[];
106:
107:                switch (dstAccessor.getDataType()) {
108:                case DataBuffer.TYPE_BYTE:
109:                case DataBuffer.TYPE_USHORT:
110:                case DataBuffer.TYPE_SHORT:
111:                case DataBuffer.TYPE_INT:
112:
113:                    mlibInterpTable = new mediaLibImageInterpTable(
114:                            Constants.MLIB_INT, jtable.getWidth(), jtable
115:                                    .getHeight(), jtable.getLeftPadding(),
116:                            jtable.getTopPadding(), jtable.getSubsampleBitsH(),
117:                            jtable.getSubsampleBitsV(), jtable
118:                                    .getPrecisionBits(), jtable
119:                                    .getHorizontalTableData(), jtable
120:                                    .getVerticalTableData());
121:
122:                    srcML = srcAccessor.getMediaLibImages();
123:                    dstML = dstAccessor.getMediaLibImages();
124:                    for (int i = 0; i < dstML.length; i++) {
125:                        Image.ZoomTranslateTable(dstML[i], srcML[i],
126:                                (double) mlibScaleX, (double) mlibScaleY,
127:                                (double) tx, (double) ty, mlibInterpTable,
128:                                Constants.MLIB_EDGE_DST_NO_WRITE);
129:                        MlibUtils.clampImage(dstML[i], getColorModel());
130:                    }
131:                    break;
132:
133:                case DataBuffer.TYPE_FLOAT:
134:
135:                    mlibInterpTable = new mediaLibImageInterpTable(
136:                            Constants.MLIB_FLOAT, jtable.getWidth(), jtable
137:                                    .getHeight(), jtable.getLeftPadding(),
138:                            jtable.getTopPadding(), jtable.getSubsampleBitsH(),
139:                            jtable.getSubsampleBitsV(), jtable
140:                                    .getPrecisionBits(), jtable
141:                                    .getHorizontalTableDataFloat(), jtable
142:                                    .getVerticalTableDataFloat());
143:
144:                    srcML = srcAccessor.getMediaLibImages();
145:                    dstML = dstAccessor.getMediaLibImages();
146:                    for (int i = 0; i < dstML.length; i++) {
147:                        Image.ZoomTranslateTable_Fp(dstML[i], srcML[i],
148:                                (double) mlibScaleX, (double) mlibScaleY,
149:                                (double) tx, (double) ty, mlibInterpTable,
150:                                Constants.MLIB_EDGE_DST_NO_WRITE);
151:                    }
152:                    break;
153:
154:                case DataBuffer.TYPE_DOUBLE:
155:
156:                    mlibInterpTable = new mediaLibImageInterpTable(
157:                            Constants.MLIB_DOUBLE, jtable.getWidth(), jtable
158:                                    .getHeight(), jtable.getLeftPadding(),
159:                            jtable.getTopPadding(), jtable.getSubsampleBitsH(),
160:                            jtable.getSubsampleBitsV(), jtable
161:                                    .getPrecisionBits(), jtable
162:                                    .getHorizontalTableDataDouble(), jtable
163:                                    .getVerticalTableDataDouble());
164:
165:                    srcML = srcAccessor.getMediaLibImages();
166:                    dstML = dstAccessor.getMediaLibImages();
167:                    for (int i = 0; i < dstML.length; i++) {
168:                        Image.ZoomTranslateTable_Fp(dstML[i], srcML[i],
169:                                (double) mlibScaleX, (double) mlibScaleY,
170:                                (double) tx, (double) ty, mlibInterpTable,
171:                                Constants.MLIB_EDGE_DST_NO_WRITE);
172:                    }
173:                    break;
174:
175:                default:
176:                    String className = this .getClass().getName();
177:                    throw new RuntimeException(JaiI18N.getString("Generic2"));
178:                }
179:
180:                if (dstAccessor.isDataCopy()) {
181:                    dstAccessor.clampDataArrays();
182:                    dstAccessor.copyDataToRaster();
183:                }
184:            }
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.