Saves the specified ROI as a byte array.
(Roi roi)
| 81 | |
| 82 | /** Saves the specified ROI as a byte array. */ |
| 83 | public static byte[] saveAsByteArray(Roi roi) { |
| 84 | if (roi==null) return null; |
| 85 | byte[] bytes = null; |
| 86 | try { |
| 87 | ByteArrayOutputStream out = new ByteArrayOutputStream(4096); |
| 88 | RoiEncoder encoder = new RoiEncoder(out); |
| 89 | encoder.write(roi); |
| 90 | out.close(); |
| 91 | bytes = out.toByteArray(); |
| 92 | } catch (IOException e) { |
| 93 | return null; |
| 94 | } |
| 95 | return bytes; |
| 96 | } |
| 97 | |
| 98 | void write(Roi roi, OutputStream f) throws IOException { |
| 99 | Rectangle r = roi.getBounds(); |
no test coverage detected