Class IIOParam
- Direct Known Subclasses:
- ImageReadParam,- ImageWriteParam
ImageReadParam and
 ImageWriteParam.
 This class provides mechanisms to specify a source region and a destination region. When reading, the source is the stream and the in-memory image is the destination. When writing, these are reversed. In the case of writing, destination regions may be used only with a writer that supports pixel replacement.
Decimation subsampling may be specified for both readers and writers, using a movable subsampling grid.
Subsets of the source and destination bands may be selected.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected IIOParamControllerTheIIOParamControllerthat will be used to provide settings for thisIIOParamobject when theactivateControllermethod is called.protected IIOParamControllerThe defaultIIOParamControllerthat will be used to provide settings for thisIIOParamobject when theactivateControllermethod is called.protected PointThe offset in the destination where the upper-left decoded pixel should be placed.protected ImageTypeSpecifierAnImageTypeSpecifierto be used to generate a destination image when reading, or to set the output color type when writing.protected int[]An array ofints indicating which source bands will be used, ornull.protected RectangleThe source region, onnullif none is set.protected intThe decimation subsampling to be applied in the horizontal direction.protected intThe decimation subsampling to be applied in the vertical direction.protected intA horizontal offset to be applied to the subsampling grid before subsampling.protected intA vertical offset to be applied to the subsampling grid before subsampling.
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedIIOParam()Protected constructor may be called only by subclasses.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanActivates the installedIIOParamControllerfor thisIIOParamobject and returns the resulting value.Returns whateverIIOParamControlleris currently installed.Returns the defaultIIOParamController, if there is one, regardless of the currently installed controller.Returns the offset in the destination image at which pixels are to be placed.Returns the type of image to be returned by the read, if one was set by a call tosetDestination(ImageTypeSpecifier), as anImageTypeSpecifier.int[]Returns the set of source bands to be used.Returns the source region to be used.intReturns the number of source columns to advance for each pixel.intReturns the number of rows to advance for each pixel.intReturns the horizontal offset of the subsampling grid.intReturns the vertical offset of the subsampling grid.booleanReturnstrueif there is a controller installed for thisIIOParamobject.voidsetController(IIOParamController controller) Sets theIIOParamControllerto be used to provide settings for thisIIOParamobject when theactivateControllermethod is called, overriding any default controller.voidsetDestinationOffset(Point destinationOffset) Specifies the offset in the destination image at which future decoded pixels are to be placed, when reading, or where a region will be written, when writing.voidsetDestinationType(ImageTypeSpecifier destinationType) Sets the desired image type for the destination image, using anImageTypeSpecifier.voidsetSourceBands(int[] sourceBands) Sets the indices of the source bands to be used.voidsetSourceRegion(Rectangle sourceRegion) Sets the source region of interest.voidsetSourceSubsampling(int sourceXSubsampling, int sourceYSubsampling, int subsamplingXOffset, int subsamplingYOffset) Specifies a decimation subsampling to apply on I/O.
- 
Field Details- 
sourceRegionThe source region, onnullif none is set.
- 
sourceXSubsamplingprotected int sourceXSubsamplingThe decimation subsampling to be applied in the horizontal direction. By default, the value is1. The value must not be negative or 0.
- 
sourceYSubsamplingprotected int sourceYSubsamplingThe decimation subsampling to be applied in the vertical direction. By default, the value is1. The value must not be negative or 0.
- 
subsamplingXOffsetprotected int subsamplingXOffsetA horizontal offset to be applied to the subsampling grid before subsampling. The first pixel to be used will be offset this amount from the origin of the region, or of the image if no region is specified.
- 
subsamplingYOffsetprotected int subsamplingYOffsetA vertical offset to be applied to the subsampling grid before subsampling. The first pixel to be used will be offset this amount from the origin of the region, or of the image if no region is specified.
- 
sourceBandsprotected int[] sourceBandsAn array ofints indicating which source bands will be used, ornull. Ifnull, the set of source bands to be used is as described in the comment for thesetSourceBandsmethod. No value should be allowed to be negative.
- 
destinationTypeAnImageTypeSpecifierto be used to generate a destination image when reading, or to set the output color type when writing. If non has been set the value will benull. By default, the value isnull.
- 
destinationOffsetThe offset in the destination where the upper-left decoded pixel should be placed. By default, the value is (0, 0).
- 
defaultControllerThe defaultIIOParamControllerthat will be used to provide settings for thisIIOParamobject when theactivateControllermethod is called. This default should be set by subclasses that choose to provide their own default controller, usually a GUI, for setting parameters.- See Also:
 
- 
controllerTheIIOParamControllerthat will be used to provide settings for thisIIOParamobject when theactivateControllermethod is called. This value overrides any default controller, even when null.- See Also:
 
 
- 
- 
Constructor Details- 
IIOParamprotected IIOParam()Protected constructor may be called only by subclasses.
 
