Module ij
Package ij.io

# Class RoiDecoder

java.lang.Object
ij.io.RoiDecoder

public class RoiDecoder extends Object
This class decodes an ImageJ .roi file.

Format of the original 64 byte ImageJ/NIH Image .roi file header. Two byte numbers are big-endian signed shorts. The JavaScript example at http://wsr.imagej.net/macros/js/DecodeRoiFile.js demonstrates how to use this information to decode a .roi file.

            0-3             "Iout"
            4-5             version (>=217)
            6-7             roi type (encoded as one byte)
            8-9             top
            10-11   left
            12-13   bottom
            14-15   right
            16-17   NCoordinates
            18-33   x1,y1,x2,y2 (straight line) | x,y,width,height (double rect) | size (npoints)
            34-35   stroke width (v1.43i or later)
            36-39   ShapeRoi size (type must be 1 if this value>0)
            40-43   stroke color (v1.43i or later)
            44-47   fill color (v1.43i or later)
            48-49   subtype (v1.43k or later)
            50-51   options (v1.43k or later)
            52-52   arrow style or aspect ratio (v1.43p or later)
            53-53   arrow head size (v1.43p or later)
            54-55   rounded rect arc size (v1.43p or later)
            56-59   position
            60-63   header2 offset
            64-       x-coordinates (short), followed by y-coordinates

See Also:
  - DecodeRoiFile.js

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`ARROW`
`static final int`
`ARROW_HEAD_SIZE`
`static final int`
`ARROW_STYLE`
`static final int`
`BOTTOM`
`static final int`
`C_POSITION`
`static final int`
`COORDINATES`
`static final int`
`COUNTERS_OFFSET`
`static final int`
`DOUBLE_HEADED`
`static final int`
`DRAW_OFFSET`
`static final int`
`ELLIPSE`
`static final int`
`FILL_COLOR`
`static final int`
`FLOAT_PARAM`
`static final int`
`FLOAT_STROKE_WIDTH`
`static final int`
`GROUP`
`static final int`
`HEADER2_OFFSET`
`static final int`
`HEIGHTD`
`static final int`
`IMAGE`
`static final int`
`IMAGE_OPACITY`
`static final int`
`IMAGE_SIZE`
`static final int`
`LEFT`
`static final int`
`N_COORDINATES`
`static final int`
`NAME_LENGTH`
`static final int`
`NAME_OFFSET`
`static final int`
`OPTIONS`
`static final int`
`OUTLINE`
`static final int`
`OVERLAY_BACKGROUNDS`
`static final int`
`OVERLAY_BOLD`
`static final int`
`OVERLAY_FONT_SIZE`
`static final int`
`OVERLAY_LABEL_COLOR`
`static final int`
`OVERLAY_LABELS`
`static final int`
`OVERLAY_NAMES`
`static final int`
`POINT_TYPE`
`static final int`
`POSITION`
`static final int`
`PROMPT_BEFORE_DELETING`
`static final int`
`RIGHT`
`static final int`
`ROI_PROPS_LENGTH`
`static final int`
`ROI_PROPS_OFFSET`
`static final int`
`ROTATED_RECT`
`static final int`
`ROUNDED_RECT_ARC_SIZE`
`static final int`
`SCALE_LABELS`
`static final int`
`SCALE_STROKE_WIDTH`
`static final int`
`SHAPE_ROI_SIZE`
`static final int`
`SHOW_LABELS`
`static final int`
`SIZE`
`static final int`
`SPLINE_FIT`
`static final int`
`STROKE_COLOR`
`static final int`
`STROKE_WIDTH`
`static final int`
`SUB_PIXEL_RESOLUTION`
`static final int`
`SUBTYPE`
`static final int`
`T_POSITION`
`static final int`
`TEXT`
`static final int`
`TOP`
`static final int`
`TYPE`
`static final int`
`VERSION_OFFSET`
`static final int`
`WIDTHD`
`static final int`
`X1`
`static final int`
`X2`
`static final int`
`XD`
`static final int`
`Y1`
`static final int`
`Y2`
`static final int`
`YD`
`static final int`
`Z_POSITION`
`static final int`
`ZERO_TRANSPARENT`

