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


001:        /*
002:         * $RCSfile: UnpackedImageData.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:57:23 $
010:         * $State: Exp $
011:         */
012:        package javax.media.jai;
013:
014:        import java.awt.Rectangle;
015:        import java.awt.image.DataBuffer;
016:        import java.awt.image.Raster;
017:
018:        /**
019:         * This class is used by <code>PixelAccessor</code> to store unpacked
020:         * image data and the information needed to access it.  The data are stored in
021:         * a two-dimensional primitive array.
022:         *
023:         * @since JAI 1.1
024:         *
025:         */
026:        public final class UnpackedImageData {
027:
028:            /** The <code>Raster</code> containing the pixel data. */
029:            public final Raster raster;
030:
031:            /**
032:             * The rectangular region within the <code>Raster</code> where the
033:             * data are to be accessed.
034:             */
035:            public final Rectangle rect;
036:
037:            /** The type of the primitive array used to store the data. */
038:            public final int type;
039:
040:            /** The data array supplied to store the unpacked data. */
041:            public final Object data;
042:
043:            /**
044:             * The number of array elements to skip to get to the next
045:             * pixel on the same scanline.
046:             */
047:            public final int pixelStride;
048:
049:            /** The number of array elements per scanline. */
050:            public final int lineStride;
051:
052:            /**
053:             * The number of array elements from the beginning of the data array
054:             * to the first pixel of the <code>Rectangle</code> for all bands.
055:             */
056:            public final int[] bandOffsets;
057:
058:            /**
059:             * Indicates whether the <code>PixelAccessor</code> can and must set the
060:             * data back into the <code>Raster</code>. If the data does not need 
061:             * to be copied back to the <code>Raster</code>, this variable should be 
062:             * set to <code>false</code>. Only destinations can be set.
063:             */
064:            public final boolean convertToDest;
065:
066:            /** Constructs a PackedImageRaster.
067:             *  @param raster The <code>Raster</code> containing the pixel data.
068:             *  @param rect The rectangular region containing the data.
069:             *  @param type  The type of the primitive array supplied to store the data.
070:             *  @param data The data array supplied to store the data.
071:             *  @param pixelStride The data array increment needed to move from band x
072:             *                     of pixel i to band x of pixel i+1 on the same 
073:                                   scanline.
074:             *  @param lineStride The data array increment to move from the pixel x
075:             *                    of line i to pixel x of line i+1.
076:             *  @param bandOffsets The number of bytes from the start of the data array
077:             *                 to the location of the first pixel of the rectangle
078:             *                 for all bands.
079:             *  @param convertToDest A <code>boolean</code> indicating whether the data can and
080:             *             must be set back into the <code>Raster</code>. This applies
081:             *             only to destinations.
082:             */
083:            public UnpackedImageData(Raster raster, Rectangle rect, int type,
084:                    Object data, int pixelStride, int lineStride,
085:                    int[] bandOffsets, boolean convertToDest) {
086:                this .raster = raster;
087:                this .rect = rect;
088:                this .type = type;
089:                this .data = data;
090:                this .pixelStride = pixelStride;
091:                this .lineStride = lineStride;
092:                this .bandOffsets = bandOffsets;
093:                this .convertToDest = convertToDest;
094:            }
095:
096:            /**
097:             * Returns the two-dimensional byte data array, or <code>null</code>
098:             * if the data are not stored in a byte array.
099:             * The array format is <code>data[band][]</code> where the second
100:             * index is navigated using the pixel and line strides.
101:             * @return The two-dimensional byte data array.
102:             */
103:            public byte[][] getByteData() {
104:                return type == DataBuffer.TYPE_BYTE ? (byte[][]) data : null;
105:            }
106:
107:            /**
108:             * Returns byte data array for a specific band, or <code>null</code>
109:             * if the data are not stored in a byte array.
110:             * @param b The band whose data array is to be retrieved.
111:             * @return The one-dimensional byte data array for the requested band.
112:             */
113:            public byte[] getByteData(int b) {
114:                byte[][] d = getByteData();
115:                return d == null ? null : d[b];
116:            }
117:
118:            /**
119:             * Returns the two-dimensional short data array, or <code>null</code>
120:             * if the data are not stored in a short array.
121:             * The array format is <code>data[band][]</code> where the second
122:             * index is navigated using the pixel and line strides.
123:             * @return The two-dimensional short data array.
124:             */
125:            public short[][] getShortData() {
126:                return (type == DataBuffer.TYPE_USHORT || type == DataBuffer.TYPE_SHORT) ? (short[][]) data
127:                        : null;
128:            }
129:
130:            /**
131:             * Returns short data array for a specific band, or <code>null</code>
132:             * if the data are not stored in a short array.
133:             * @param b The band whose data array is to be retrieved.
134:             * @return The one-dimensional short data array for the requested band.
135:             */
136:            public short[] getShortData(int b) {
137:                short[][] d = getShortData();
138:                return d == null ? null : d[b];
139:            }
140:
141:            /**
142:             * Returns the two-dimensional integer data array, or <code>null</code>
143:             * if the data are not stored in an integer array.
144:             * The array format is <code>data[band][]</code> where the second
145:             * index is navigated using the pixel and line strides.
146:             * @return The two-dimensional int data array.
147:             */
148:            public int[][] getIntData() {
149:                return type == DataBuffer.TYPE_INT ? (int[][]) data : null;
150:            }
151:
152:            /**
153:             * Returns integer data array for a specific band, or <code>null</code>
154:             * if the data are not stored in an integer array.
155:             * @param b The band whose data array is to be retrieved.
156:             * @return The one-dimensional int data array for the requested band.
157:             */
158:            public int[] getIntData(int b) {
159:                int[][] d = getIntData();
160:                return d == null ? null : d[b];
161:            }
162:
163:            /**
164:             * Returns the two-dimensional float data array, or <code>null</code>
165:             * if the data are not stored in a float array.
166:             * The array format is <code>data[band][]</code> where the second
167:             * index is navigated using the pixel and line strides.
168:             * @return The two-dimensional float data array.
169:             */
170:            public float[][] getFloatData() {
171:                return type == DataBuffer.TYPE_FLOAT ? (float[][]) data : null;
172:            }
173:
174:            /**
175:             * Returns float data array for a specific band, or <code>null</code>
176:             * if the data are not stored in a float array.
177:             * @param b The band whose data array is to be retrieved.
178:             * @return The one-dimensional float data array for the requested band.
179:             */
180:            public float[] getFloatData(int b) {
181:                float[][] d = getFloatData();
182:                return d == null ? null : d[b];
183:            }
184:
185:            /**
186:             * Returns the two-dimensional double data array, or <code>null</code>
187:             * if the data are not stored in a double array.
188:             * The array format is <code>data[band][]</code> where the second
189:             * index is navigated using the pixel and line strides.
190:             * @return The two-dimensional double data array.
191:             */
192:            public double[][] getDoubleData() {
193:                return type == DataBuffer.TYPE_DOUBLE ? (double[][]) data
194:                        : null;
195:            }
196:
197:            /**
198:             * Returns double data array for a specific band, or <code>null</code>
199:             * if the data are not stored in a double array.
200:             * @param b The band whose data array is to be retrieved.
201:             * @return The one-dimensional double data array for the requested band.
202:             */
203:            public double[] getDoubleData(int b) {
204:                double[][] d = getDoubleData();
205:                return d == null ? null : d[b];
206:            }
207:
208:            /** Returns the offset for a band.
209:             *  @param b The band whose offset is to be returned.
210:             *  @return The offset of the requested band.
211:             */
212:            public int getOffset(int b) {
213:                return bandOffsets[b];
214:            }
215:
216:            /** Returns the minimum offset of all bands.
217:             *  @return The minimum offset of all bands.
218:             */
219:            public int getMinOffset() {
220:                int min = bandOffsets[0];
221:                for (int i = 1; i < bandOffsets.length; i++) {
222:                    min = Math.min(min, bandOffsets[i]);
223:                }
224:                return min;
225:            }
226:
227:            /** Returns the maximum offset of all bands.
228:             *  @return The maximum offset of all the bands.
229:             */
230:            public int getMaxOffset() {
231:                int max = bandOffsets[0];
232:                for (int i = 1; i < bandOffsets.length; i++) {
233:                    max = Math.max(max, bandOffsets[i]);
234:                }
235:                return max;
236:            }
237:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.