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
    Creates RenderedImageSrc for encoding a Raster.
    Creates RenderedImageSrc for encoding a RenderedImage.
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    int
    Returns the height in pixels of the specified component in the current tile.
    int
    Returns the height in pixels of the specified component in the overall image.
    int
    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
    Returns the position of the fixed point in the specified component (i.e.
    int
    Returns the overall height of the image in pixels.
    int
    Returns the horizontal coordinate of the image origin, the top-left corner, in the canvas system, on the reference grid.
    int
    Returns the vertical coordinate of the image origin, the top-left corner, in the canvas system, on the reference grid.
    int
    Returns the overall width of the image in pixels.
    final DataBlk
    Returns, in the blk argument, the block of image data containing the specifed rectangular area, in the specified component.
    int
    Returns the number of bits corresponding to the nominal range of the data in the specified component.
    int
    Returns the nominal tiles height
    int
    Returns the nominal tiles width
    int
    Returns the number of components in the image.
    int
    Returns the total number of tiles in the image.
    Returns the number of tiles in the horizontal and vertical directions.
    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-component
    int
     
    int
     
    int
    Returns the overall height of the current tile in pixels.
    int
    Returns 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).
    int
    Returns the horizontal tile partition offset in the reference grid
    int
    Returns the vertical tile partition offset in the reference grid
    int
    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
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RenderedImageSrc

      public RenderedImageSrc(Raster raster, J2KImageWriteParamJava param, J2KImageWriter writer)
      Creates RenderedImageSrc for encoding a Raster.
      Parameters:
      raster - The Raster to be encoded.
      param - The J2KImageWriteParamJava used in encoding.
      writer - The J2KImageWriter performs the encoding.
      Throws:
      IOException - If an error occurs while opening the file.
    • RenderedImageSrc

      public RenderedImageSrc(RenderedImage src, J2KImageWriteParamJava param, J2KImageWriter writer)
      Creates RenderedImageSrc for encoding a RenderedImage.
      Parameters:
      src - The RenderedImage to be encoded.
      param - The J2KImageWriteParamJava used in encoding.
      writer - The J2KImageWriter performs the encoding.
      Throws:
      IOException - If an error occurs while opening the file.
  • Method Details

    • getTilePartULX

      public int getTilePartULX()
      Description copied from interface: ImgData
      Returns the horizontal tile partition offset in the reference grid
      Specified by:
      getTilePartULX in interface ImgData
    • getTilePartULY

      public int getTilePartULY()
      Description copied from interface: ImgData
      Returns the vertical tile partition offset in the reference grid
      Specified by:
      getTilePartULY in interface ImgData
    • getTileWidth

      public int getTileWidth()
      Returns the width of the current tile in pixels.
      Specified by:
      getTileWidth in interface ImgData
      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 interface ImgData
      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 interface ImgData
    • getNomTileHeight

      public int getNomTileHeight()
      Description copied from interface: ImgData
      Returns the nominal tiles height
      Specified by:
      getNomTileHeight in interface ImgData
    • 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 interface ImgData
      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 interface ImgData
      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 interface ImgData
      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 interface ImgData
      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 interface ImgData
      Parameters:
      t - Tile index
      c - 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 interface ImgData
      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:
      getCompSubsY in interface ImgData
      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:
      getCompImgWidth in interface ImgData
      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 interface ImgData
      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.
      Specified by:
      setTile in interface ImgData
      Parameters:
      x - The horizontal coordinate of the tile.
      y - The vertical coordinate of the new tile.
    • nextTile

      public void nextTile()
      Advances to the next tile, in standard scan-line order (by rows then columns).
      Specified by:
      nextTile in interface ImgData
    • getTile

      public Point getTile(Point co)
      Returns the coordinates of the current tile. This default implementation assumes no-tiling, so (0,0) is returned.
      Specified by:
      getTile in interface ImgData
      Parameters:
      co - If not null this object is used to return the information. If null a new one is created and returned.
      Returns:
      The current tile's coordinates.
    • getTileIdx

      public int getTileIdx()
      Returns the index of the current tile, relative to a standard scan-line order.
      Specified by:
      getTileIdx in interface ImgData
      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 interface ImgData
      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 interface ImgData
      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.
      Specified by:
      getImgULX in interface ImgData
      Returns:
      The horizontal coordinate of the image origin 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.
      Specified by:
      getImgULY in interface ImgData
      Returns:
      The vertical coordinate of the image origin 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 interface ImgData
      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 interface ImgData
      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 interface ImgData
      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 interface BlkImgDataSrc
      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 interface BlkImgDataSrc
      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

      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 interface BlkImgDataSrc
      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.