Class RenderedImageSrc
- All Implemented Interfaces:
BlkImgDataSrc,ImgData
-
Constructor Summary
ConstructorsConstructorDescriptionRenderedImageSrc(Raster raster, J2KImageWriteParamJava param, J2KImageWriter writer) CreatesRenderedImageSrcfor encoding aRaster.RenderedImageSrc(RenderedImage src, J2KImageWriteParamJava param, J2KImageWriter writer) CreatesRenderedImageSrcfor encoding aRenderedImage. -
Method Summary
Modifier and TypeMethodDescriptionfinal DataBlkgetCompData(DataBlk blk, int c) Returns, in the blk argument, a block of image data containing the specifed rectangular area, in the specified component.intgetCompHeight(int c) Returns the height in pixels of the specified component in the current tile.intgetCompImgHeight(int c) Returns the height in pixels of the specified component in the overall image.intgetCompImgWidth(int c) Returns the width in pixels of the specified component in the overall image.intgetCompSubsX(int c) Returns the component subsampling factor in the horizontal direction, for the specified component.intgetCompSubsY(int c) Returns the component subsampling factor in the vertical direction, for the specified component.intgetCompULX(int c) Returns the horizontal coordinate of the upper-left corner of the active tile, with respect to the canvas origin, in the component coordinates, for the specified component.intgetCompULY(int c) Returns the vertical coordinate of the upper-left corner of the active tile, with respect to the canvas origin, in the component coordinates, for the specified component.intgetCompWidth(int n) Returns the width in pixels of the specified component in the current tile.intgetFixedPoint(int c) Returns the position of the fixed point in the specified component (i.e.intReturns the overall height of the image in pixels.intReturns the horizontal coordinate of the image origin, the top-left corner, in the canvas system, on the reference grid.intReturns the vertical coordinate of the image origin, the top-left corner, in the canvas system, on the reference grid.intReturns the overall width of the image in pixels.final DataBlkgetInternCompData(DataBlk blk, int c) Returns, in the blk argument, the block of image data containing the specifed rectangular area, in the specified component.intgetNomRangeBits(int c) Returns the number of bits corresponding to the nominal range of the data in the specified component.intReturns the nominal tiles heightintReturns the nominal tiles widthintReturns the number of components in the image.intReturns the total number of tiles in the image.getNumTiles(Point co) Returns the number of tiles in the horizontal and vertical directions.Returns the coordinates of the current tile.intgetTileCompHeight(int t, int c) Returns the height in pixels of the specified tile-component.intgetTileCompWidth(int t, int c) Returns the width in pixels of the specified tile-componentintintintReturns the overall height of the current tile in pixels.intReturns the index of the current tile, relative to a standard scan-line order.getTileOff(Point p, int c) Returns the horizontal and vertical offset of the upper-left corner of the current tile, in the specified component, relative to the canvas origin, in the component coordinates (not in the reference grid coordinates).intReturns the horizontal tile partition offset in the reference gridintReturns the vertical tile partition offset in the reference gridintReturns the width of the current tile in pixels.booleanisOrigSigned(int c) Returns true if the data read was originally signed in the specified component, false if not.voidnextTile()Advances to the next tile, in standard scan-line order (by rows then columns).voidsetTile(int x, int y) Changes the current tile, given the new coordinates.
-
Constructor Details
-
RenderedImageSrc
CreatesRenderedImageSrcfor encoding aRaster.- Parameters:
raster- TheRasterto be encoded.param- TheJ2KImageWriteParamJavaused in encoding.writer- TheJ2KImageWriterperforms the encoding.- Throws:
IOException- If an error occurs while opening the file.
-
RenderedImageSrc
CreatesRenderedImageSrcfor encoding aRenderedImage.- Parameters:
src- TheRenderedImageto be encoded.param- TheJ2KImageWriteParamJavaused in encoding.writer- TheJ2KImageWriterperforms the encoding.- Throws:
IOException- If an error occurs while opening the file.
-
-
Method Details
-
getTilePartULX
public int getTilePartULX()Description copied from interface:ImgDataReturns the horizontal tile partition offset in the reference grid- Specified by:
getTilePartULXin interfaceImgData
-
getTilePartULY
public int getTilePartULY()Description copied from interface:ImgDataReturns the vertical tile partition offset in the reference grid- Specified by:
getTilePartULYin interfaceImgData
-
getTileWidth
public int getTileWidth()Returns the width of the current tile in pixels.- Specified by:
getTileWidthin interfaceImgData- Returns:
- The total image width in pixels.
-
getTileHeight
public int getTileHeight()Returns the overall height of the current tile in pixels.- Specified by:
getTileHeightin interfaceImgData- Returns:
- The total image height in pixels.
-
getNomTileWidth
public int getNomTileWidth()Description copied from interface:ImgDataReturns the nominal tiles width- Specified by:
getNomTileWidthin interfaceImgData
-
getNomTileHeight
public int getNomTileHeight()Description copied from interface:ImgDataReturns the nominal tiles height- Specified by:
getNomTileHeightin interfaceImgData
-
getImgWidth
public int getImgWidth()Returns the overall width of the image in pixels. This is the image's width without accounting for any component subsampling or tiling. The value of w is returned.- Specified by:
getImgWidthin interfaceImgData- Returns:
- The total image's width in pixels.
-
getImgHeight
public int getImgHeight()Returns the overall height of the image in pixels. This is the image's height without accounting for any component subsampling or tiling. The value of h is returned.- Specified by:
getImgHeightin interfaceImgData- Returns:
- The total image's height in pixels.
-
getNumComps
public int getNumComps()Returns the number of components in the image. The value of nc is returned.- Specified by:
getNumCompsin interfaceImgData- Returns:
- The number of components in the image.
-
getTileGridXOffset
public int getTileGridXOffset() -
getTileGridYOffset
public int getTileGridYOffset() -
getTileCompHeight
public int getTileCompHeight(int t, int c) Description copied from interface:ImgDataReturns the height in pixels of the specified tile-component.- Specified by:
getTileCompHeightin interfaceImgData- Parameters:
t- The tile index.c- The index of the component, from 0 to N-1.- Returns:
- The height in pixels of component c in tile t.
-
getTileCompWidth
public int getTileCompWidth(int t, int c) Description copied from interface:ImgDataReturns the width in pixels of the specified tile-component- Specified by:
getTileCompWidthin interfaceImgData- Parameters:
t- Tile indexc- The index of the component, from 0 to N-1.- Returns:
- The width in pixels of component c in tilet.
-
getCompSubsX
public int getCompSubsX(int c) Returns the component subsampling factor in the horizontal direction, for the specified component. This is, approximately, the ratio of dimensions between the reference grid and the component itself, see the 'ImgData' interface desription for details.- Specified by:
getCompSubsXin interfaceImgData- Parameters:
c- The index of the component (between 0 and C-1)- Returns:
- The horizontal subsampling factor of component 'c'
- See Also:
-
getCompSubsY
public int getCompSubsY(int c) Returns the component subsampling factor in the vertical direction, for the specified component. This is, approximately, the ratio of dimensions between the reference grid and the component itself, see the 'ImgData' interface desription for details.- Specified by:
getCompSubsYin interfaceImgData- Parameters:
c- The index of the component (between 0 and C-1)- Returns:
- The vertical subsampling factor of component 'c'
- See Also:
-
getCompWidth
public int getCompWidth(int n) Returns the width in pixels of the specified component in the current tile. This default implementation assumes no tiling and no component subsampling (i.e., all components, or components, have the same dimensions in pixels).- Parameters:
n- The index of the component, from 0 to C-1.- Returns:
- The width in pixels of component n in the current tile.
-
getCompHeight
public int getCompHeight(int c) Returns the height in pixels of the specified component in the current tile. This default implementation assumes no tiling and no component subsampling (i.e., all components, or components, have the same dimensions in pixels).- Parameters:
c- The index of the component, from 0 to C-1.- Returns:
- The height in pixels of component c in the current tile.
-
getCompImgWidth
public int getCompImgWidth(int c) Returns the width in pixels of the specified component in the overall image. This default implementation assumes no component, or component, subsampling (i.e. all components have the same dimensions in pixels).- Specified by:
getCompImgWidthin interfaceImgData- Parameters:
c- The index of the component, from 0 to C-1.- Returns:
- The width in pixels of component c in the overall image.
-
getCompImgHeight
public int getCompImgHeight(int c) Returns the height in pixels of the specified component in the overall image. This default implementation assumes no component, or component, subsampling (i.e. all components have the same dimensions in pixels).- Specified by:
getCompImgHeightin interfaceImgData- Parameters:
c- The index of the component, from 0 to C-1.- Returns:
- The height in pixels of component c in the overall image.
-
setTile
public void setTile(int x, int y) Changes the current tile, given the new coordinates. -
nextTile
public void nextTile()Advances to the next tile, in standard scan-line order (by rows then columns). -
getTile
Returns the coordinates of the current tile. This default implementation assumes no-tiling, so (0,0) is returned. -
getTileIdx
public int getTileIdx()Returns the index of the current tile, relative to a standard scan-line order.- Specified by:
getTileIdxin interfaceImgData- Returns:
- The current tile's index (starts at 0).
-
getTileOff
Returns the horizontal and vertical offset of the upper-left corner of the current tile, in the specified component, relative to the canvas origin, in the component coordinates (not in the reference grid coordinates). These are the coordinates of the current tile's (not active tile) upper-left corner relative to the canvas.- Parameters:
p- If not null the object is used to return the values, if null a new one is created and returned.c- The index of the component (between 0 and C-1)- Returns:
- The horizontal and vertical offsets of the upper-left corner of the current tile, for the specified component, relative to the canvas origin, in the component coordinates.
-
getCompULX
public int getCompULX(int c) Returns the horizontal coordinate of the upper-left corner of the active tile, with respect to the canvas origin, in the component coordinates, for the specified component.- Specified by:
getCompULXin interfaceImgData- Parameters:
c- The index of the component (between 0 and C-1)- Returns:
- The horizontal coordinate of the upper-left corner of the active tile, with respect to the canvas origin, for component 'c', in the component coordinates.
-
getCompULY
public int getCompULY(int c) Returns the vertical coordinate of the upper-left corner of the active tile, with respect to the canvas origin, in the component coordinates, for the specified component.- Specified by:
getCompULYin interfaceImgData- Parameters:
c- The index of the component (between 0 and C-1)- Returns:
- The vertical coordinate of the upper-left corner of the active tile, with respect to the canvas origin, for component 'c', in the component coordinates.
-
getImgULX
public int getImgULX()Returns the horizontal coordinate of the image origin, the top-left corner, in the canvas system, on the reference grid. -
getImgULY
public int getImgULY()Returns the vertical coordinate of the image origin, the top-left corner, in the canvas system, on the reference grid. -
getNumTiles
Returns the number of tiles in the horizontal and vertical directions.- Specified by:
getNumTilesin interfaceImgData- Parameters:
co- If not null this object is used to return the information. If null a new one is created and returned.- Returns:
- The number of tiles in the horizontal (Point.x) and vertical (Point.y) directions.
-
getNumTiles
public int getNumTiles()Returns the total number of tiles in the image. This default implementation assumes no tiling, so 1 is always returned.- Specified by:
getNumTilesin interfaceImgData- Returns:
- The total number of tiles in the image.
-
getNomRangeBits
public int getNomRangeBits(int c) Returns the number of bits corresponding to the nominal range of the data in the specified component. This is the value rb (range bits) that was specified in the constructor, which normally is 8 for non bilevel data, and 1 for bilevel data.If this number is b then the nominal range is between -2^(b-1) and 2^(b-1)-1, since unsigned data is level shifted to have a nominal avergae of 0.
- Specified by:
getNomRangeBitsin interfaceImgData- Parameters:
c- The index of the component.- Returns:
- The number of bits corresponding to the nominal range of the data. For floating-point data this value is not applicable and the return value is undefined.
-
getFixedPoint
public int getFixedPoint(int c) Returns the position of the fixed point in the specified component (i.e. the number of fractional bits), which is always 0 for this ImgReader.- Specified by:
getFixedPointin interfaceBlkImgDataSrc- Parameters:
c- The index of the component.- Returns:
- The position of the fixed-point (i.e. the number of fractional bits). Always 0 for this ImgReader.
-
getInternCompData
Returns, in the blk argument, the block of image data containing the specifed rectangular area, in the specified component. The data is returned, as a reference to the internal data, if any, instead of as a copy, therefore the returned data should not be modified.After being read the coefficients are level shifted by subtracting 2^(nominal bit range - 1)
The rectangular area to return is specified by the 'ulx', 'uly', 'w' and 'h' members of the 'blk' argument, relative to the current tile. These members are not modified by this method. The 'offset' and 'scanw' of the returned data can be arbitrary. See the 'DataBlk' class.
If the data array in blk is null, then a new one is created if necessary. The implementation of this interface may choose to return the same array or a new one, depending on what is more efficient. Therefore, the data array in blk prior to the method call should not be considered to contain the returned data, a new array may have been created. Instead, get the array from blk after the method has returned.
The returned data always has its 'progressive' attribute unset (i.e. false).
When an I/O exception is encountered the JJ2KExceptionHandler is used. The exception is passed to its handleException method. The action that is taken depends on the action that has been registered in JJ2KExceptionHandler. See JJ2KExceptionHandler for details.
This method implements buffering for the 3 components: When the first one is asked, all the 3 components are read and stored until they are needed.
- Specified by:
getInternCompDatain interfaceBlkImgDataSrc- Parameters:
blk- Its coordinates and dimensions specify the area to return. Some fields in this object are modified to return the data.c- The index of the component from which to get the data. Only 0, 1 and 3 are valid.- Returns:
- The requested DataBlk
- See Also:
-
getCompData
Returns, in the blk argument, a block of image data containing the specifed rectangular area, in the specified component. The data is returned, as a copy of the internal data, therefore the returned data can be modified "in place".After being read the coefficients are level shifted by subtracting 2^(nominal bit range - 1)
The rectangular area to return is specified by the 'ulx', 'uly', 'w' and 'h' members of the 'blk' argument, relative to the current tile. These members are not modified by this method. The 'offset' of the returned data is 0, and the 'scanw' is the same as the block's width. See the 'DataBlk' class.
If the data array in 'blk' is 'null', then a new one is created. If the data array is not 'null' then it is reused, and it must be large enough to contain the block's data. Otherwise an 'ArrayStoreException' or an 'IndexOutOfBoundsException' is thrown by the Java system.
The returned data has its 'progressive' attribute unset (i.e. false).
When an I/O exception is encountered the JJ2KExceptionHandler is used. The exception is passed to its handleException method. The action that is taken depends on the action that has been registered in JJ2KExceptionHandler. See JJ2KExceptionHandler for details.
- Specified by:
getCompDatain interfaceBlkImgDataSrc- Parameters:
blk- Its coordinates and dimensions specify the area to return. If it contains a non-null data array, then it must have the correct dimensions. If it contains a null data array a new one is created. The fields in this object are modified to return the data.c- The index of the component from which to get the data. Only 0,1 and 2 are valid.- Returns:
- The requested DataBlk
- See Also:
-
isOrigSigned
public boolean isOrigSigned(int c) Returns true if the data read was originally signed in the specified component, false if not. This method always returns false since PPM data is always unsigned.- Parameters:
c- The index of the component, from 0 to N-1.- Returns:
- always false, since PPM data is always unsigned.
-