Java Doc for ImageReadParam.java in  » 6.0-JDK-Core » image » javax » imageio » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
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
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » image » javax.imageio 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javax.imageio.IIOParam
      javax.imageio.ImageReadParam

All known Subclasses:   javax.imageio.plugins.jpeg.JPEGImageReadParam,
ImageReadParam
public class ImageReadParam extends IIOParam (Code)
A class describing how a stream is to be decoded. Instances of this class or its subclasses are used to supply prescriptive "how-to" information to instances of ImageReader.

An image encoded as part of a file or stream may be thought of extending out in multiple dimensions: the spatial dimensions of width and height, a number of bands, and a number of progressive decoding passes. This class allows a contiguous (hyper)rectangular subarea of the image in all of these dimensions to be selected for decoding. Additionally, the spatial dimensions may be subsampled discontinuously. Finally, color and format conversions may be specified by controlling the ColorModel and SampleModel of the destination image, either by providing a BufferedImage or by using an ImageTypeSpecifier.

An ImageReadParam object is used to specify how an image, or a set of images, will be converted on input from a stream in the context of the Java Image I/O framework. A plug-in for a specific image format will return instances of ImageReadParam from the getDefaultReadParam method of its ImageReader implementation.

The state maintained by an instance of ImageReadParam is independent of any particular image being decoded. When actual decoding takes place, the values set in the read param are combined with the actual properties of the image being decoded from the stream and the destination BufferedImage that will receive the decoded pixel data. For example, the source region set using setSourceRegion will first be intersected with the actual valid source area. The result will be translated by the value returned by getDestinationOffset, and the resulting rectangle intersected with the actual valid destination area to yield the destination area that will be written.

The parameters specified by an ImageReadParam are applied to an image as follows. First, if a rendering size has been set by setSourceRenderSize, the entire decoded image is rendered at the size given by getSourceRenderSize. Otherwise, the image has its natural size given by ImageReader.getWidth and ImageReader.getHeight.

Next, the image is clipped against the source region specified by getSourceXOffset, getSourceYOffset, getSourceWidth, and getSourceHeight.

The resulting region is then subsampled according to the factors given in IIOParam.setSourceSubsampling IIOParam.setSourceSubsampling . The first pixel, the number of pixels per row, and the number of rows all depend on the subsampling settings. Call the minimum X and Y coordinates of the resulting rectangle (minX, minY), its width w and its height h.

This rectangle is offset by (getDestinationOffset().x, getDestinationOffset().y) and clipped against the destination bounds. If no destination image has been set, the destination is defined to have a width of getDestinationOffset().x + w, and a height of getDestinationOffset().y + h so that all pixels of the source region may be written to the destination.

Pixels that land, after subsampling, within the destination image, and that are written in one of the progressive passes specified by getSourceMinProgressivePass and getSourceNumProgressivePasses are passed along to the next step.

Finally, the source samples of each pixel are mapped into destination bands according to the algorithm described in the comment for setDestinationBands.

Plug-in writers may extend the functionality of ImageReadParam by providing a subclass that implements additional, plug-in specific interfaces. It is up to the plug-in to document what interfaces are available and how they are to be used. Readers will silently ignore any extended features of an ImageReadParam subclass of which they are not aware. Also, they may ignore any optional features that they normally disable when creating their own ImageReadParam instances via getDefaultReadParam.

Note that unless a query method exists for a capability, it must be supported by all ImageReader implementations (e.g. source render size is optional, but subsampling must be supported).
version:
   0.5
See Also:   ImageReader
See Also:   ImageWriter
See Also:   ImageWriteParam



Field Summary
protected  booleancanSetSourceRenderSize
     true if this ImageReadParam allows the source rendering dimensions to be set.
protected  BufferedImagedestination
     The current destination BufferedImage, or null if none has been set.
protected  int[]destinationBands
     The set of destination bands to be used, as an array of ints.
protected  intminProgressivePass
     The minimum index of a progressive pass to read from the source.
protected  intnumProgressivePasses
     The maximum number of progressive passes to read from the source.
