Source Code Cross Referenced for BufferedImage.java in  » 6.0-JDK-Modules » j2me » java » awt » image » 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 » j2me » java.awt.image 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)BufferedImage.java	1.21 06/10/10
003:         *
004:         * Copyright  1990-2006 Sun Microsystems, Inc. All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License version
009:         * 2 only, as published by the Free Software Foundation. 
010:         * 
011:         * This program is distributed in the hope that it will be useful, but
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:         * General Public License version 2 for more details (a copy is
015:         * included at /legal/license.txt). 
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * version 2 along with this work; if not, write to the Free Software
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA 
021:         * 
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023:         * Clara, CA 95054 or visit www.sun.com if you need additional
024:         * information or have any questions. 
025:         *
026:         */
027:
028:        package java.awt.image;
029:
030:        import java.awt.Toolkit;
031:        import java.util.Hashtable;
032:        import java.util.Vector;
033:        import sun.awt.image.BufferedImagePeer;
034:        import java.awt.GraphicsEnvironment;
035:        import java.awt.Graphics2D;
036:
037:        /**
038:         *
039:         * The <code>BufferedImage</code> subclass describes an {@link Image} with
040:         * an accessible buffer of image data.
041:         * A <code>BufferedImage</code> is comprised of a {@link ColorModel} and a
042:         * {@link Raster} of image data.
043:         * The number and types of bands in the {@link SampleModel} of the
044:         * <code>Raster</code> must match the number and types required by the
045:         * <code>ColorModel</code> to represent its color and alpha components.
046:         * All <code>BufferedImage</code> objects have an upper left corner
047:         * coordinate of (0,&nbsp;0).  Any <code>Raster</code> used to construct a
048:         * <code>BufferedImage</code> must therefore have minX=0 and minY=0.
049:         * @see ColorModel
050:         * @see Raster
051:         * @see WritableRaster
052:         * @version 10 Feb 1997
053:         */
054:
055:        public class BufferedImage extends java.awt.Image //                           implements WritableRenderedImage
056:        {
057:            //int        imageType = TYPE_CUSTOM;
058:
059:            /** The peer used to implement BufferedImage. */
060:
061:            private transient BufferedImagePeer peer;
062:            // ### Serialization difference
063:            //  WritableRaster raster;
064:
065:            // ### Serialization difference
066:            // OffScreenImageSource osis;
067:
068:            //    Hashtable properties;
069:
070:            //    boolean    isAlphaPremultiplied;// If true, alpha has been premultiplied in
071:            // color channels
072:
073:            /**
074:             * Image Type Constants
075:             */
076:
077:            /**
078:             * Image type is not recognized so it must be a customized
079:             * image.  This type is only used as a return value for the getType()
080:             * method.
081:             */
082:            public static final int TYPE_CUSTOM = 0;
083:            /**
084:             * Represents an image with 8-bit RGB color components packed into
085:             * integer pixels.  The image has a {@link DirectColorModel} without
086:             * alpha.
087:             */
088:            public static final int TYPE_INT_RGB = 1;
089:            /**
090:             * Represents an image with 8-bit RGBA color components packed into
091:             * integer pixels.  The image has a <code>DirectColorModel</code>
092:             * with alpha. The color data in this image is considered not to be
093:             * premultiplied with alpha.  When this type is used as the
094:             * <code>imageType</code> argument to a <code>BufferedImage</code>
095:             * constructor, the created image is consistent with images
096:             * created in the JDK1.1 and earlier releases.
097:             */
098:            public static final int TYPE_INT_ARGB = 2;
099:            /**
100:             * Represents an image with 8-bit RGBA color components packed into
101:             * integer pixels.  The image has a <code>DirectColorModel</code>
102:             * with alpha.  The color data in this image is considered to be
103:             * premultiplied with alpha.
104:             */
105:            public static final int TYPE_INT_ARGB_PRE = 3;
106:            /**
107:             * Represents an image with 8-bit RGB color components, corresponding
108:             * to a Windows- or Solaris- style BGR color model, with the colors
109:             * Blue, Green, and Red packed into integer pixels.  There is no alpha.
110:             * The image has a {@link ComponentColorModel}.
111:             */
112:            public static final int TYPE_INT_BGR = 4;
113:            /**
114:             * Represents an image with 8-bit RGB color components, corresponding
115:             * to a Windows-style BGR color model) with the colors Blue, Green,
116:             * and Red stored in 3 bytes.  There is no alpha.  The image has a
117:             * <code>ComponentColorModel</code>.
118:             */
119:            //    public static final int TYPE_3BYTE_BGR = 5;
120:            /**
121:             * Represents an image with 8-bit RGBA color components with the colors
122:             * Blue, Green, and Red stored in 3 bytes and 1 byte of alpha.  The
123:             * image has a <code>ComponentColorModel</code> with alpha.  The
124:             * color data in this image is considered not to be premultiplied with
125:             * alpha.  The byte data is interleaved in a single
126:             * byte array in the order A, B, G, R
127:             * from lower to higher byte addresses within each pixel.
128:             */
129:            //    public static final int TYPE_4BYTE_ABGR = 6;
130:            /**
131:             * Represents an image with 8-bit RGBA color components with the colors
132:             * Blue, Green, and Red stored in 3 bytes and 1 byte of alpha.  The
133:             * image has a <code>ComponentColorModel</code> with alpha. The color
134:             * data in this image is considered to be premultiplied with alpha.
135:             * The byte data is interleaved in a single byte array in the order
136:             * A, B, G, R from lower to higher byte addresses within each pixel.
137:             */
138:            //    public static final int TYPE_4BYTE_ABGR_PRE = 7;
139:            /**
140:             * Represents an image with 5-6-5 RGB color components (5-bits red,
141:             * 6-bits green, 5-bits blue) with no alpha.  This image has
142:             * a <code>DirectColorModel</code>.
143:             */
144:            public static final int TYPE_USHORT_565_RGB = 8;
145:            /**
146:             * Represents an image with 5-5-5 RGB color components (5-bits red,
147:             * 5-bits green, 5-bits blue) with no alpha.  This image has
148:             * a <code>DirectColorModel</code>.
149:             */
150:            public static final int TYPE_USHORT_555_RGB = 9;
151:            /**
152:             * Represents a unsigned byte grayscale image, non-indexed.  This
153:             * image has a <code>ComponentColorModel</code> with a CS_GRAY
154:             * {@link ColorSpace}.
155:             */
156:            //    public static final int TYPE_BYTE_GRAY = 10;
157:            /**
158:             * Represents an unsigned short grayscale image, non-indexed).  This
159:             * image has a <code>ComponentColorModel</code> with a CS_GRAY
160:             * <code>ColorSpace</code>.
161:             */
162:            //    public static final int TYPE_USHORT_GRAY = 11;
163:            /**
164:             * Represents an opaque byte-packed binary image.  The
165:             * image has an {@link IndexColorModel} without alpha.  When this
166:             * type is used as the <code>imageType</code> argument to the
167:             * <code>BufferedImage</code> constructor that takes an
168:             * <code>imageType</code> argument but no <code>ColorModel</code>
169:             * argument, an <code>IndexColorModel</code> is created with
170:             * two colors in the default sRGB <code>ColorSpace</code>:
171:             * {0,&nbsp;0,&nbsp;0} and {255,&nbsp;255,&nbsp;255}.
172:             */
173:            public static final int TYPE_BYTE_BINARY = 12;
174:            /**
175:             * Represents an indexed byte image.  When this type is used as the
176:             * <code>imageType</code> argument to the <code>BufferedImage</code>
177:             * constructor that takes an <code>imageType</code> argument
178:             * but no <code>ColorModel</code> argument, an
179:             * <code>IndexColorModel</code> is created with
180:             * a 256-color 6/6/6 color cube palette with the rest of the colors
181:             * from 216-255 populated by grayscale values in the
182:             * default sRGB ColorSpace.
183:             */
184:            public static final int TYPE_BYTE_INDEXED = 13;
185:
186:            //    private static final int DCM_RED_MASK   = 0x00ff0000;
187:            //    private static final int DCM_GREEN_MASK = 0x0000ff00;
188:            //    private static final int DCM_BLUE_MASK  = 0x000000ff;
189:            //    private static final int DCM_ALPHA_MASK = 0xff000000;
190:            //    private static final int DCM_565_RED_MASK = 0xf800;
191:            //    private static final int DCM_565_GRN_MASK = 0x07E0;
192:            //    private static final int DCM_565_BLU_MASK = 0x001F;
193:            //    private static final int DCM_555_RED_MASK = 0x7C00;
194:            //    private static final int DCM_555_GRN_MASK = 0x03E0;
195:            //    private static final int DCM_555_BLU_MASK = 0x001F;
196:            //    private static final int DCM_BGR_RED_MASK = 0x0000ff;
197:            //    private static final int DCM_BGR_GRN_MASK = 0x00ff00;
198:            //    private static final int DCM_BGR_BLU_MASK = 0xff0000;
199:
200:            /**
201:             * Constructs a <code>BufferedImage</code> of one of the predefined
202:             * image types.  The <code>ColorSpace</code> for the image is the
203:             * default sRGB space.
204:             * @param width     width of the created image
205:             * @param height    height of the created image
206:             * @param imageType type of the created image
207:             * @see ColorSpace
208:             * @see #TYPE_INT_RGB
209:             * @see #TYPE_INT_ARGB
210:             * @see #TYPE_INT_ARGB_PRE
211:             * @see #TYPE_INT_BGR
212:             * @see #TYPE_3BYTE_BGR
213:             * @see #TYPE_4BYTE_ABGR
214:             * @see #TYPE_4BYTE_ABGR_PRE
215:             * @see #TYPE_BYTE_GRAY
216:             * @see #TYPE_USHORT_GRAY
217:             * @see #TYPE_BYTE_BINARY
218:             * @see #TYPE_BYTE_INDEXED
219:             * @see #TYPE_USHORT_565_RGB
220:             * @see #TYPE_USHORT_555_RGB
221:             */
222:
223:            /*
224:             BufferedImage(int width, int height, int imageType) {
225:
226:
227:
228:             }
229:             */
230:
231:            /**
232:             * Constructs a <code>BufferedImage</code> of one of the predefined
233:             * image types:
234:             * TYPE_BYTE_BINARY or TYPE_BYTE_INDEXED
235:             * @param width     width of the created image
236:             * @param height    height of the created image
237:             * @param imageType type of the created image
238:             * @param cm        <code>IndexColorModel</code> of the created image
239:             * @throws IllegalArgumentException   if the imageType is not
240:             * TYPE_BYTE_BINARY or TYPE_BYTE_INDEXED
241:             * @see #TYPE_BYTE_BINARY
242:             * @see #TYPE_BYTE_INDEXED
243:             */
244:
245:            /*
246:             public BufferedImage (int width,
247:             int height,
248:             int imageType,
249:             IndexColorModel cm) {
250:             }
251:             */
252:
253:            /**
254:             * Constructs a new <code>BufferedImage</code> with a specified
255:             * <code>ColorModel</code> and <code>Raster</code>.  If the number and
256:             * types of bands in the <code>SampleModel</code> of the
257:             * <code>Raster</code> do not match the number and types required by
258:             * the <code>ColorModel</code> to represent its color and alpha
259:             * components, a {@link RasterFormatException} is thrown.  This
260:             * method can multiply or divide the color <code>Raster</code> data by
261:             * alpha to match the <code>alphaPremultiplied</code> state
262:             * in the <code>ColorModel</code>.  Properties for this
263:             * <code>BufferedImage</code> can be established by passing
264:             * in a {@link Hashtable} of <code>String</code>/<code>Object</code>
265:             * pairs.
266:             * @param ColorModel <code>ColorModel</code> for the new image
267:             * @param raster     <code>Raster</code> for the image data
268:             * @param isRasterPremultiplied   if <code>true</code>, the data in
269:             *                  the raster has been premultiplied with alpha.
270:             * @param properties <code>Hashtable</code> of
271:             *                  <code>String</code>/<code>Object</code> pairs.
272:             * @exception <code>RasterFormatException</code> if the number and
273:             * types of bands in the <code>SampleModel</code> of the
274:             * <code>Raster</code> do not match the number and types required by
275:             * the <code>ColorModel</code> to represent its color and alpha
276:             * components.
277:             * @exception <code>IllegalArgumentException</code> if
278:             *		<code>raster</code> is incompatible with <code>cm</code>
279:             * @see ColorModel
280:             * @see Raster
281:             * @see WritableRaster
282:             */
283:
284:            /*
285:             *
286:             *  FOR NOW THE CODE WHICH DEFINES THE RASTER TYPE IS DUPLICATED BY DVF
287:             *  SEE THE METHOD DEFINERASTERTYPE @ RASTEROUTPUTMANAGER
288:             *
289:             */
290:
291:            /*
292:             public BufferedImage (ColorModel cm,
293:             WritableRaster raster,
294:             boolean isRasterPremultiplied,
295:             Hashtable properties) {
296:
297:             }
298:             */
299:
300:            /** Constructs a new BufferedImage using <code>peer</code> for delegating its imlementation to.
301:             This constructor is private to ensure that it is not possible to create BufferedImages using
302:             constructors in basis or personal profile. It also prevents sub classing of BufferedImage.
303:             Implementors should implement the BufferedImagePeer interface and call this constructor,
304:             using JNI for example, from their implementation of <code>GraphicsConfiguration.createCompatiableImage()</code>
305:             method. */
306:
307:            private BufferedImage(BufferedImagePeer peer) {
308:                this .peer = peer;
309:            }
310:
311:            /**
312:             * Returns the image type.  If it is not one of the known types,
313:             * TYPE_CUSTOM is returned.
314:             * @return the image type of this <code>BufferedImage</code>.
315:             * @see #TYPE_INT_RGB
316:             * @see #TYPE_INT_ARGB
317:             * @see #TYPE_INT_ARGB_PRE
318:             * @see #TYPE_INT_BGR
319:             * @see #TYPE_3BYTE_BGR
320:             * @see #TYPE_4BYTE_ABGR
321:             * @see #TYPE_4BYTE_ABGR_PRE
322:             * @see #TYPE_BYTE_GRAY
323:             * @see #TYPE_BYTE_BINARY
324:             * @see #TYPE_BYTE_INDEXED
325:             * @see #TYPE_USHORT_GRAY
326:             * @see #TYPE_USHORT_565_RGB
327:             * @see #TYPE_USHORT_555_RGB
328:             * @see #TYPE_CUSTOM
329:             */
330:
331:            public int getType() {
332:                return peer.getType();
333:            }
334:
335:            /**
336:             * Returns the <code>ColorModel</code>.
337:             * @return the <code>ColorModel</code> of this
338:             *  <code>BufferedImage</code>.
339:             */
340:            public ColorModel getColorModel() {
341:                return peer.getColorModel();
342:            }
343:
344:            /**
345:             * Returns the {@link WritableRaster}.
346:             * @return the <code>WriteableRaster</code> of this
347:             *  <code>BufferedImage</code>.
348:             */
349:
350:            /*
351:             public WritableRaster getRaster() {
352:             return raster;
353:             }
354:             */
355:
356:            /**
357:             * Creates a <code>Graphics2D</code>, which can be used to draw into
358:             * this <code>BufferedImage</code>.
359:             * @return a <code>Graphics2D</code>, used for drawing into this
360:             *          image.
361:             */
362:            public Graphics2D createGraphics() {
363:                return (Graphics2D) peer.getGraphics();
364:            }
365:
366:            /**
367:             * Returns a <code>WritableRaster</code> representing the alpha
368:             * channel for <code>BufferedImage</code> objects
369:             * with <code>ColorModel</code> objects that support a separate
370:             * spatial alpha channel, such as <code>ComponentColorModel</code> and
371:             * <code>DirectColorModel</code>.  Returns <code>null</code> if there
372:             * is no alpha channel associated with the <code>ColorModel</code> in
373:             * this image.  This method assumes that for all
374:             * <code>ColorModel</code> objects other than
375:             * <code>IndexColorModel</code>, if the <code>ColorModel</code>
376:             * supports alpha, there is a separate alpha channel
377:             * which is stored as the last band of image data.
378:             * If the image uses an <code>IndexColorModel</code> that
379:             * has alpha in the lookup table, this method returns
380:             * <code>null</code> since there is no spatially discrete alpha
381:             * channel.  This method creates a new
382:             * <code>WritableRaster</code>, but shares the data array.
383:             * @return a <code>WritableRaster</code> or <code>null</code> if this
384:             *          <code>BufferedImage</code> has no alpha channel associated
385:             *          with its <code>ColorModel</code>.
386:             */
387:
388:            /*
389:             public WritableRaster getAlphaRaster() {
390:             return null;
391:             }
392:             */
393:
394:            /**
395:             * Returns an integer pixel in the default RGB color model
396:             * (TYPE_INT_ARGB) and default sRGB colorspace.  Color
397:             * conversion takes place if this default model does not match
398:             * the image <code>ColorModel</code>.  There are only 8-bits of
399:             * precision for each color component in the returned data when using
400:             * this method.
401:             * @param x,&nbsp;y the coordinates of the pixel from which to get
402:             *          the pixel in the default RGB color model and sRGB
403:             *          color space
404:             * @return an integer pixel in the default RGB color model and
405:             *          default sRGB colorspace.
406:             */
407:            public int getRGB(int x, int y) {
408:                return peer.getRGB(x, y);
409:            }
410:
411:            /**
412:             * Returns an array of integer pixels in the default RGB color model
413:             * (TYPE_INT_ARGB) and default sRGB color space,
414:             * from a portion of the image data.  Color conversion takes
415:             * place if the default model does not match the image
416:             * <code>ColorModel</code>.  There are only 8-bits of precision for
417:             * each color component in the returned data when
418:             * using this method.  With a specified coordinate (x,&nbsp;y) in the
419:             * image, the ARGB pixel can be accessed in this way:
420:             * <pre>
421:             *    pixel   = rgbArray[offset + (y-startY)*scansize + (x-startX)];
422:             * </pre>
423:             * @param startX,&nbsp; startY the starting coordinates
424:             * @param w           width of region
425:             * @param h           height of region
426:             * @param rgbArray    if not <code>null</code>, the rgb pixels are
427:             *          written here
428:             * @param offset      offset into the <code>rgbArray</code>
429:             * @param scansize    scanline stride for the <code>rgbArray</code>
430:             * @return            array of RGB pixels.
431:             * @exception <code>IllegalArgumentException</code> if an unknown
432:             *		datatype is specified
433:             */
434:            public int[] getRGB(int startX, int startY, int w, int h,
435:                    int[] rgbArray, int offset, int scansize) {
436:                return peer.getRGB(startX, startY, w, h, rgbArray, offset,
437:                        scansize);
438:            }
439:
440:            /**
441:             * Sets a pixel in this <code>BufferedImage</code> to the specified
442:             * RGB value. The pixel is assumed to be in the default RGB color
443:             * model, TYPE_INT_ARGB, and default sRGB color space.  For images
444:             * with an <code>IndexColorModel</code>, the index with the nearest
445:             * color is chosen.
446:             * @param x,&nbsp;y the coordinates of the pixel to set
447:             * @param rgb the RGB value
448:             */
449:            public synchronized void setRGB(int x, int y, int rgb) {
450:                peer.setRGB(x, y, rgb);
451:            }
452:
453:            /**
454:             * Sets an array of integer pixels in the default RGB color model
455:             * (TYPE_INT_ARGB) and default sRGB color space,
456:             * into a portion of the image data.  Color conversion takes place
457:             * if the default model does not match the image
458:             * <code>ColorModel</code>.  There are only 8-bits of precision for
459:             * each color component in the returned data when
460:             * using this method.  With a specified coordinate (x,&nbsp;y) in the
461:             * this image, the ARGB pixel can be accessed in this way:
462:             * <pre>
463:             *    pixel   = rgbArray[offset + (y-startY)*scansize + (x-startX)];
464:             * </pre>
465:             * WARNING: No dithering takes place.
466:             *
467:             * @param startX,&nbsp;startY the starting coordinates
468:             * @param w           width of the region
469:             * @param h           height of the region
470:             * @param rgbArray    the rgb pixels
471:             * @param offset      offset into the <code>rgbArray</code>
472:             * @param scansize    scanline stride for the <code>rgbArray</code>
473:             */
474:            public void setRGB(int startX, int startY, int w, int h,
475:                    int[] rgbArray, int offset, int scansize) {
476:                peer.setRGB(startX, startY, w, h, rgbArray, offset, scansize);
477:            }
478:
479:            /**
480:             * Returns the width of the <code>BufferedImage</code>.
481:             * @return the width of this <code>BufferedImage</code>.
482:             */
483:            public int getWidth() {
484:                return peer.getWidth();
485:            }
486:
487:            /**
488:             * Returns the height of the <code>BufferedImage</code>.
489:             * @return the height of this <code>BufferedImage</code>.
490:             */
491:            public int getHeight() {
492:                return peer.getHeight();
493:            }
494:
495:            /**
496:             * Returns the actual width of the image.  If the width is not known
497:             * yet then the {@link ImageObserver} is notified later and
498:             * <code>-1</code> is returned.
499:             * @param observer the <code>ImageObserver</code> that receives
500:             *          information about the image
501:             * @return the width of the image or <code>-1</code> if the width
502:             *          is not yet known.
503:             * @see java.awt.Image#getHeight(ImageObserver)
504:             * @see ImageObserver
505:             */
506:            public int getWidth(ImageObserver observer) {
507:                return peer.getWidth(observer);
508:            }
509:
510:            /**
511:             * Returns the actual height of the image.  If the height is not known
512:             * yet then the <code>ImageObserver</code> is notified later and
513:             * <code>-1</code> is returned.
514:             * @param observer the <code>ImageObserver</code> that receives
515:             *          information about the image
516:             * @return the height of the image or <code>-1</code> if the height
517:             *          is not yet known.
518:             * @see java.awt.Image#getWidth(ImageObserver)
519:             * @see ImageObserver
520:             */
521:            public int getHeight(ImageObserver observer) {
522:                return peer.getHeight(observer);
523:            }
524:
525:            /**
526:             * Returns the object that produces the pixels for the image.
527:             * @return the {@link ImageProducer} that is used to produce the
528:             * pixels for this image.
529:             * @see ImageProducer
530:             */
531:            public ImageProducer getSource() {
532:                return peer.getSource();
533:            }
534:
535:            /**
536:             * Returns a property of the image by name.  Individual property names
537:             * are defined by the various image formats.  If a property is not
538:             * defined for a particular image, this method returns the
539:             * <code>UndefinedProperty</code> field.  If the properties
540:             * for this image are not yet known, then this method returns
541:             * <code>null</code> and the <code>ImageObserver</code> object is
542:             * notified later.  The property name "comment" should be used to
543:             * store an optional comment that can be presented to the user as a
544:             * description of the image, its source, or its author.
545:             * @param name the property name
546:             * @param observer the <code>ImageObserver</code> that receives
547:             *  notification regarding image information
548:             * @return an {@link Object} that is the property referred to by the
549:             *          specified <code>name</code> or <code>null</code> if the
550:             *          properties of this image are not yet known.
551:             * @see ImageObserver
552:             * @see java.awt.Image#UndefinedProperty
553:             */
554:            public Object getProperty(String name, ImageObserver observer) {
555:                return peer.getProperty(name, observer);
556:            }
557:
558:            /**
559:             * Returns a property of the image by name.
560:             * @param name the property name
561:             * @return an <code>Object</code> that is the property referred to by
562:             *          the specified <code>name</code>.
563:             */
564:            public Object getProperty(String name) {
565:                return peer.getProperty(name);
566:            }
567:
568:            /**
569:             * Flushes all resources being used to cache optimization information.
570:             * The underlying pixel data is unaffected.
571:             */
572:            public void flush() {
573:                peer.flush();
574:            }
575:
576:            /**
577:             * This method returns a {@link Graphics2D}, but is here
578:             * for backwards compatibility.  {@link #createGraphics() createGraphics} is more
579:             * convenient, since it is declared to return a
580:             * <code>Graphics2D</code>.
581:             * @return a <code>Graphics2D</code>, which can be used to draw into
582:             *          this image.
583:             */
584:            public java.awt.Graphics getGraphics() {
585:                return peer.getGraphics();
586:            }
587:
588:            /**
589:             * Creates a <code>Graphics2D</code>, which can be used to draw into
590:             * this <code>BufferedImage</code>.
591:             * @return a <code>Graphics2D</code>, used for drawing into this
592:             *          image.
593:             */
594:
595:            /*
596:             public Graphics2D createGraphics() {
597:             }
598:             */
599:
600:            /**
601:             * Returns a subimage defined by a specified rectangular region.
602:             * The returned <code>BufferedImage</code> shares the same
603:             * data array as the original image.
604:             * @param x,&nbsp;y the coordinates of the upper-left corner of the
605:             *          specified rectangular region
606:             * @param w the width of the specified rectangular region
607:             * @param h the height of the specified rectangular region
608:             * @return a <code>BufferedImage</code> that is the subimage of this
609:             *          <code>BufferedImage</code>.
610:             * @exception <code>RasterFormatException</code> if the specified
611:             * area is not contained within this <code>BufferedImage</code>.
612:             */
613:            public BufferedImage getSubimage(int x, int y, int w, int h) {
614:                return peer.getSubimage(x, y, w, h);
615:            }
616:
617:            /**
618:             * Returns a <code>String</code> representation of this
619:             * <code>BufferedImage</code> object and its values.
620:             * @return a <code>String</code> representing this
621:             *          <code>BufferedImage</code>.
622:             */
623:            public String toString() {
624:                return peer.toString();
625:            }
626:
627:            /**
628:             * Returns a {@link Vector} of {@link RenderedImage} objects that are
629:             * the immediate sources, not the sources of these immediate sources,
630:             * of image data for this <code>BufferedImage</code>.  This
631:             * method returns <code>null</code> if the <code>BufferedImage</code>
632:             * has no information about its immediate sources.  It returns an
633:             * empty <code>Vector</code> if the <code>BufferedImage</code> has no
634:             * immediate sources.
635:             * @return a <code>Vector</code> containing immediate sources of
636:             *          this <code>BufferedImage</code> object's image date, or
637:             *          <code>null</code> if this <code>BufferedImage</code> has
638:             *          no information about its immediate sources, or an empty
639:             *          <code>Vector</code> if this <code>BufferedImage</code>
640:             *          has no immediate sources.
641:             */
642:
643:            /*
644:             public Vector getSources() {
645:             return null;
646:             }
647:             */
648:
649:            /**
650:             * Returns an array of names recognized by
651:             * {@link #getProperty(String) getProperty(String)}
652:             * or <code>null</code>, if no property names are recognized.
653:             * @return a <code>String</code> array containing all of the property
654:             *          names that <code>getProperty(String)</code> recognizes;
655:             *		or <code>null</code> if no property names are recognized.
656:             */
657:            public String[] getPropertyNames() {
658:                return peer.getPropertyNames();
659:            }
660:            /**
661:             * Returns the minimum x coordinate of this
662:             * <code>BufferedImage</code>.  This is always zero.
663:             * @return the minimum x coordinate of this
664:             *          <code>BufferedImage</code>.
665:             */
666:
667:            /*    public int getMinX() {
668:             return 0;
669:             }
670:             */
671:
672:            /**
673:             * Returns the minimum y coordinate of this
674:             * <code>BufferedImage</code>.  This is always zero.
675:             * @return the minimum y coordinate of this
676:             *          <code>BufferedImage</code>.
677:             */
678:
679:            /*    public int getMinY() {
680:             return 0;
681:             }
682:             */
683:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.