Class RenderedImageSrc
- java.lang.Object
-
- com.sun.media.imageioimpl.plugins.jpeg2000.RenderedImageSrc
-
- All Implemented Interfaces:
BlkImgDataSrc
,ImgData
public class RenderedImageSrc extends Object implements BlkImgDataSrc
-
-
Constructor Summary
Constructors Constructor Description RenderedImageSrc(Raster raster, J2KImageWriteParamJava param, J2KImageWriter writer)
CreatesRenderedImageSrc
for encoding aRaster
.RenderedImageSrc(RenderedImage src, J2KImageWriteParamJava param, J2KImageWriter writer)
CreatesRenderedImageSrc
for encoding aRenderedImage
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DataBlk
getCompData(DataBlk blk, int c)
Returns, in the blk argument, a block of image data containing the specifed rectangular area, in the specified component.int
getCompHeight(int c)
Returns the height in pixels of the specified component in the current tile.int
getCompImgHeight(int c)
Returns the height in pixels of the specified component in the overall image.int
getCompImgWidth(int c)
Returns the width in pixels of the specified component in the overall image.int
getCompSubsX(int c)
Returns the component subsampling factor in the horizontal direction, for the specified component.int
getCompSubsY(int c)
Returns the component subsampling factor in the vertical direction, for the specified component.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.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.int
getCompWidth(int n)
Returns the width in pixels of the specified component in the current tile.int
getFixedPoint(int c)
Returns the position of the fixed point in the specified component (i.e.int
getImgHeight()
Returns the overall height of the image in pixels.int
getImgULX()
Returns the horizontal coordinate of the image origin, the top-left corner, in the canvas system, on the reference grid.int
getImgULY()
Returns the vertical coordinate of the image origin, the top-left corner, in the canvas system, on the reference grid.int
getImgWidth()
Returns the overall width of the image in pixels.DataBlk
getInternCompData(DataBlk blk, int c)
Returns, in the blk argument, the block of image data containing the specifed rectangular area, in the specified component.int
getNomRangeBits(int c)
Returns the number of bits corresponding to the nominal range of the data in the specified component.int
getNomTileHeight()
Returns the nominal tiles heightint
getNomTileWidth()
Returns the nominal tiles widthint
getNumComps()
Returns the number of components in the image.int
getNumTiles()
Returns the total number of tiles in the image.Point
getNumTiles(Point co)
Returns the number of tiles in the horizontal and vertical directions.Point
getTile(Point co)
Returns the coordinates of the current tile.int
getTileCompHeight(int t, int c)
Returns the height in pixels of the specified tile-component.int
getTileCompWidth(int t, int c)
Returns the width in pixels of the specified tile-componentint
getTileGridXOffset()
int
getTileGridYOffset()
int
getTileHeight()
Returns the overall height of the current tile in pixels.int
getTileIdx()
Returns the index of the current tile, relative to a standard scan-line order.Point
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).int
getTilePartULX()
Returns the horizontal tile partition offset in the reference gridint
getTilePartULY()
Returns the vertical tile partition offset in the reference gridint
getTileWidth()
Returns the width of the current tile in pixels.boolean
isOrigSigned(int c)
Returns true if the data read was originally signed in the specified component, false if not.void
nextTile()
Advances to the next tile, in standard scan-line order (by rows then columns).void
setTile(int x, int y)
Changes the current tile, given the new coordinates.
-
-
-
Constructor Detail
-
RenderedImageSrc
public RenderedImageSrc(Raster raster, J2KImageWriteParamJava param, J2KImageWriter writer)
CreatesRenderedImageSrc
for encoding aRaster
.- Parameters:
raster
- TheRaster
to be encoded.param
- TheJ2KImageWriteParamJava
used in encoding.writer
- TheJ2KImageWriter
performs the encoding.- Throws:
IOException
- If an error occurs while opening the file.
-
RenderedImageSrc
public RenderedImageSrc(RenderedImage src, J2KImageWriteParamJava param, J2KImageWriter writer)
CreatesRenderedImageSrc
for encoding aRenderedImage
.- Parameters:
src
- TheRenderedImage
to be encoded.param
- TheJ2KImageWriteParamJava
used in encoding.writer
- TheJ2KImageWriter
performs the encoding.- Throws:
IOException
- If an error occurs while opening the file.
-
-
Method Detail
-
getTilePartULX
public int getTilePartULX()
Description copied from interface:ImgData
Returns the horizontal tile partition offset in the reference grid- Specified by:
getTilePartULX
in interfaceImgData
-
getTilePartULY
public int getTilePartULY()
Description copied from interface:ImgData
Returns the vertical tile partition offset in the reference grid- Specified by:
getTilePartULY
in interfaceImgData
-
getTileWidth
public int getTileWidth()
Returns the width of the current tile in pixels.- Specified by:
getTileWidth
in interfaceImgData
- Returns:
- The total image width in pixels.
-
getTileHeight
public int getTileHeight()
Returns the overall height of the current tile in pixels.- Specified by:
getTileHeight
in interfaceImgData
- Returns:
- The total image height in pixels.
-
getNomTileWidth
public int getNomTileWidth()
Description copied from interface:ImgData
Returns the nominal tiles width- Specified by:
getNomTileWidth
in interfaceImgData
-
getNomTileHeight
public int getNomTileHeight()
Description copied from interface:ImgData
Returns the nominal tiles height- Specified by:
getNomTileHeight
in 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:
getImgWidth
in 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:
getImgHeight
in 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:
getNumComps
in 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:ImgData
Returns the height in pixels of the specified tile-component.- Specified by:
getTileCompHeight
in 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:ImgData
Returns the width in pixels of the specified tile-component- Specified by:
getTileCompWidth
in 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:
getCompSubsX
in interfaceImgData
- Parameters:
c
- The index of the component (between 0 and C-1)- Returns:
- The horizontal subsampling factor of component 'c'
- See Also:
ImgData
-
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:
getCompSubsY
in interfaceImgData
- Parameters:
c
- The index of the component (between 0 and C-1)- Returns:
- The vertical subsampling factor of component 'c'
- See Also:
ImgData
-
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:
getCompImgWidth
in 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:
getCompImgHeight
in 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
public Point getTile(Point co)
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:
getTileIdx
in interfaceImgData
- Returns:
- The current tile's index (starts at 0).
-
getTileOff
public Point 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). 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:
getCompULX
in 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:
getCompULY
in 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
public Point getNumTiles(Point co)
Returns the number of tiles in the horizontal and vertical directions.- Specified by:
getNumTiles
in 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:
getNumTiles
in 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:
getNomRangeBits
in 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:
getFixedPoint
in 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
public final DataBlk getInternCompData(DataBlk blk, int c)
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:
getInternCompData
in 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(jj2000.j2k.image.DataBlk, int)
,JJ2KExceptionHandler
-
getCompData
public final DataBlk getCompData(DataBlk blk, int c)
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:
getCompData
in 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:
getInternCompData(jj2000.j2k.image.DataBlk, int)
,JJ2KExceptionHandler
-
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.
-
-