protected  DimensionsourceRenderSize
     The desired rendering width and height of the source, if canSetSourceRenderSize is true, or null.

Constructor Summary
public  ImageReadParam()
     Constructs an ImageReadParam.

Method Summary
public  booleancanSetSourceRenderSize()
     Returns true if this reader allows the source image to be rendered at an arbitrary size as part of the decoding process, by means of the setSourceRenderSize method.
public  BufferedImagegetDestination()
     Returns the BufferedImage currently set by the setDestination method, or null if none is set.
public  int[]getDestinationBands()
     Returns the set of band indices where data will be placed.
public  intgetSourceMaxProgressivePass()
     If getSourceNumProgressivePasses is equal to Integer.MAX_VALUE, returns Integer.MAX_VALUE.
public  intgetSourceMinProgressivePass()
     Returns the index of the first progressive pass that will be decoded.
public  intgetSourceNumProgressivePasses()
     Returns the number of the progressive passes that will be decoded.
public  DimensiongetSourceRenderSize()
     Returns the width and height of the source image as it will be rendered during decoding, if they have been set via the setSourceRenderSize method.
public  voidsetDestination(BufferedImage destination)
     Supplies a BufferedImage to be used as the destination for decoded pixel data.
public  voidsetDestinationBands(int[] destinationBands)
     Sets the indices of the destination bands where data will be placed.
public  voidsetDestinationType(ImageTypeSpecifier destinationType)
    
public  voidsetSourceProgressivePasses(int minPass, int numPasses)
     Sets the range of progressive passes that will be decoded. Passes outside of this range will be ignored.

A progressive pass is a re-encoding of the entire image, generally at progressively higher effective resolutions, but requiring greater transmission bandwidth.

public  voidsetSourceRenderSize(Dimension size)
     If the image is able to be rendered at an arbitrary size, sets the source width and height to the supplied values.

Field Detail
canSetSourceRenderSize
protected boolean canSetSourceRenderSize(Code)
true if this ImageReadParam allows the source rendering dimensions to be set. By default, the value is false. Subclasses must set this value manually.

ImageReaders that do not support setting of the source render size should set this value to false.




destination
protected BufferedImage destination(Code)
The current destination BufferedImage, or null if none has been set. By default, the value is null.



destinationBands
protected int[] destinationBands(Code)
The set of destination bands to be used, as an array of ints. By default, the value is null, indicating all destination bands should be written in order.



minProgressivePass
protected int minProgressivePass(Code)
The minimum index of a progressive pass to read from the source. By default, the value is set to 0, which indicates that passes starting with the first available pass should be decoded.

Subclasses should ensure that this value is non-negative.




numProgressivePasses
protected int numProgressivePasses(Code)
The maximum number of progressive passes to read from the source. By default, the value is set to Integer.MAX_VALUE, which indicates that passes up to and including the last available pass should be decoded.

Subclasses should ensure that this value is positive. Additionally, if the value is not Integer.MAX_VALUE, then minProgressivePass + numProgressivePasses - 1 should not exceed Integer.MAX_VALUE.




sourceRenderSize
protected Dimension sourceRenderSize(Code)
The desired rendering width and height of the source, if canSetSourceRenderSize is true, or null.

ImageReaders that do not support setting of the source render size may ignore this value.





Constructor Detail
ImageReadParam
public ImageReadParam()(Code)
Constructs an ImageReadParam.




Method Detail
canSetSourceRenderSize
public boolean canSetSourceRenderSize()(Code)
Returns true if this reader allows the source image to be rendered at an arbitrary size as part of the decoding process, by means of the setSourceRenderSize method. If this method returns false, calls to setSourceRenderSize will throw an UnsupportedOperationException. true if setting source rendering size issupported.
See Also:   ImageReadParam.setSourceRenderSize



getDestination
public BufferedImage getDestination()(Code)
Returns the BufferedImage currently set by the setDestination method, or null if none is set. the BufferedImage to be written to.
See Also:   ImageReadParam.setDestination