## Constructor Summary

Constructors
Constructor
Description
`RoiDecoder(byte[] bytes, String name)`
Constructs an RoiDecoder using a byte array.
`RoiDecoder(String path)`
Constructs an RoiDecoder using a file path.

## Method Summary

Modifier and Type
Method
Description
`Roi`
`getRoi()`
Returns the ROI.
`Roi`
`getShapeRoi()`
`static Roi`
`open(String path)`
Opens the Roi at the specified path.
`static Roi`
`openFromByteArray(byte[] bytes)`
Opens an ROI from a byte array.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### VERSION_OFFSET

public static final int VERSION_OFFSET

See Also:
  - Constant Field Values

### TYPE

public static final int TYPE

See Also:
  - Constant Field Values

### TOP

public static final int TOP

See Also:
  - Constant Field Values

### LEFT

public static final int LEFT

See Also:
  - Constant Field Values

### BOTTOM

public static final int BOTTOM

See Also:
  - Constant Field Values

### RIGHT

public static final int RIGHT

See Also:
  - Constant Field Values

### N_COORDINATES

public static final int N_COORDINATES

See Also:
  - Constant Field Values

### X1

public static final int X1

See Also:
  - Constant Field Values

### Y1

public static final int Y1

See Also:
  - Constant Field Values

### X2

public static final int X2

See Also:
  - Constant Field Values

### Y2

public static final int Y2

See Also:
  - Constant Field Values

### XD

public static final int XD

See Also:
  - Constant Field Values

### YD

public static final int YD

See Also:
  - Constant Field Values

### WIDTHD

public static final int WIDTHD

See Also:
  - Constant Field Values

### HEIGHTD

public static final int HEIGHTD

See Also:
  - Constant Field Values

### SIZE

public static final int SIZE

See Also:
  - Constant Field Values

### STROKE_WIDTH

public static final int STROKE_WIDTH

See Also:
  - Constant Field Values

### SHAPE_ROI_SIZE

public static final int SHAPE_ROI_SIZE

See Also:
  - Constant Field Values

### STROKE_COLOR

public static final int STROKE_COLOR

See Also:
  - Constant Field Values

### FILL_COLOR

public static final int FILL_COLOR

See Also:
  - Constant Field Values

### SUBTYPE

public static final int SUBTYPE

See Also:
  - Constant Field Values

### OPTIONS

public static final int OPTIONS

See Also:
  - Constant Field Values

### ARROW_STYLE

public static final int ARROW_STYLE

See Also:
  - Constant Field Values

### FLOAT_PARAM

public static final int FLOAT_PARAM

See Also:
  - Constant Field Values

### POINT_TYPE

public static final int POINT_TYPE

See Also:
  - Constant Field Values

### ARROW_HEAD_SIZE

public static final int ARROW_HEAD_SIZE

See Also:
  - Constant Field Values

### ROUNDED_RECT_ARC_SIZE

public static final int ROUNDED_RECT_ARC_SIZE

See Also:
  - Constant Field Values

### POSITION

public static final int POSITION

See Also:
  - Constant Field Values

### HEADER2_OFFSET

public static final int HEADER2_OFFSET

See Also:
  - Constant Field Values

### COORDINATES

public static final int COORDINATES

See Also:
  - Constant Field Values

### C_POSITION

public static final int C_POSITION

See Also:
  - Constant Field Values

### Z_POSITION

public static final int Z_POSITION

See Also:
  - Constant Field Values

### T_POSITION

public static final int T_POSITION

See Also:
  - Constant Field Values

### NAME_OFFSET

public static final int NAME_OFFSET

