MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / saveShapeRoi

Method saveShapeRoi

ij/src/main/java/ij/io/RoiEncoder.java:322–354  ·  view source on GitHub ↗
(Roi roi, int type, OutputStream f, int options)

Source from the content-addressed store, hash-verified

320 }
321
322 void saveShapeRoi(Roi roi, int type, OutputStream f, int options) throws IOException {
323 float[] shapeArray = ((ShapeRoi)roi).getShapeAsArray();
324 if (shapeArray==null) return;
325 BufferedOutputStream bout = new BufferedOutputStream(f);
326 Rectangle r = roi.getBounds();
327 data = new byte[HEADER_SIZE+HEADER2_SIZE+shapeArray.length*4+roiNameSize+roiPropsSize];
328 data[0]=73; data[1]=111; data[2]=117; data[3]=116; // "Iout"
329
330 putShort(RoiDecoder.VERSION_OFFSET, VERSION);
331 data[RoiDecoder.TYPE] = (byte)type;
332 putShort(RoiDecoder.TOP, r.y);
333 putShort(RoiDecoder.LEFT, r.x);
334 putShort(RoiDecoder.BOTTOM, r.y+r.height);
335 putShort(RoiDecoder.RIGHT, r.x+r.width);
336 putInt(RoiDecoder.POSITION, roi.getPosition());
337 //putShort(16, n);
338 putInt(36, shapeArray.length); // non-zero segment count indicate composite type
339 if (VERSION>=218) saveStrokeWidthAndColor(roi);
340 saveOverlayOptions(roi, options);
341
342 // handle the actual data: data are stored segment-wise, i.e.,
343 // the type of the segment followed by 0-6 control point coordinates.
344 int base = 64;
345 for (int i=0; i<shapeArray.length; i++) {
346 putFloat(base, shapeArray[i]);
347 base += 4;
348 }
349 int hdr2Offset = HEADER_SIZE+shapeArray.length*4;
350 //ij.IJ.log("saveShapeRoi: "+HEADER_SIZE+" "+shapeArray.length);
351 putHeader2(roi, hdr2Offset);
352 bout.write(data,0,data.length);
353 bout.flush();
354 }
355
356 void saveOverlayOptions(Roi roi, int options) {
357 Overlay proto = roi.getPrototypeOverlay();

Callers 1

writeMethod · 0.95

Calls 11

putShortMethod · 0.95
putIntMethod · 0.95
saveOverlayOptionsMethod · 0.95
putFloatMethod · 0.95
putHeader2Method · 0.95
getShapeAsArrayMethod · 0.80
getBoundsMethod · 0.65
writeMethod · 0.65
flushMethod · 0.65
getPositionMethod · 0.45

Tested by

no test coverage detected