getDestinationBands
public int[] getDestinationBands()(Code)
Returns the set of band indices where data will be placed. If no value has been set, null is returned to indicate that all destination bands will be used. the indices of the destination bands to be used,or null.
See Also:   ImageReadParam.setDestinationBands



getSourceMaxProgressivePass
public int getSourceMaxProgressivePass()(Code)
If getSourceNumProgressivePasses is equal to Integer.MAX_VALUE, returns Integer.MAX_VALUE. Otherwise, returns getSourceMinProgressivePass() + getSourceNumProgressivePasses() - 1. the index of the last pass to be read, orInteger.MAX_VALUE.



getSourceMinProgressivePass
public int getSourceMinProgressivePass()(Code)
Returns the index of the first progressive pass that will be decoded. If no value has been set, 0 will be returned (which is the correct value). the index of the first pass that will be decoded.
See Also:   ImageReadParam.setSourceProgressivePasses
See Also:   ImageReadParam.getSourceNumProgressivePasses



getSourceNumProgressivePasses
public int getSourceNumProgressivePasses()(Code)
Returns the number of the progressive passes that will be decoded. If no value has been set, Integer.MAX_VALUE will be returned (which is the correct value). the number of the passes that will be decoded.
See Also:   ImageReadParam.setSourceProgressivePasses
See Also:   ImageReadParam.getSourceMinProgressivePass



getSourceRenderSize
public Dimension getSourceRenderSize()(Code)
Returns the width and height of the source image as it will be rendered during decoding, if they have been set via the setSourceRenderSize method. A nullvalue indicates that no setting has been made. the rendered width and height of the source imageas a Dimension.
See Also:   ImageReadParam.setSourceRenderSize



setDestination
public void setDestination(BufferedImage destination)(Code)
Supplies a BufferedImage to be used as the destination for decoded pixel data. The currently set image will be written to by the read, readAll, and readRaster methods, and a reference to it will be returned by those methods.

Pixel data from the aforementioned methods will be written starting at the offset specified by getDestinationOffset.

If destination is null, a newly-created BufferedImage will be returned by those methods.

At the time of reading, the image is checked to verify that its ColorModel and SampleModel correspond to one of the ImageTypeSpecifiers returned from the ImageReader's getImageTypes method. If it does not, the reader will throw an IIOException.
Parameters:
  destination - the BufferedImage to be written to, ornull.
See Also:   ImageReadParam.getDestination




setDestinationBands
public void setDestinationBands(int[] destinationBands)(Code)
Sets the indices of the destination bands where data will be placed. Duplicate indices are not allowed.

A null value indicates that all destination bands will be used.

Choosing a destination band subset will not affect the number of bands in the output image of a read if no destination image is specified; the created destination image will still have the same number of bands as if this method had never been called. If a different number of bands in the destination image is desired, an image must be supplied using the ImageReadParam.setDestination method.

At the time of reading or writing, an IllegalArgumentException will be thrown by the reader or writer if a value larger than the largest destination band index has been specified, or if the number of source bands and destination bands to be used differ. The ImageReader.checkReadParamBandSettings method may be used to automate this test.
Parameters:
  destinationBands - an array of integer band indices to beused.
exception:
  IllegalArgumentException - if destinationBandscontains a negative or duplicate value.
See Also:   ImageReadParam.getDestinationBands
See Also:   ImageReadParam.getSourceBands
See Also:   ImageReader.checkReadParamBandSettings




setDestinationType
public void setDestinationType(ImageTypeSpecifier destinationType)(Code)



setSourceProgressivePasses
public void setSourceProgressivePasses(int minPass, int numPasses)(Code)
Sets the range of progressive passes that will be decoded. Passes outside of this range will be ignored.

A progressive pass is a re-encoding of the entire image, generally at progressively higher effective resolutions, but requiring greater transmission bandwidth. The most common use of progressive encoding is found in the JPEG format, where successive passes include more detailed representations of the high-frequency image content.

The actual number of passes to be decoded is determined during decoding, based on the number of actual passes available in the stream. Thus if minPass + numPasses - 1 is larger than the index of the last available passes, decoding will end with that pass.