See Also:
  - Constant Field Values

### NAME_LENGTH

public static final int NAME_LENGTH

See Also:
  - Constant Field Values

### OVERLAY_LABEL_COLOR

public static final int OVERLAY_LABEL_COLOR

See Also:
  - Constant Field Values

### OVERLAY_FONT_SIZE

public static final int OVERLAY_FONT_SIZE

See Also:
  - Constant Field Values

### GROUP

public static final int GROUP

See Also:
  - Constant Field Values

### IMAGE_OPACITY

public static final int IMAGE_OPACITY

See Also:
  - Constant Field Values

### IMAGE_SIZE

public static final int IMAGE_SIZE

See Also:
  - Constant Field Values

### FLOAT_STROKE_WIDTH

public static final int FLOAT_STROKE_WIDTH

See Also:
  - Constant Field Values

### ROI_PROPS_OFFSET

public static final int ROI_PROPS_OFFSET

See Also:
  - Constant Field Values

### ROI_PROPS_LENGTH

public static final int ROI_PROPS_LENGTH

See Also:
  - Constant Field Values

### COUNTERS_OFFSET

public static final int COUNTERS_OFFSET

See Also:
  - Constant Field Values

### TEXT

public static final int TEXT

See Also:
  - Constant Field Values

### ARROW

public static final int ARROW

See Also:
  - Constant Field Values

### ELLIPSE

public static final int ELLIPSE

See Also:
  - Constant Field Values

### IMAGE

public static final int IMAGE

See Also:
  - Constant Field Values

### ROTATED_RECT

public static final int ROTATED_RECT

See Also:
  - Constant Field Values

### SPLINE_FIT

public static final int SPLINE_FIT

See Also:
  - Constant Field Values

### DOUBLE_HEADED

public static final int DOUBLE_HEADED

See Also:
  - Constant Field Values

### OUTLINE

public static final int OUTLINE

See Also:
  - Constant Field Values

### OVERLAY_LABELS

public static final int OVERLAY_LABELS

See Also:
  - Constant Field Values

### OVERLAY_NAMES

public static final int OVERLAY_NAMES

See Also:
  - Constant Field Values

### OVERLAY_BACKGROUNDS

public static final int OVERLAY_BACKGROUNDS

See Also:
  - Constant Field Values

### OVERLAY_BOLD

public static final int OVERLAY_BOLD

See Also:
  - Constant Field Values

### SUB_PIXEL_RESOLUTION

public static final int SUB_PIXEL_RESOLUTION

See Also:
  - Constant Field Values

### DRAW_OFFSET

public static final int DRAW_OFFSET

See Also:
  - Constant Field Values

### ZERO_TRANSPARENT

public static final int ZERO_TRANSPARENT

See Also:
  - Constant Field Values

### SHOW_LABELS

public static final int SHOW_LABELS

See Also:
  - Constant Field Values

### SCALE_LABELS

public static final int SCALE_LABELS

See Also:
  - Constant Field Values

### PROMPT_BEFORE_DELETING

public static final int PROMPT_BEFORE_DELETING

See Also:
  - Constant Field Values

### SCALE_STROKE_WIDTH

public static final int SCALE_STROKE_WIDTH

See Also:
  - Constant Field Values

## Constructor Details

### RoiDecoder

public RoiDecoder(String path)
Constructs an RoiDecoder using a file path.

### RoiDecoder

public RoiDecoder(byte[] bytes, String name)
Constructs an RoiDecoder using a byte array.

## Method Details

### open

public static Roi open(String path)
Opens the Roi at the specified path. Returns null if there is an error.

### getRoi

public Roi getRoi() throws IOException
Returns the ROI.

Throws:
  `IOException`

### getShapeRoi

public Roi getShapeRoi() throws IOException

Throws:
  `IOException`

### openFromByteArray

public static Roi openFromByteArray(byte[] bytes)
Opens an ROI from a byte array.