Source Code Cross Referenced for MlibAndOpImage.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: MlibAndOpImage.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:50 $
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.PixelInterleavedSampleModel;
017:        import java.awt.image.Raster;
018:        import java.awt.image.RenderedImage;
019:        import java.awt.image.SampleModel;
020:        import java.awt.image.WritableRaster;
021:        import javax.media.jai.ImageLayout;
022:        import javax.media.jai.OpImage;
023:        import javax.media.jai.PointOpImage;
024:        import java.util.Map;
025:        import com.sun.medialib.mlib.*;
026:
027:        // import com.sun.media.jai.test.OpImageTester;
028:
029:        /**
030:         * An OpImage that performs the And operation on 2 images through mediaLib.
031:         *
032:         */
033:        final class MlibAndOpImage extends PointOpImage {
034:
035:            /**
036:             * Constructs an MlibAndOpImage. The image dimensions are copied
037:             * from the source image.  The tile grid layout, SampleModel, and
038:             * ColorModel may optionally be specified by an ImageLayout object.
039:             *
040:             * @param source    a RenderedImage.
041:             * @param layout    an ImageLayout optionally containing the tile
042:             *                  grid layout, SampleModel, and ColorModel, or null.
043:             */
044:            public MlibAndOpImage(RenderedImage source1, RenderedImage source2,
045:                    Map config, ImageLayout layout) {
046:                super (source1, source2, layout, config, true);
047:            }
048:
049:            /**
050:             * And the pixel values of a rectangle from the two sources.
051:             * The sources are cobbled.
052:             *
053:             * @param sources   an array of sources, guarantee to provide all
054:             *                  necessary source data for computing the rectangle.
055:             * @param dest      a tile that contains the rectangle to be computed.
056:             * @param destRect  the rectangle within this OpImage to be processed.
057:             */
058:            protected void computeRect(Raster[] sources, WritableRaster dest,
059:                    Rectangle destRect) {
060:
061:                int formatTag = MediaLibAccessor.findCompatibleTag(sources,
062:                        dest);
063:
064:                MediaLibAccessor srcAccessor1 = new MediaLibAccessor(
065:                        sources[0], destRect, formatTag);
066:                MediaLibAccessor srcAccessor2 = new MediaLibAccessor(
067:                        sources[1], destRect, formatTag);
068:                MediaLibAccessor dstAccessor = new MediaLibAccessor(dest,
069:                        destRect, formatTag);
070:
071:                switch (dstAccessor.getDataType()) {
072:                case DataBuffer.TYPE_BYTE:
073:                case DataBuffer.TYPE_USHORT:
074:                case DataBuffer.TYPE_SHORT:
075:                case DataBuffer.TYPE_INT:
076:                    mediaLibImage[] srcML1 = srcAccessor1.getMediaLibImages();
077:                    mediaLibImage[] srcML2 = srcAccessor2.getMediaLibImages();
078:                    mediaLibImage[] dstML = dstAccessor.getMediaLibImages();
079:                    for (int i = 0; i < dstML.length; i++) {
080:                        Image.And(dstML[i], srcML1[i], srcML2[i]);
081:                    }
082:                    break;
083:                default:
084:                    String className = this .getClass().getName();
085:                    throw new RuntimeException(className
086:                            + JaiI18N.getString("Generic2"));
087:                }
088:
089:                if (dstAccessor.isDataCopy()) {
090:                    dstAccessor.clampDataArrays();
091:                    dstAccessor.copyDataToRaster();
092:                }
093:            }
094:
095:            //     public static void main (String args[]) {
096:            //         System.out.println("MlibAndOpImage Test");
097:            //         ImageLayout layout;
098:            //         OpImage src1, src2, dst;
099:            //         Rectangle rect = new Rectangle(0, 0, 5, 5);
100:
101:            //         System.out.println("1. PixelInterleaved byte 3-band");
102:            //         layout = OpImageTester.createImageLayout(0, 0, 800, 800, 0, 0,
103:            // 						 200, 200, DataBuffer.TYPE_BYTE,
104:            // 						 3, false);
105:            //         src1 = OpImageTester.createRandomOpImage(layout);
106:            //         src2 = OpImageTester.createRandomOpImage(layout);
107:            //         dst = new MlibAndOpImage(src1, src2, null, null);
108:            //         OpImageTester.testOpImage(dst, rect);
109:            //         OpImageTester.timeOpImage(dst, 10);
110:
111:            //         System.out.println("2. Banded byte 3-band");
112:            //         layout = OpImageTester.createImageLayout(0, 0, 800, 800, 0, 0,
113:            // 						 200, 200, DataBuffer.TYPE_BYTE,
114:            // 						 3, true);
115:            //         src1 = OpImageTester.createRandomOpImage(layout);
116:            //         src2 = OpImageTester.createRandomOpImage(layout);
117:            //         dst = new MlibAndOpImage(src1, src2, null, null);
118:            //         OpImageTester.testOpImage(dst, rect);
119:            //         OpImageTester.timeOpImage(dst, 10);
120:
121:            //         System.out.println("3. PixelInterleaved int 3-band");
122:            //         layout = OpImageTester.createImageLayout(0, 0, 512, 512, 0, 0, 200, 200,
123:            // 						 DataBuffer.TYPE_INT, 3, false);
124:            //         src1 = OpImageTester.createRandomOpImage(layout);
125:            //         src2 = OpImageTester.createRandomOpImage(layout);
126:            //         dst = new MlibAndOpImage(src1, src2, null, null);
127:            //         OpImageTester.testOpImage(dst, rect);
128:            //         OpImageTester.timeOpImage(dst, 10);
129:
130:            //         System.out.println("4. Banded int 3-band");
131:            //         layout = OpImageTester.createImageLayout(0, 0, 512, 512, 0, 0,
132:            // 						 200, 200, DataBuffer.TYPE_INT,
133:            // 						 3, true);
134:            //         src1 = OpImageTester.createRandomOpImage(layout);
135:            //         src2 = OpImageTester.createRandomOpImage(layout);
136:            //         dst = new MlibAndOpImage(src1, src2, null, null);
137:            //         OpImageTester.testOpImage(dst, rect);
138:            //         OpImageTester.timeOpImage(dst, 10);
139:            //     }
140:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.