A value of numPasses of Integer.MAX_VALUE indicates that all passes from minPass forward should be read. Otherwise, the index of the last pass (i.e., minPass + numPasses - 1) must not exceed Integer.MAX_VALUE.

There is no unsetSourceProgressivePasses method; the same effect may be obtained by calling setSourceProgressivePasses(0, Integer.MAX_VALUE).
Parameters:
  minPass - the index of the first pass to be decoded.
Parameters:
  numPasses - the maximum number of passes to be decoded.
exception:
  IllegalArgumentException - if minPass isnegative, numPasses is negative or 0, ornumPasses is smaller thanInteger.MAX_VALUE but minPass +numPasses - 1 is greater thanINTEGER.MAX_VALUE.
See Also:   ImageReadParam.getSourceMinProgressivePass
See Also:   ImageReadParam.getSourceMaxProgressivePass




setSourceRenderSize
public void setSourceRenderSize(Dimension size) throws UnsupportedOperationException(Code)
If the image is able to be rendered at an arbitrary size, sets the source width and height to the supplied values. Note that the values returned from the getWidth and getHeight methods on ImageReader are not affected by this method; they will continue to return the default size for the image. Similarly, if the image is also tiled the tile width and height are given in terms of the default size.

Typically, the width and height should be chosen such that the ratio of width to height closely approximates the aspect ratio of the image, as returned from ImageReader.getAspectRatio.

If this plug-in does not allow the rendering size to be set, an UnsupportedOperationException will be thrown.

To remove the render size setting, pass in a value of null for size.
Parameters:
  size - a Dimension indicating the desiredwidth and height.
exception:
  IllegalArgumentException - if either the width or theheight is negative or 0.
exception:
  UnsupportedOperationException - if image resizingis not supported by this plug-in.
See Also:   ImageReadParam.getSourceRenderSize
See Also:   ImageReader.getWidth
See Also:   ImageReader.getHeight
See Also:   ImageReader.getAspectRatio




Fields inherited from javax.imageio.IIOParam
protected IIOParamController controller(Code)(Java Doc)
protected IIOParamController defaultController(Code)(Java Doc)
protected Point destinationOffset(Code)(Java Doc)
protected ImageTypeSpecifier destinationType(Code)(Java Doc)
protected int[] sourceBands(Code)(Java Doc)
protected Rectangle sourceRegion(Code)(Java Doc)
protected int sourceXSubsampling(Code)(Java Doc)
protected int sourceYSubsampling(Code)(Java Doc)
protected int subsamplingXOffset(Code)(Java Doc)
protected int subsamplingYOffset(Code)(Java Doc)

Methods inherited from javax.imageio.IIOParam
public boolean activateController()(Code)(Java Doc)
public IIOParamController getController()(Code)(Java Doc)
public IIOParamController getDefaultController()(Code)(Java Doc)
public Point getDestinationOffset()(Code)(Java Doc)
public ImageTypeSpecifier getDestinationType()(Code)(Java Doc)
public int[] getSourceBands()(Code)(Java Doc)
public Rectangle getSourceRegion()(Code)(Java Doc)
public int getSourceXSubsampling()(Code)(Java Doc)
public int getSourceYSubsampling()(Code)(Java Doc)
public int getSubsamplingXOffset()(Code)(Java Doc)
public int getSubsamplingYOffset()(Code)(Java Doc)
public boolean hasController()(Code)(Java Doc)
public void setController(IIOParamController controller)(Code)(Java Doc)
public void setDestinationOffset(Point destinationOffset)(Code)(Java Doc)
public void setDestinationType(ImageTypeSpecifier destinationType)(Code)(Java Doc)
public void setSourceBands(int[] sourceBands)(Code)(Java Doc)
public void setSourceRegion(Rectangle sourceRegion)(Code)(Java Doc)
public void setSourceSubsampling(int sourceXSubsampling, int sourceYSubsampling, int subsamplingXOffset, int subsamplingYOffset)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.