- 
- 
Method Details- 
setSourceRegionSets the source region of interest. The region of interest is described as a rectangle, with the upper-left corner of the source image as pixel (0, 0) and increasing values down and to the right. The actual number of pixels used will depend on the subsampling factors set bysetSourceSubsampling. If subsampling has been set such that this number is zero, anIllegalStateExceptionwill be thrown.The source region of interest specified by this method will be clipped as needed to fit within the source bounds, as well as the destination offsets, width, and height at the time of actual I/O. A value of nullforsourceRegionwill remove any region specification, causing the entire image to be used.- Parameters:
- sourceRegion- a- Rectanglespecifying the source region of interest, or- null.
- Throws:
- IllegalArgumentException- if- sourceRegionis non-- nulland either- sourceRegion.xor- sourceRegion.yis negative.
- IllegalArgumentException- if- sourceRegionis non-- nulland either- sourceRegion.widthor- sourceRegion.heightis negative or 0.
- IllegalStateException- if subsampling is such that this region will have a subsampled width or height of zero.
- See Also:
 
- 
getSourceRegionReturns the source region to be used. The returned value is that set by the most recent call tosetSourceRegion, and will benullif there is no region set.- Returns:
- the source region of interest as a
 Rectangle, ornull.
- See Also:
 
- 
setSourceSubsamplingpublic void setSourceSubsampling(int sourceXSubsampling, int sourceYSubsampling, int subsamplingXOffset, int subsamplingYOffset) Specifies a decimation subsampling to apply on I/O. ThesourceXSubsamplingandsourceYSubsamplingparameters specify the subsampling period (i.e., the number of rows and columns to advance after every source pixel). Specifically, a period of 1 will use every row or column; a period of 2 will use every other row or column. ThesubsamplingXOffsetandsubsamplingYOffsetparameters specify an offset from the region (or image) origin for the first subsampled pixel. Adjusting the origin of the subsample grid is useful for avoiding seams when subsampling a very large source image into destination regions that will be assembled into a complete subsampled image. Most users will want to simply leave these parameters at 0.The number of pixels and scanlines to be used are calculated as follows. The number of subsampled pixels in a scanline is given by truncate[(width - subsamplingXOffset + sourceXSubsampling - 1) / sourceXSubsampling].If the region is such that this width is zero, an IllegalStateExceptionis thrown.The number of scanlines to be used can be computed similarly. The ability to set the subsampling grid to start somewhere other than the source region origin is useful if the region is being used to create subsampled tiles of a large image, where the tile width and height are not multiples of the subsampling periods. If the subsampling grid does not remain consistent from tile to tile, there will be artifacts at the tile boundaries. By adjusting the subsampling grid offset for each tile to compensate, these artifacts can be avoided. The tradeoff is that in order to avoid these artifacts, the tiles are not all the same size. The grid offset to use in this case is given by: 
 grid offset = [period - (region offset modulo period)] modulo period)If either sourceXSubsamplingorsourceYSubsamplingis 0 or negative, anIllegalArgumentExceptionwill be thrown.If either subsamplingXOffsetorsubsamplingYOffsetis negative or greater than or equal to the corresponding period, anIllegalArgumentExceptionwill be thrown.There is no unsetSourceSubsamplingmethod; simply callsetSourceSubsampling(1, 1, 0, 0)to restore default values.- Parameters:
- sourceXSubsampling- the number of columns to advance between pixels.
- sourceYSubsampling- the number of rows to advance between pixels.
- subsamplingXOffset- the horizontal offset of the first subsample within the region, or within the image if no region is set.
- subsamplingYOffset- the horizontal offset of the first subsample within the region, or within the image if no region is set.
- Throws:
- IllegalArgumentException- if either period is negative or 0, or if either grid offset is negative or greater than the corresponding period.
- IllegalStateException- if the source region is such that the subsampled output would contain no pixels.
 
- 
getSourceXSubsamplingpublic int getSourceXSubsampling()Returns the number of source columns to advance for each pixel.If setSourceSubsamplinghas not been called, 1 is returned (which is the correct value).- Returns:
- the source subsampling X period.
- See Also:
 
- 
getSourceYSubsamplingpublic int getSourceYSubsampling()Returns the number of rows to advance for each pixel.If setSourceSubsamplinghas not been called, 1 is returned (which is the correct value).- Returns:
- the source subsampling Y period.
- See Also:
 
- 
getSubsamplingXOffsetpublic int getSubsamplingXOffset()Returns the horizontal offset of the subsampling grid.If setSourceSubsamplinghas not been called, 0 is returned (which is the correct value).- Returns:
- the source subsampling grid X offset.
- See Also:
 
- 
getSubsamplingYOffsetpublic int getSubsamplingYOffset()Returns the vertical offset of the subsampling grid.If setSourceSubsamplinghas not been called, 0 is returned (which is the correct value).- Returns:
- the source subsampling grid Y offset.
- See Also:
 
