@@ -41,10 +41,6 @@ public void run(String arg) {
4141 Roi roiA = imp .getRoi ();
4242 ImagePlus impA = imp ;
4343 boolean isRotatedRect = (roiA !=null && roiA instanceof RotatedRectRoi );
44- if (isRotatedRect ) {
45- Rectangle bounds = imp .getRoi ().getBounds ();
46- imp .setRoi (bounds );
47- }
4844 boolean roiOutside = false ;
4945 if (roiA !=null ) {
5046 Rectangle r = roiA .getBounds ();
@@ -63,13 +59,17 @@ public void run(String arg) {
6359 if (imp .isHyperStack () || imp .isComposite ()) {
6460 if (roiOutside )
6561 imp .deleteRoi ();
66- duplicateHyperstack (imp , newTitle );
67- if (isRotatedRect )
62+ boolean ok = duplicateHyperstack (imp , newTitle );
63+ if (ok && isRotatedRect )
6864 straightenRotatedRect (impA , roiA , IJ .getImage ());
6965 return ;
7066 } else
7167 newTitle = showDialog (imp , "Duplicate..." , "Title: " );
7268 }
69+ if (isRotatedRect ) {
70+ Rectangle bounds = imp .getRoi ().getBounds ();
71+ imp .setRoi (bounds );
72+ }
7373 if (newTitle ==null ) {
7474 if (isRotatedRect )
7575 imp .setRoi (roiA );
@@ -551,10 +551,10 @@ private String getNewTitle() {
551551 return title ;
552552 }
553553
554- void duplicateHyperstack (ImagePlus imp , String newTitle ) {
554+ boolean duplicateHyperstack (ImagePlus imp , String newTitle ) {
555555 newTitle = showHSDialog (imp , newTitle );
556556 if (newTitle ==null )
557- return ;
557+ return false ;
558558 ImagePlus imp2 = null ;
559559 Roi roi = imp .getRoi ();
560560 if (!duplicateStack ) {
@@ -569,11 +569,11 @@ void duplicateHyperstack(ImagePlus imp, String newTitle) {
569569 firstT = lastT = imp .getFrame ();
570570 }
571571 imp2 = run (imp , firstC , lastC , firstZ , lastZ , firstT , lastT );
572- if (imp2 ==null ) return ;
572+ if (imp2 ==null ) return false ;
573573 imp2 .setTitle (newTitle );
574574 if (imp2 .getWidth ()==0 || imp2 .getHeight ()==0 ) {
575575 IJ .error ("Duplicator" , "Selection is outside the image" );
576- return ;
576+ return false ;
577577 }
578578 if (roi !=null && roi .isArea () && roi .getType ()!=Roi .RECTANGLE ) {
579579 Roi roi2 = (Roi )cropRoi (imp , roi ).clone ();
@@ -584,6 +584,7 @@ void duplicateHyperstack(ImagePlus imp, String newTitle) {
584584 imp2 .setPosition (imp .getC (), imp .getZ (), imp .getT ());
585585 if (IJ .isMacro ()&&imp2 .getWindow ()!=null )
586586 IJ .wait (50 );
587+ return true ;
587588 }
588589
589590 String showHSDialog (ImagePlus imp , String newTitle ) {
0 commit comments