void saveTextRoi(TextRoi roi) { Font font = roi.getCurrentFont(); String fontName = font.getName(); int size = font.getSize(); int drawStringMode = roi.getDrawStringMode()?1024:0; int style = font.getStyle() + roi.getJustification()*256+drawStringMode; String text = roi.getText(); float angle = (float)roi.getAngle(); int angleLength = 4; int fontNameLength = fontName.length(); int textLength = text.length(); int textRoiDataLength = 16+fontNameLength*2+textLength*2 + angleLength; byte[] data2 = new byte[HEADER_SIZE+HEADER2_SIZE+textRoiDataLength+roiNameSize+roiPropsSize]; System.arraycopy(data, 0, data2, 0, HEADER_SIZE); data = data2; putShort(RoiDecoder.SUBTYPE, RoiDecoder.TEXT); putInt(HEADER_SIZE, size); putInt(HEADER_SIZE+4, style); putInt(HEADER_SIZE+8, fontNameLength); putInt(HEADER_SIZE+12, textLength); for (int i=0; i<fontNameLength; i++) putShort(HEADER_SIZE+16+i*2, fontName.charAt(i)); for (int i=0; i<textLength; i++) putShort(HEADER_SIZE+16+fontNameLength*2+i*2, text.charAt(i)); int hdr2Offset = HEADER_SIZE+textRoiDataLength; //ij.IJ.log("saveTextRoi: "+HEADER_SIZE+" "+textRoiDataLength+" "+fontNameLength+" "+textLength); putFloat(hdr2Offset-angleLength, angle); putHeader2(roi, hdr2Offset); }
void saveTextRoi(TextRoi roi) { Font font = roi.getCurrentFont(); String fontName = font.getName(); int size = font.getSize(); int drawStringMode = roi.getDrawStringMode()?1024:0; int style = font.getStyle() + roi.getJustification()*256+drawStringMode; String text = roi.getText(); float angle = (float)roi.getAngle(); int angleLength = 4; int fontNameLength = fontName.length(); int textLength = text.length(); int textRoiDataLength = 16+fontNameLength*2+textLength*2 + angleLength; byte[] data2 = new byte[HEADER_SIZE+HEADER2_SIZE+textRoiDataLength+roiNameSize+roiPropsSize]; System.arraycopy(data, 0, data2, 0, HEADER_SIZE); data = data2; putShort(RoiDecoder.SUBTYPE, RoiDecoder.TEXT); putInt(HEADER_SIZE, size); putInt(HEADER_SIZE+4, style); putInt(HEADER_SIZE+8, fontNameLength); putInt(HEADER_SIZE+12, textLength); for (int i=0; i<fontNameLength; i++) putShort(HEADER_SIZE+16+i*2, fontName.charAt(i)); for (int i=0; i<textLength; i++) putShort(HEADER_SIZE+16+fontNameLength*2+i*2, text.charAt(i)); int hdr2Offset = HEADER_SIZE+textRoiDataLength; //ij.IJ.log("saveTextRoi: "+HEADER_SIZE+" "+textRoiDataLength+" "+fontNameLength+" "+textLength); putFloat(hdr2Offset-angleLength, angle); putHeader2(roi, hdr2Offset); }