- 
setSourceBandspublic void setSourceBands(int[] sourceBands) Sets the indices of the source bands to be used. Duplicate indices are not allowed.A nullvalue indicates that all source bands will be used.At the time of reading, an IllegalArgumentExceptionwill be thrown by the reader or writer if a value larger than the largest available source band index has been specified or if the number of source bands and destination bands to be used differ. TheImageReader.checkReadParamBandSettingsmethod may be used to automate this test.Semantically, a copy is made of the array; changes to the array contents subsequent to this call have no effect on this IIOParam.- Parameters:
- sourceBands- an array of integer band indices to be used.
- Throws:
- IllegalArgumentException- if- sourceBandscontains a negative or duplicate value.
- See Also:
 
- 
getSourceBandspublic int[] getSourceBands()Returns the set of source bands to be used. The returned value is that set by the most recent call tosetSourceBands, ornullif there have been no calls tosetSourceBands.Semantically, the array returned is a copy; changes to array contents subsequent to this call have no effect on this IIOParam.- Returns:
- the set of source bands to be used, or
 null.
- See Also:
 
- 
setDestinationTypeSets the desired image type for the destination image, using anImageTypeSpecifier.When reading, if the layout of the destination has been set using this method, each call to an ImageReaderreadmethod will return a newBufferedImageusing the format specified by the supplied type specifier. As a side effect, any destinationBufferedImageset byImageReadParam.setDestination(BufferedImage)will no longer be set as the destination. In other words, this method may be thought of as callingsetDestination((BufferedImage)null).When writing, the destination type maybe used to determine the color type of the image. The SampleModelinformation will be ignored, and may benull. For example, a 4-banded image could represent either CMYK or RGBA data. If a destination type is set, itsColorModelwill override anyColorModelon the image itself. This is crucial whensetSourceBandsis used since the image'sColorModelwill refer to the entire image rather than to the subset of bands being written.- Parameters:
- destinationType- the- ImageTypeSpecifierto be used to determine the destination layout and color type.
- See Also:
 
- 
getDestinationTypeReturns the type of image to be returned by the read, if one was set by a call tosetDestination(ImageTypeSpecifier), as anImageTypeSpecifier. If none was set,nullis returned.- Returns:
- an ImageTypeSpecifierdescribing the destination type, ornull.
- See Also:
 
- 
setDestinationOffsetSpecifies the offset in the destination image at which future decoded pixels are to be placed, when reading, or where a region will be written, when writing.When reading, the region to be written within the destination BufferedImagewill start at this offset and have a width and height determined by the source region of interest, the subsampling parameters, and the destination bounds.Normal writes are not affected by this method, only writes performed using ImageWriter.replacePixels. For such writes, the offset specified is within the output stream image whose pixels are being modified.There is no unsetDestinationOffsetmethod; simply callsetDestinationOffset(new Point(0, 0))to restore default values.- Parameters:
- destinationOffset- the offset in the destination, as a- Point.
- Throws:
- IllegalArgumentException- if- destinationOffsetis- null.
- See Also:
 
- 
getDestinationOffsetReturns the offset in the destination image at which pixels are to be placed.If setDestinationOffsetshas not been called, aPointwith zero X and Y values is returned (which is the correct value).- Returns:
- the destination offset as a Point.
- See Also:
 
- 
setControllerSets theIIOParamControllerto be used to provide settings for thisIIOParamobject when theactivateControllermethod is called, overriding any default controller. If the argument isnull, no controller will be used, including any default. To restore the default, usesetController(getDefaultController()).- Parameters:
- controller- An appropriate- IIOParamController, or- null.
- See Also:
 
- 
getControllerReturns whateverIIOParamControlleris currently installed. This could be the default if there is one,null, or the argument of the most recent call tosetController.- Returns:
- the currently installed
 IIOParamController, ornull.
- See Also:
 
- 
getDefaultControllerReturns the defaultIIOParamController, if there is one, regardless of the currently installed controller. If there is no default controller, returnsnull.- Returns:
- the default IIOParamController, ornull.
- See Also:
 
- 
hasControllerpublic boolean hasController()Returnstrueif there is a controller installed for thisIIOParamobject. This will returntrueifgetControllerwould not returnnull.- Returns:
- trueif a controller is installed.
- See Also:
 
- 
activateControllerpublic boolean activateController()Activates the installedIIOParamControllerfor thisIIOParamobject and returns the resulting value. When this method returnstrue, all values for thisIIOParamobject will be ready for the next read or write operation. Iffalseis returned, no settings in this object will have been disturbed (i.e., the user canceled the operation).Ordinarily, the controller will be a GUI providing a user interface for a subclass of IIOParamfor a particular plug-in. Controllers need not be GUIs, however.- Returns:
- trueif the controller completed normally.
- Throws:
- IllegalStateException- if there is no controller currently installed.
- See Also:
 
 
-